mwg API
    Preparing search index...

    Function mergeCatalogKeys

    • Drops mergedKey from catalog, keeping survivingKey (and its current text) exactly as it was - the mechanical half of collapsing two keys a human decided are the same message. Apply this to every language's own catalog to merge consistently across all of them.

      Rewriting whichever call sites used mergedKey is deliberately not this function's job: mwg has no view into a game's own source tree, the same boundary catalogUsage's referencedKeys already draws - a caller doing that rewrite already knows exactly where mergedKey is used, since it had to find referencedKeys the same way to begin with.

      Parameters

      • catalog: Catalog
      • survivingKey: string
      • mergedKey: string

      Returns Catalog

      import { mergeCatalogKeys } from '@datamoc/mw_games/i18n';

      const catalog = {
      locale: 'en', direction: 'ltr' as const,
      messages: { 'confirm.quit': 'Are you sure?', 'confirm.delete': 'Are you sure?' },
      };

      const merged = mergeCatalogKeys(catalog, 'confirm.quit', 'confirm.delete');
      console.log(Object.keys(merged.messages)); // ['confirm.quit']