@wordpress/i18n 4.3.0 → 4.3.2-next.a55ed9455a.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -224,4 +224,10 @@ _Returns_
224
224
 
225
225
  <!-- END TOKEN(Autogenerated API docs) -->
226
226
 
227
- <br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
227
+ ## Contributing to this package
228
+
229
+ This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.
230
+
231
+ To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).
232
+
233
+ <br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
@@ -292,7 +292,7 @@ const createI18n = (initialData, initialDomain, hooks) => {
292
292
  let number = arguments.length > 4 ? arguments[4] : undefined;
293
293
 
294
294
  if (!tannin.data[domain]) {
295
- // use `doSetLocaleData` to set silently, without notifying listeners
295
+ // Use `doSetLocaleData` to set silently, without notifying listeners.
296
296
  doSetLocaleData(undefined, domain);
297
297
  }
298
298
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/i18n/src/create-i18n.js"],"names":["DEFAULT_LOCALE_DATA","plural_forms","n","I18N_HOOK_REGEXP","createI18n","initialData","initialDomain","hooks","tannin","Tannin","listeners","Set","notifyListeners","forEach","listener","subscribe","callback","add","delete","getLocaleData","domain","data","doSetLocaleData","pluralForms","setLocaleData","addLocaleData","resetLocaleData","dcnpgettext","context","single","plural","number","undefined","getFilterDomain","__","text","translation","applyFilters","_x","_n","_nx","isRTL","hasTranslation","key","result","onHookAddedOrRemoved","hookName","test","addAction"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,mBAAmB,GAAG;AAC3B,MAAI;AACH;AACAC,IAAAA,YAAY,CAAEC,CAAF,EAAM;AACjB,aAAOA,CAAC,KAAK,CAAN,GAAU,CAAV,GAAc,CAArB;AACA;;AAJE;AADuB,CAA5B;AASA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAG,yCAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;;AACA;;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,UAAU,GAAG,CAAEC,WAAF,EAAeC,aAAf,EAA8BC,KAA9B,KAAyC;AAClE;AACD;AACA;AACA;AACA;AACC,QAAMC,MAAM,GAAG,IAAIC,eAAJ,CAAY,EAAZ,CAAf;AAEA,QAAMC,SAAS,GAAG,IAAIC,GAAJ,EAAlB;;AAEA,QAAMC,eAAe,GAAG,MAAM;AAC7BF,IAAAA,SAAS,CAACG,OAAV,CAAqBC,QAAF,IAAgBA,QAAQ,EAA3C;AACA,GAFD;AAIA;AACD;AACA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AAK,CAACyC,SAAN,CAAiB,aAAjB,EAAgC,WAAhC,EAA6CH,oBAA7C;AACA;;AAED,SAAO;AACN1B,IAAAA,aADM;AAENK,IAAAA,aAFM;AAGNC,IAAAA,aAHM;AAINC,IAAAA,eAJM;AAKNX,IAAAA,SALM;AAMNmB,IAAAA,EANM;AAONI,IAAAA,EAPM;AAQNC,IAAAA,EARM;AASNC,IAAAA,GATM;AAUNC,IAAAA,KAVM;AAWNC,IAAAA;AAXM,GAAP;AAaA,CA9VM","sourcesContent":["/**\n * External dependencies\n */\nimport Tannin from 'tannin';\n\n/**\n * @typedef {Record<string,any>} LocaleData\n */\n\n/**\n * Default locale data to use for Tannin domain when not otherwise provided.\n * Assumes an English plural forms expression.\n *\n * @type {LocaleData}\n */\nconst DEFAULT_LOCALE_DATA = {\n\t'': {\n\t\t/** @param {number} n */\n\t\tplural_forms( n ) {\n\t\t\treturn n === 1 ? 0 : 1;\n\t\t},\n\t},\n};\n\n/*\n * Regular expression that matches i18n hooks like `i18n.gettext`, `i18n.ngettext`,\n * `i18n.gettext_domain` or `i18n.ngettext_with_context` or `i18n.has_translation`.\n */\nconst I18N_HOOK_REGEXP = /^i18n\\.(n?gettext|has_translation)(_|$)/;\n\n/**\n * @typedef {(domain?: string) => LocaleData} GetLocaleData\n *\n * Returns locale data by domain in a\n * Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/**\n * @typedef {(data?: LocaleData, domain?: string) => void} SetLocaleData\n *\n * Merges locale data into the Tannin instance by domain. Note that this\n * function will overwrite the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/**\n * @typedef {(data?: LocaleData, domain?: string) => void} AddLocaleData\n *\n * Merges locale data into the Tannin instance by domain. Note that this\n * function will also merge the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/**\n * @typedef {(data?: LocaleData, domain?: string) => void} ResetLocaleData\n *\n * Resets all current Tannin instance locale data and sets the specified\n * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/** @typedef {() => void} SubscribeCallback */\n/** @typedef {() => void} UnsubscribeCallback */\n/**\n * @typedef {(callback: SubscribeCallback) => UnsubscribeCallback} Subscribe\n *\n * Subscribes to changes of locale data\n */\n/**\n * @typedef {(domain?: string) => string} GetFilterDomain\n * Retrieve the domain to use when calling domain-specific filters.\n */\n/**\n * @typedef {(text: string, domain?: string) => string} __\n *\n * Retrieve the translation of text.\n *\n * @see https://developer.wordpress.org/reference/functions/__/\n */\n/**\n * @typedef {(text: string, context: string, domain?: string) => string} _x\n *\n * Retrieve translated string with gettext context.\n *\n * @see https://developer.wordpress.org/reference/functions/_x/\n */\n/**\n * @typedef {(single: string, plural: string, number: number, domain?: string) => string} _n\n *\n * Translates and retrieves the singular or plural form based on the supplied\n * number.\n *\n * @see https://developer.wordpress.org/reference/functions/_n/\n */\n/**\n * @typedef {(single: string, plural: string, number: number, context: string, domain?: string) => string} _nx\n *\n * Translates and retrieves the singular or plural form based on the supplied\n * number, with gettext context.\n *\n * @see https://developer.wordpress.org/reference/functions/_nx/\n */\n/**\n * @typedef {() => boolean} IsRtl\n *\n * Check if current locale is RTL.\n *\n * **RTL (Right To Left)** is a locale property indicating that text is written from right to left.\n * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common\n * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,\n * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).\n */\n/**\n * @typedef {(single: string, context?: string, domain?: string) => boolean} HasTranslation\n *\n * Check if there is a translation for a given string in singular form.\n */\n/** @typedef {import('@wordpress/hooks').Hooks} Hooks */\n\n/**\n * An i18n instance\n *\n * @typedef I18n\n * @property {GetLocaleData} getLocaleData Returns locale data by domain in a Jed-formatted JSON object shape.\n * @property {SetLocaleData} setLocaleData Merges locale data into the Tannin instance by domain. Note that this\n * function will overwrite the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n * @property {AddLocaleData} addLocaleData Merges locale data into the Tannin instance by domain. Note that this\n * function will also merge the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n * @property {ResetLocaleData} resetLocaleData Resets all current Tannin instance locale data and sets the specified\n * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.\n * @property {Subscribe} subscribe Subscribes to changes of Tannin locale data.\n * @property {__} __ Retrieve the translation of text.\n * @property {_x} _x Retrieve translated string with gettext context.\n * @property {_n} _n Translates and retrieves the singular or plural form based on the supplied\n * number.\n * @property {_nx} _nx Translates and retrieves the singular or plural form based on the supplied\n * number, with gettext context.\n * @property {IsRtl} isRTL Check if current locale is RTL.\n * @property {HasTranslation} hasTranslation Check if there is a translation for a given string.\n */\n\n/**\n * Create an i18n instance\n *\n * @param {LocaleData} [initialData] Locale data configuration.\n * @param {string} [initialDomain] Domain for which configuration applies.\n * @param {Hooks} [hooks] Hooks implementation.\n *\n * @return {I18n} I18n instance.\n */\nexport const createI18n = ( initialData, initialDomain, hooks ) => {\n\t/**\n\t * The underlying instance of Tannin to which exported functions interface.\n\t *\n\t * @type {Tannin}\n\t */\n\tconst tannin = new Tannin( {} );\n\n\tconst listeners = new Set();\n\n\tconst notifyListeners = () => {\n\t\tlisteners.forEach( ( listener ) => listener() );\n\t};\n\n\t/**\n\t * Subscribe to changes of locale data.\n\t *\n\t * @param {SubscribeCallback} callback Subscription callback.\n\t * @return {UnsubscribeCallback} Unsubscribe callback.\n\t */\n\tconst subscribe = ( callback ) => {\n\t\tlisteners.add( callback );\n\t\treturn () => listeners.delete( callback );\n\t};\n\n\t/** @type {GetLocaleData} */\n\tconst getLocaleData = ( domain = 'default' ) => tannin.data[ domain ];\n\n\t/**\n\t * @param {LocaleData} [data]\n\t * @param {string} [domain]\n\t */\n\tconst doSetLocaleData = ( data, domain = 'default' ) => {\n\t\ttannin.data[ domain ] = {\n\t\t\t...tannin.data[ domain ],\n\t\t\t...data,\n\t\t};\n\n\t\t// Populate default domain configuration (supported locale date which omits\n\t\t// a plural forms expression).\n\t\ttannin.data[ domain ][ '' ] = {\n\t\t\t...DEFAULT_LOCALE_DATA[ '' ],\n\t\t\t...tannin.data[ domain ]?.[ '' ],\n\t\t};\n\n\t\t// Clean up cached plural forms functions cache as it might be updated.\n\t\tdelete tannin.pluralForms[ domain ];\n\t};\n\n\t/** @type {SetLocaleData} */\n\tconst setLocaleData = ( data, domain ) => {\n\t\tdoSetLocaleData( data, domain );\n\t\tnotifyListeners();\n\t};\n\n\t/** @type {AddLocaleData} */\n\tconst addLocaleData = ( data, domain = 'default' ) => {\n\t\ttannin.data[ domain ] = {\n\t\t\t...tannin.data[ domain ],\n\t\t\t...data,\n\t\t\t// Populate default domain configuration (supported locale date which omits\n\t\t\t// a plural forms expression).\n\t\t\t'': {\n\t\t\t\t...DEFAULT_LOCALE_DATA[ '' ],\n\t\t\t\t...tannin.data[ domain ]?.[ '' ],\n\t\t\t\t...data?.[ '' ],\n\t\t\t},\n\t\t};\n\n\t\t// Clean up cached plural forms functions cache as it might be updated.\n\t\tdelete tannin.pluralForms[ domain ];\n\n\t\tnotifyListeners();\n\t};\n\n\t/** @type {ResetLocaleData} */\n\tconst resetLocaleData = ( data, domain ) => {\n\t\t// Reset all current Tannin locale data.\n\t\ttannin.data = {};\n\n\t\t// Reset cached plural forms functions cache.\n\t\ttannin.pluralForms = {};\n\n\t\tsetLocaleData( data, domain );\n\t};\n\n\t/**\n\t * Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not\n\t * otherwise previously assigned.\n\t *\n\t * @param {string|undefined} domain Domain to retrieve the translated text.\n\t * @param {string|undefined} context Context information for the translators.\n\t * @param {string} single Text to translate if non-plural. Used as\n\t * fallback return value on a caught error.\n\t * @param {string} [plural] The text to be used if the number is\n\t * plural.\n\t * @param {number} [number] The number to compare against to use\n\t * either the singular or plural form.\n\t *\n\t * @return {string} The translated string.\n\t */\n\tconst dcnpgettext = (\n\t\tdomain = 'default',\n\t\tcontext,\n\t\tsingle,\n\t\tplural,\n\t\tnumber\n\t) => {\n\t\tif ( ! tannin.data[ domain ] ) {\n\t\t\t// use `doSetLocaleData` to set silently, without notifying listeners\n\t\t\tdoSetLocaleData( undefined, domain );\n\t\t}\n\n\t\treturn tannin.dcnpgettext( domain, context, single, plural, number );\n\t};\n\n\t/** @type {GetFilterDomain} */\n\tconst getFilterDomain = ( domain = 'default' ) => domain;\n\n\t/** @type {__} */\n\tconst __ = ( text, domain ) => {\n\t\tlet translation = dcnpgettext( domain, undefined, text );\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters text with its translation.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} text Text to translate.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext',\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {_x} */\n\tconst _x = ( text, context, domain ) => {\n\t\tlet translation = dcnpgettext( domain, context, text );\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters text with its translation based on context information.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} text Text to translate.\n\t\t * @param {string} context Context information for the translators.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext_with_context',\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext_with_context_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {_n} */\n\tconst _n = ( single, plural, number, domain ) => {\n\t\tlet translation = dcnpgettext(\n\t\t\tdomain,\n\t\t\tundefined,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber\n\t\t);\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters the singular or plural form of a string.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} single The text to be used if the number is singular.\n\t\t * @param {string} plural The text to be used if the number is plural.\n\t\t * @param {string} number The number to compare against to use either the singular or plural form.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext',\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {_nx} */\n\tconst _nx = ( single, plural, number, context, domain ) => {\n\t\tlet translation = dcnpgettext(\n\t\t\tdomain,\n\t\t\tcontext,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber\n\t\t);\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters the singular or plural form of a string with gettext context.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} single The text to be used if the number is singular.\n\t\t * @param {string} plural The text to be used if the number is plural.\n\t\t * @param {string} number The number to compare against to use either the singular or plural form.\n\t\t * @param {string} context Context information for the translators.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext_with_context',\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext_with_context_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {IsRtl} */\n\tconst isRTL = () => {\n\t\treturn 'rtl' === _x( 'ltr', 'text direction' );\n\t};\n\n\t/** @type {HasTranslation} */\n\tconst hasTranslation = ( single, context, domain ) => {\n\t\tconst key = context ? context + '\\u0004' + single : single;\n\t\tlet result = !! tannin.data?.[ domain ?? 'default' ]?.[ key ];\n\t\tif ( hooks ) {\n\t\t\t/**\n\t\t\t * Filters the presence of a translation in the locale data.\n\t\t\t *\n\t\t\t * @param {boolean} hasTranslation Whether the translation is present or not..\n\t\t\t * @param {string} single The singular form of the translated text (used as key in locale data)\n\t\t\t * @param {string} context Context information for the translators.\n\t\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t\t */\n\t\t\tresult = /** @type { boolean } */ (\n\t\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t\t'i18n.has_translation',\n\t\t\t\t\tresult,\n\t\t\t\t\tsingle,\n\t\t\t\t\tcontext,\n\t\t\t\t\tdomain\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tresult = /** @type { boolean } */ (\n\t\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t\t'i18n.has_translation_' + getFilterDomain( domain ),\n\t\t\t\t\tresult,\n\t\t\t\t\tsingle,\n\t\t\t\t\tcontext,\n\t\t\t\t\tdomain\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn result;\n\t};\n\n\tif ( initialData ) {\n\t\tsetLocaleData( initialData, initialDomain );\n\t}\n\n\tif ( hooks ) {\n\t\t/**\n\t\t * @param {string} hookName\n\t\t */\n\t\tconst onHookAddedOrRemoved = ( hookName ) => {\n\t\t\tif ( I18N_HOOK_REGEXP.test( hookName ) ) {\n\t\t\t\tnotifyListeners();\n\t\t\t}\n\t\t};\n\n\t\thooks.addAction( 'hookAdded', 'core/i18n', onHookAddedOrRemoved );\n\t\thooks.addAction( 'hookRemoved', 'core/i18n', onHookAddedOrRemoved );\n\t}\n\n\treturn {\n\t\tgetLocaleData,\n\t\tsetLocaleData,\n\t\taddLocaleData,\n\t\tresetLocaleData,\n\t\tsubscribe,\n\t\t__,\n\t\t_x,\n\t\t_n,\n\t\t_nx,\n\t\tisRTL,\n\t\thasTranslation,\n\t};\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/i18n/src/create-i18n.js"],"names":["DEFAULT_LOCALE_DATA","plural_forms","n","I18N_HOOK_REGEXP","createI18n","initialData","initialDomain","hooks","tannin","Tannin","listeners","Set","notifyListeners","forEach","listener","subscribe","callback","add","delete","getLocaleData","domain","data","doSetLocaleData","pluralForms","setLocaleData","addLocaleData","resetLocaleData","dcnpgettext","context","single","plural","number","undefined","getFilterDomain","__","text","translation","applyFilters","_x","_n","_nx","isRTL","hasTranslation","key","result","onHookAddedOrRemoved","hookName","test","addAction"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,mBAAmB,GAAG;AAC3B,MAAI;AACH;AACAC,IAAAA,YAAY,CAAEC,CAAF,EAAM;AACjB,aAAOA,CAAC,KAAK,CAAN,GAAU,CAAV,GAAc,CAArB;AACA;;AAJE;AADuB,CAA5B;AASA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAG,yCAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;;AACA;;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,UAAU,GAAG,CAAEC,WAAF,EAAeC,aAAf,EAA8BC,KAA9B,KAAyC;AAClE;AACD;AACA;AACA;AACA;AACC,QAAMC,MAAM,GAAG,IAAIC,eAAJ,CAAY,EAAZ,CAAf;AAEA,QAAMC,SAAS,GAAG,IAAIC,GAAJ,EAAlB;;AAEA,QAAMC,eAAe,GAAG,MAAM;AAC7BF,IAAAA,SAAS,CAACG,OAAV,CAAqBC,QAAF,IAAgBA,QAAQ,EAA3C;AACA,GAFD;AAI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C,IAAAA,KAAK,CAACyC,SAAN,CAAiB,aAAjB,EAAgC,WAAhC,EAA6CH,oBAA7C;AACA;;AAED,SAAO;AACN1B,IAAAA,aADM;AAENK,IAAAA,aAFM;AAGNC,IAAAA,aAHM;AAINC,IAAAA,eAJM;AAKNX,IAAAA,SALM;AAMNmB,IAAAA,EANM;AAONI,IAAAA,EAPM;AAQNC,IAAAA,EARM;AASNC,IAAAA,GATM;AAUNC,IAAAA,KAVM;AAWNC,IAAAA;AAXM,GAAP;AAaA,CA9VM","sourcesContent":["/**\n * External dependencies\n */\nimport Tannin from 'tannin';\n\n/**\n * @typedef {Record<string,any>} LocaleData\n */\n\n/**\n * Default locale data to use for Tannin domain when not otherwise provided.\n * Assumes an English plural forms expression.\n *\n * @type {LocaleData}\n */\nconst DEFAULT_LOCALE_DATA = {\n\t'': {\n\t\t/** @param {number} n */\n\t\tplural_forms( n ) {\n\t\t\treturn n === 1 ? 0 : 1;\n\t\t},\n\t},\n};\n\n/*\n * Regular expression that matches i18n hooks like `i18n.gettext`, `i18n.ngettext`,\n * `i18n.gettext_domain` or `i18n.ngettext_with_context` or `i18n.has_translation`.\n */\nconst I18N_HOOK_REGEXP = /^i18n\\.(n?gettext|has_translation)(_|$)/;\n\n/**\n * @typedef {(domain?: string) => LocaleData} GetLocaleData\n *\n * Returns locale data by domain in a\n * Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/**\n * @typedef {(data?: LocaleData, domain?: string) => void} SetLocaleData\n *\n * Merges locale data into the Tannin instance by domain. Note that this\n * function will overwrite the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/**\n * @typedef {(data?: LocaleData, domain?: string) => void} AddLocaleData\n *\n * Merges locale data into the Tannin instance by domain. Note that this\n * function will also merge the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/**\n * @typedef {(data?: LocaleData, domain?: string) => void} ResetLocaleData\n *\n * Resets all current Tannin instance locale data and sets the specified\n * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/** @typedef {() => void} SubscribeCallback */\n/** @typedef {() => void} UnsubscribeCallback */\n/**\n * @typedef {(callback: SubscribeCallback) => UnsubscribeCallback} Subscribe\n *\n * Subscribes to changes of locale data\n */\n/**\n * @typedef {(domain?: string) => string} GetFilterDomain\n * Retrieve the domain to use when calling domain-specific filters.\n */\n/**\n * @typedef {(text: string, domain?: string) => string} __\n *\n * Retrieve the translation of text.\n *\n * @see https://developer.wordpress.org/reference/functions/__/\n */\n/**\n * @typedef {(text: string, context: string, domain?: string) => string} _x\n *\n * Retrieve translated string with gettext context.\n *\n * @see https://developer.wordpress.org/reference/functions/_x/\n */\n/**\n * @typedef {(single: string, plural: string, number: number, domain?: string) => string} _n\n *\n * Translates and retrieves the singular or plural form based on the supplied\n * number.\n *\n * @see https://developer.wordpress.org/reference/functions/_n/\n */\n/**\n * @typedef {(single: string, plural: string, number: number, context: string, domain?: string) => string} _nx\n *\n * Translates and retrieves the singular or plural form based on the supplied\n * number, with gettext context.\n *\n * @see https://developer.wordpress.org/reference/functions/_nx/\n */\n/**\n * @typedef {() => boolean} IsRtl\n *\n * Check if current locale is RTL.\n *\n * **RTL (Right To Left)** is a locale property indicating that text is written from right to left.\n * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common\n * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,\n * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).\n */\n/**\n * @typedef {(single: string, context?: string, domain?: string) => boolean} HasTranslation\n *\n * Check if there is a translation for a given string in singular form.\n */\n/** @typedef {import('@wordpress/hooks').Hooks} Hooks */\n\n/**\n * An i18n instance\n *\n * @typedef I18n\n * @property {GetLocaleData} getLocaleData Returns locale data by domain in a Jed-formatted JSON object shape.\n * @property {SetLocaleData} setLocaleData Merges locale data into the Tannin instance by domain. Note that this\n * function will overwrite the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n * @property {AddLocaleData} addLocaleData Merges locale data into the Tannin instance by domain. Note that this\n * function will also merge the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n * @property {ResetLocaleData} resetLocaleData Resets all current Tannin instance locale data and sets the specified\n * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.\n * @property {Subscribe} subscribe Subscribes to changes of Tannin locale data.\n * @property {__} __ Retrieve the translation of text.\n * @property {_x} _x Retrieve translated string with gettext context.\n * @property {_n} _n Translates and retrieves the singular or plural form based on the supplied\n * number.\n * @property {_nx} _nx Translates and retrieves the singular or plural form based on the supplied\n * number, with gettext context.\n * @property {IsRtl} isRTL Check if current locale is RTL.\n * @property {HasTranslation} hasTranslation Check if there is a translation for a given string.\n */\n\n/**\n * Create an i18n instance\n *\n * @param {LocaleData} [initialData] Locale data configuration.\n * @param {string} [initialDomain] Domain for which configuration applies.\n * @param {Hooks} [hooks] Hooks implementation.\n *\n * @return {I18n} I18n instance.\n */\nexport const createI18n = ( initialData, initialDomain, hooks ) => {\n\t/**\n\t * The underlying instance of Tannin to which exported functions interface.\n\t *\n\t * @type {Tannin}\n\t */\n\tconst tannin = new Tannin( {} );\n\n\tconst listeners = new Set();\n\n\tconst notifyListeners = () => {\n\t\tlisteners.forEach( ( listener ) => listener() );\n\t};\n\n\t/**\n\t * Subscribe to changes of locale data.\n\t *\n\t * @param {SubscribeCallback} callback Subscription callback.\n\t * @return {UnsubscribeCallback} Unsubscribe callback.\n\t */\n\tconst subscribe = ( callback ) => {\n\t\tlisteners.add( callback );\n\t\treturn () => listeners.delete( callback );\n\t};\n\n\t/** @type {GetLocaleData} */\n\tconst getLocaleData = ( domain = 'default' ) => tannin.data[ domain ];\n\n\t/**\n\t * @param {LocaleData} [data]\n\t * @param {string} [domain]\n\t */\n\tconst doSetLocaleData = ( data, domain = 'default' ) => {\n\t\ttannin.data[ domain ] = {\n\t\t\t...tannin.data[ domain ],\n\t\t\t...data,\n\t\t};\n\n\t\t// Populate default domain configuration (supported locale date which omits\n\t\t// a plural forms expression).\n\t\ttannin.data[ domain ][ '' ] = {\n\t\t\t...DEFAULT_LOCALE_DATA[ '' ],\n\t\t\t...tannin.data[ domain ]?.[ '' ],\n\t\t};\n\n\t\t// Clean up cached plural forms functions cache as it might be updated.\n\t\tdelete tannin.pluralForms[ domain ];\n\t};\n\n\t/** @type {SetLocaleData} */\n\tconst setLocaleData = ( data, domain ) => {\n\t\tdoSetLocaleData( data, domain );\n\t\tnotifyListeners();\n\t};\n\n\t/** @type {AddLocaleData} */\n\tconst addLocaleData = ( data, domain = 'default' ) => {\n\t\ttannin.data[ domain ] = {\n\t\t\t...tannin.data[ domain ],\n\t\t\t...data,\n\t\t\t// Populate default domain configuration (supported locale date which omits\n\t\t\t// a plural forms expression).\n\t\t\t'': {\n\t\t\t\t...DEFAULT_LOCALE_DATA[ '' ],\n\t\t\t\t...tannin.data[ domain ]?.[ '' ],\n\t\t\t\t...data?.[ '' ],\n\t\t\t},\n\t\t};\n\n\t\t// Clean up cached plural forms functions cache as it might be updated.\n\t\tdelete tannin.pluralForms[ domain ];\n\n\t\tnotifyListeners();\n\t};\n\n\t/** @type {ResetLocaleData} */\n\tconst resetLocaleData = ( data, domain ) => {\n\t\t// Reset all current Tannin locale data.\n\t\ttannin.data = {};\n\n\t\t// Reset cached plural forms functions cache.\n\t\ttannin.pluralForms = {};\n\n\t\tsetLocaleData( data, domain );\n\t};\n\n\t/**\n\t * Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not\n\t * otherwise previously assigned.\n\t *\n\t * @param {string|undefined} domain Domain to retrieve the translated text.\n\t * @param {string|undefined} context Context information for the translators.\n\t * @param {string} single Text to translate if non-plural. Used as\n\t * fallback return value on a caught error.\n\t * @param {string} [plural] The text to be used if the number is\n\t * plural.\n\t * @param {number} [number] The number to compare against to use\n\t * either the singular or plural form.\n\t *\n\t * @return {string} The translated string.\n\t */\n\tconst dcnpgettext = (\n\t\tdomain = 'default',\n\t\tcontext,\n\t\tsingle,\n\t\tplural,\n\t\tnumber\n\t) => {\n\t\tif ( ! tannin.data[ domain ] ) {\n\t\t\t// Use `doSetLocaleData` to set silently, without notifying listeners.\n\t\t\tdoSetLocaleData( undefined, domain );\n\t\t}\n\n\t\treturn tannin.dcnpgettext( domain, context, single, plural, number );\n\t};\n\n\t/** @type {GetFilterDomain} */\n\tconst getFilterDomain = ( domain = 'default' ) => domain;\n\n\t/** @type {__} */\n\tconst __ = ( text, domain ) => {\n\t\tlet translation = dcnpgettext( domain, undefined, text );\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters text with its translation.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} text Text to translate.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext',\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {_x} */\n\tconst _x = ( text, context, domain ) => {\n\t\tlet translation = dcnpgettext( domain, context, text );\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters text with its translation based on context information.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} text Text to translate.\n\t\t * @param {string} context Context information for the translators.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext_with_context',\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext_with_context_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {_n} */\n\tconst _n = ( single, plural, number, domain ) => {\n\t\tlet translation = dcnpgettext(\n\t\t\tdomain,\n\t\t\tundefined,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber\n\t\t);\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters the singular or plural form of a string.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} single The text to be used if the number is singular.\n\t\t * @param {string} plural The text to be used if the number is plural.\n\t\t * @param {string} number The number to compare against to use either the singular or plural form.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext',\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {_nx} */\n\tconst _nx = ( single, plural, number, context, domain ) => {\n\t\tlet translation = dcnpgettext(\n\t\t\tdomain,\n\t\t\tcontext,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber\n\t\t);\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters the singular or plural form of a string with gettext context.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} single The text to be used if the number is singular.\n\t\t * @param {string} plural The text to be used if the number is plural.\n\t\t * @param {string} number The number to compare against to use either the singular or plural form.\n\t\t * @param {string} context Context information for the translators.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext_with_context',\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext_with_context_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {IsRtl} */\n\tconst isRTL = () => {\n\t\treturn 'rtl' === _x( 'ltr', 'text direction' );\n\t};\n\n\t/** @type {HasTranslation} */\n\tconst hasTranslation = ( single, context, domain ) => {\n\t\tconst key = context ? context + '\\u0004' + single : single;\n\t\tlet result = !! tannin.data?.[ domain ?? 'default' ]?.[ key ];\n\t\tif ( hooks ) {\n\t\t\t/**\n\t\t\t * Filters the presence of a translation in the locale data.\n\t\t\t *\n\t\t\t * @param {boolean} hasTranslation Whether the translation is present or not..\n\t\t\t * @param {string} single The singular form of the translated text (used as key in locale data)\n\t\t\t * @param {string} context Context information for the translators.\n\t\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t\t */\n\t\t\tresult = /** @type { boolean } */ (\n\t\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t\t'i18n.has_translation',\n\t\t\t\t\tresult,\n\t\t\t\t\tsingle,\n\t\t\t\t\tcontext,\n\t\t\t\t\tdomain\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tresult = /** @type { boolean } */ (\n\t\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t\t'i18n.has_translation_' + getFilterDomain( domain ),\n\t\t\t\t\tresult,\n\t\t\t\t\tsingle,\n\t\t\t\t\tcontext,\n\t\t\t\t\tdomain\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn result;\n\t};\n\n\tif ( initialData ) {\n\t\tsetLocaleData( initialData, initialDomain );\n\t}\n\n\tif ( hooks ) {\n\t\t/**\n\t\t * @param {string} hookName\n\t\t */\n\t\tconst onHookAddedOrRemoved = ( hookName ) => {\n\t\t\tif ( I18N_HOOK_REGEXP.test( hookName ) ) {\n\t\t\t\tnotifyListeners();\n\t\t\t}\n\t\t};\n\n\t\thooks.addAction( 'hookAdded', 'core/i18n', onHookAddedOrRemoved );\n\t\thooks.addAction( 'hookRemoved', 'core/i18n', onHookAddedOrRemoved );\n\t}\n\n\treturn {\n\t\tgetLocaleData,\n\t\tsetLocaleData,\n\t\taddLocaleData,\n\t\tresetLocaleData,\n\t\tsubscribe,\n\t\t__,\n\t\t_x,\n\t\t_n,\n\t\t_nx,\n\t\tisRTL,\n\t\thasTranslation,\n\t};\n};\n"]}
@@ -282,7 +282,7 @@ export const createI18n = (initialData, initialDomain, hooks) => {
282
282
  let number = arguments.length > 4 ? arguments[4] : undefined;
283
283
 
284
284
  if (!tannin.data[domain]) {
285
- // use `doSetLocaleData` to set silently, without notifying listeners
285
+ // Use `doSetLocaleData` to set silently, without notifying listeners.
286
286
  doSetLocaleData(undefined, domain);
287
287
  }
288
288
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/i18n/src/create-i18n.js"],"names":["Tannin","DEFAULT_LOCALE_DATA","plural_forms","n","I18N_HOOK_REGEXP","createI18n","initialData","initialDomain","hooks","tannin","listeners","Set","notifyListeners","forEach","listener","subscribe","callback","add","delete","getLocaleData","domain","data","doSetLocaleData","pluralForms","setLocaleData","addLocaleData","resetLocaleData","dcnpgettext","context","single","plural","number","undefined","getFilterDomain","__","text","translation","applyFilters","_x","_n","_nx","isRTL","hasTranslation","key","result","onHookAddedOrRemoved","hookName","test","addAction"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,MAAP,MAAmB,QAAnB;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAG;AAC3B,MAAI;AACH;AACAC,IAAAA,YAAY,CAAEC,CAAF,EAAM;AACjB,aAAOA,CAAC,KAAK,CAAN,GAAU,CAAV,GAAc,CAArB;AACA;;AAJE;AADuB,CAA5B;AASA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAG,yCAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;;AACA;;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,UAAU,GAAG,CAAEC,WAAF,EAAe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;AACA;;AAED,MAAKC,KAAL,EAAa;AACZ;AACF;AACA;AACE,UAAMqC,oBAAoB,GAAKC,QAAF,IAAgB;AAC5C,UAAK1C,gBAAgB,CAAC2C,IAAjB,CAAuBD,QAAvB,CAAL,EAAyC;AACxClC,QAAAA,eAAe;AACf;AACD,KAJD;;AAMAJ,IAAAA,KAAK,CAACwC,SAAN,CAAiB,WAAjB,EAA8B,WAA9B,EAA2CH,oBAA3C;AACArC,IAAAA,KAAK,CAACwC,SAAN,CAAiB,aAAjB,EAAgC,WAAhC,EAA6CH,oBAA7C;AACA;;AAED,SAAO;AACN1B,IAAAA,aADM;AAENK,IAAAA,aAFM;AAGNC,IAAAA,aAHM;AAINC,IAAAA,eAJM;AAKNX,IAAAA,SALM;AAMNmB,IAAAA,EANM;AAONI,IAAAA,EAPM;AAQNC,IAAAA,EARM;AASNC,IAAAA,GATM;AAUNC,IAAAA,KAVM;AAWNC,IAAAA;AAXM,GAAP;AAaA,CA9VM","sourcesContent":["/**\n * External dependencies\n */\nimport Tannin from 'tannin';\n\n/**\n * @typedef {Record<string,any>} LocaleData\n */\n\n/**\n * Default locale data to use for Tannin domain when not otherwise provided.\n * Assumes an English plural forms expression.\n *\n * @type {LocaleData}\n */\nconst DEFAULT_LOCALE_DATA = {\n\t'': {\n\t\t/** @param {number} n */\n\t\tplural_forms( n ) {\n\t\t\treturn n === 1 ? 0 : 1;\n\t\t},\n\t},\n};\n\n/*\n * Regular expression that matches i18n hooks like `i18n.gettext`, `i18n.ngettext`,\n * `i18n.gettext_domain` or `i18n.ngettext_with_context` or `i18n.has_translation`.\n */\nconst I18N_HOOK_REGEXP = /^i18n\\.(n?gettext|has_translation)(_|$)/;\n\n/**\n * @typedef {(domain?: string) => LocaleData} GetLocaleData\n *\n * Returns locale data by domain in a\n * Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/**\n * @typedef {(data?: LocaleData, domain?: string) => void} SetLocaleData\n *\n * Merges locale data into the Tannin instance by domain. Note that this\n * function will overwrite the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/**\n * @typedef {(data?: LocaleData, domain?: string) => void} AddLocaleData\n *\n * Merges locale data into the Tannin instance by domain. Note that this\n * function will also merge the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/**\n * @typedef {(data?: LocaleData, domain?: string) => void} ResetLocaleData\n *\n * Resets all current Tannin instance locale data and sets the specified\n * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/** @typedef {() => void} SubscribeCallback */\n/** @typedef {() => void} UnsubscribeCallback */\n/**\n * @typedef {(callback: SubscribeCallback) => UnsubscribeCallback} Subscribe\n *\n * Subscribes to changes of locale data\n */\n/**\n * @typedef {(domain?: string) => string} GetFilterDomain\n * Retrieve the domain to use when calling domain-specific filters.\n */\n/**\n * @typedef {(text: string, domain?: string) => string} __\n *\n * Retrieve the translation of text.\n *\n * @see https://developer.wordpress.org/reference/functions/__/\n */\n/**\n * @typedef {(text: string, context: string, domain?: string) => string} _x\n *\n * Retrieve translated string with gettext context.\n *\n * @see https://developer.wordpress.org/reference/functions/_x/\n */\n/**\n * @typedef {(single: string, plural: string, number: number, domain?: string) => string} _n\n *\n * Translates and retrieves the singular or plural form based on the supplied\n * number.\n *\n * @see https://developer.wordpress.org/reference/functions/_n/\n */\n/**\n * @typedef {(single: string, plural: string, number: number, context: string, domain?: string) => string} _nx\n *\n * Translates and retrieves the singular or plural form based on the supplied\n * number, with gettext context.\n *\n * @see https://developer.wordpress.org/reference/functions/_nx/\n */\n/**\n * @typedef {() => boolean} IsRtl\n *\n * Check if current locale is RTL.\n *\n * **RTL (Right To Left)** is a locale property indicating that text is written from right to left.\n * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common\n * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,\n * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).\n */\n/**\n * @typedef {(single: string, context?: string, domain?: string) => boolean} HasTranslation\n *\n * Check if there is a translation for a given string in singular form.\n */\n/** @typedef {import('@wordpress/hooks').Hooks} Hooks */\n\n/**\n * An i18n instance\n *\n * @typedef I18n\n * @property {GetLocaleData} getLocaleData Returns locale data by domain in a Jed-formatted JSON object shape.\n * @property {SetLocaleData} setLocaleData Merges locale data into the Tannin instance by domain. Note that this\n * function will overwrite the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n * @property {AddLocaleData} addLocaleData Merges locale data into the Tannin instance by domain. Note that this\n * function will also merge the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n * @property {ResetLocaleData} resetLocaleData Resets all current Tannin instance locale data and sets the specified\n * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.\n * @property {Subscribe} subscribe Subscribes to changes of Tannin locale data.\n * @property {__} __ Retrieve the translation of text.\n * @property {_x} _x Retrieve translated string with gettext context.\n * @property {_n} _n Translates and retrieves the singular or plural form based on the supplied\n * number.\n * @property {_nx} _nx Translates and retrieves the singular or plural form based on the supplied\n * number, with gettext context.\n * @property {IsRtl} isRTL Check if current locale is RTL.\n * @property {HasTranslation} hasTranslation Check if there is a translation for a given string.\n */\n\n/**\n * Create an i18n instance\n *\n * @param {LocaleData} [initialData] Locale data configuration.\n * @param {string} [initialDomain] Domain for which configuration applies.\n * @param {Hooks} [hooks] Hooks implementation.\n *\n * @return {I18n} I18n instance.\n */\nexport const createI18n = ( initialData, initialDomain, hooks ) => {\n\t/**\n\t * The underlying instance of Tannin to which exported functions interface.\n\t *\n\t * @type {Tannin}\n\t */\n\tconst tannin = new Tannin( {} );\n\n\tconst listeners = new Set();\n\n\tconst notifyListeners = () => {\n\t\tlisteners.forEach( ( listener ) => listener() );\n\t};\n\n\t/**\n\t * Subscribe to changes of locale data.\n\t *\n\t * @param {SubscribeCallback} callback Subscription callback.\n\t * @return {UnsubscribeCallback} Unsubscribe callback.\n\t */\n\tconst subscribe = ( callback ) => {\n\t\tlisteners.add( callback );\n\t\treturn () => listeners.delete( callback );\n\t};\n\n\t/** @type {GetLocaleData} */\n\tconst getLocaleData = ( domain = 'default' ) => tannin.data[ domain ];\n\n\t/**\n\t * @param {LocaleData} [data]\n\t * @param {string} [domain]\n\t */\n\tconst doSetLocaleData = ( data, domain = 'default' ) => {\n\t\ttannin.data[ domain ] = {\n\t\t\t...tannin.data[ domain ],\n\t\t\t...data,\n\t\t};\n\n\t\t// Populate default domain configuration (supported locale date which omits\n\t\t// a plural forms expression).\n\t\ttannin.data[ domain ][ '' ] = {\n\t\t\t...DEFAULT_LOCALE_DATA[ '' ],\n\t\t\t...tannin.data[ domain ]?.[ '' ],\n\t\t};\n\n\t\t// Clean up cached plural forms functions cache as it might be updated.\n\t\tdelete tannin.pluralForms[ domain ];\n\t};\n\n\t/** @type {SetLocaleData} */\n\tconst setLocaleData = ( data, domain ) => {\n\t\tdoSetLocaleData( data, domain );\n\t\tnotifyListeners();\n\t};\n\n\t/** @type {AddLocaleData} */\n\tconst addLocaleData = ( data, domain = 'default' ) => {\n\t\ttannin.data[ domain ] = {\n\t\t\t...tannin.data[ domain ],\n\t\t\t...data,\n\t\t\t// Populate default domain configuration (supported locale date which omits\n\t\t\t// a plural forms expression).\n\t\t\t'': {\n\t\t\t\t...DEFAULT_LOCALE_DATA[ '' ],\n\t\t\t\t...tannin.data[ domain ]?.[ '' ],\n\t\t\t\t...data?.[ '' ],\n\t\t\t},\n\t\t};\n\n\t\t// Clean up cached plural forms functions cache as it might be updated.\n\t\tdelete tannin.pluralForms[ domain ];\n\n\t\tnotifyListeners();\n\t};\n\n\t/** @type {ResetLocaleData} */\n\tconst resetLocaleData = ( data, domain ) => {\n\t\t// Reset all current Tannin locale data.\n\t\ttannin.data = {};\n\n\t\t// Reset cached plural forms functions cache.\n\t\ttannin.pluralForms = {};\n\n\t\tsetLocaleData( data, domain );\n\t};\n\n\t/**\n\t * Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not\n\t * otherwise previously assigned.\n\t *\n\t * @param {string|undefined} domain Domain to retrieve the translated text.\n\t * @param {string|undefined} context Context information for the translators.\n\t * @param {string} single Text to translate if non-plural. Used as\n\t * fallback return value on a caught error.\n\t * @param {string} [plural] The text to be used if the number is\n\t * plural.\n\t * @param {number} [number] The number to compare against to use\n\t * either the singular or plural form.\n\t *\n\t * @return {string} The translated string.\n\t */\n\tconst dcnpgettext = (\n\t\tdomain = 'default',\n\t\tcontext,\n\t\tsingle,\n\t\tplural,\n\t\tnumber\n\t) => {\n\t\tif ( ! tannin.data[ domain ] ) {\n\t\t\t// use `doSetLocaleData` to set silently, without notifying listeners\n\t\t\tdoSetLocaleData( undefined, domain );\n\t\t}\n\n\t\treturn tannin.dcnpgettext( domain, context, single, plural, number );\n\t};\n\n\t/** @type {GetFilterDomain} */\n\tconst getFilterDomain = ( domain = 'default' ) => domain;\n\n\t/** @type {__} */\n\tconst __ = ( text, domain ) => {\n\t\tlet translation = dcnpgettext( domain, undefined, text );\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters text with its translation.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} text Text to translate.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext',\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {_x} */\n\tconst _x = ( text, context, domain ) => {\n\t\tlet translation = dcnpgettext( domain, context, text );\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters text with its translation based on context information.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} text Text to translate.\n\t\t * @param {string} context Context information for the translators.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext_with_context',\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext_with_context_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {_n} */\n\tconst _n = ( single, plural, number, domain ) => {\n\t\tlet translation = dcnpgettext(\n\t\t\tdomain,\n\t\t\tundefined,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber\n\t\t);\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters the singular or plural form of a string.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} single The text to be used if the number is singular.\n\t\t * @param {string} plural The text to be used if the number is plural.\n\t\t * @param {string} number The number to compare against to use either the singular or plural form.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext',\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {_nx} */\n\tconst _nx = ( single, plural, number, context, domain ) => {\n\t\tlet translation = dcnpgettext(\n\t\t\tdomain,\n\t\t\tcontext,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber\n\t\t);\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters the singular or plural form of a string with gettext context.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} single The text to be used if the number is singular.\n\t\t * @param {string} plural The text to be used if the number is plural.\n\t\t * @param {string} number The number to compare against to use either the singular or plural form.\n\t\t * @param {string} context Context information for the translators.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext_with_context',\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext_with_context_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {IsRtl} */\n\tconst isRTL = () => {\n\t\treturn 'rtl' === _x( 'ltr', 'text direction' );\n\t};\n\n\t/** @type {HasTranslation} */\n\tconst hasTranslation = ( single, context, domain ) => {\n\t\tconst key = context ? context + '\\u0004' + single : single;\n\t\tlet result = !! tannin.data?.[ domain ?? 'default' ]?.[ key ];\n\t\tif ( hooks ) {\n\t\t\t/**\n\t\t\t * Filters the presence of a translation in the locale data.\n\t\t\t *\n\t\t\t * @param {boolean} hasTranslation Whether the translation is present or not..\n\t\t\t * @param {string} single The singular form of the translated text (used as key in locale data)\n\t\t\t * @param {string} context Context information for the translators.\n\t\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t\t */\n\t\t\tresult = /** @type { boolean } */ (\n\t\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t\t'i18n.has_translation',\n\t\t\t\t\tresult,\n\t\t\t\t\tsingle,\n\t\t\t\t\tcontext,\n\t\t\t\t\tdomain\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tresult = /** @type { boolean } */ (\n\t\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t\t'i18n.has_translation_' + getFilterDomain( domain ),\n\t\t\t\t\tresult,\n\t\t\t\t\tsingle,\n\t\t\t\t\tcontext,\n\t\t\t\t\tdomain\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn result;\n\t};\n\n\tif ( initialData ) {\n\t\tsetLocaleData( initialData, initialDomain );\n\t}\n\n\tif ( hooks ) {\n\t\t/**\n\t\t * @param {string} hookName\n\t\t */\n\t\tconst onHookAddedOrRemoved = ( hookName ) => {\n\t\t\tif ( I18N_HOOK_REGEXP.test( hookName ) ) {\n\t\t\t\tnotifyListeners();\n\t\t\t}\n\t\t};\n\n\t\thooks.addAction( 'hookAdded', 'core/i18n', onHookAddedOrRemoved );\n\t\thooks.addAction( 'hookRemoved', 'core/i18n', onHookAddedOrRemoved );\n\t}\n\n\treturn {\n\t\tgetLocaleData,\n\t\tsetLocaleData,\n\t\taddLocaleData,\n\t\tresetLocaleData,\n\t\tsubscribe,\n\t\t__,\n\t\t_x,\n\t\t_n,\n\t\t_nx,\n\t\tisRTL,\n\t\thasTranslation,\n\t};\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/i18n/src/create-i18n.js"],"names":["Tannin","DEFAULT_LOCALE_DATA","plural_forms","n","I18N_HOOK_REGEXP","createI18n","initialData","initialDomain","hooks","tannin","listeners","Set","notifyListeners","forEach","listener","subscribe","callback","add","delete","getLocaleData","domain","data","doSetLocaleData","pluralForms","setLocaleData","addLocaleData","resetLocaleData","dcnpgettext","context","single","plural","number","undefined","getFilterDomain","__","text","translation","applyFilters","_x","_n","_nx","isRTL","hasTranslation","key","result","onHookAddedOrRemoved","hookName","test","addAction"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,MAAP,MAAmB,QAAnB;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAG;AAC3B,MAAI;AACH;AACAC,IAAAA,YAAY,CAAEC,CAAF,EAAM;AACjB,aAAOA,CAAC,KAAK,CAAN,GAAU,CAAV,GAAc,CAArB;AACA;;AAJE;AADuB,CAA5B;AASA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAG,yCAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;;AACA;;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAM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,CAAElB,WAAF,EAAeC,aAAf,CAAb;AACA;;AAED,MAAKC,KAAL,EAAa;AACZ;AACF;AACA;AACE,UAAMqC,oBAAoB,GAAKC,QAAF,IAAgB;AAC5C,UAAK1C,gBAAgB,CAAC2C,IAAjB,CAAuBD,QAAvB,CAAL,EAAyC;AACxClC,QAAAA,eAAe;AACf;AACD,KAJD;;AAMAJ,IAAAA,KAAK,CAACwC,SAAN,CAAiB,WAAjB,EAA8B,WAA9B,EAA2CH,oBAA3C;AACArC,IAAAA,KAAK,CAACwC,SAAN,CAAiB,aAAjB,EAAgC,WAAhC,EAA6CH,oBAA7C;AACA;;AAED,SAAO;AACN1B,IAAAA,aADM;AAENK,IAAAA,aAFM;AAGNC,IAAAA,aAHM;AAINC,IAAAA,eAJM;AAKNX,IAAAA,SALM;AAMNmB,IAAAA,EANM;AAONI,IAAAA,EAPM;AAQNC,IAAAA,EARM;AASNC,IAAAA,GATM;AAUNC,IAAAA,KAVM;AAWNC,IAAAA;AAXM,GAAP;AAaA,CA9VM","sourcesContent":["/**\n * External dependencies\n */\nimport Tannin from 'tannin';\n\n/**\n * @typedef {Record<string,any>} LocaleData\n */\n\n/**\n * Default locale data to use for Tannin domain when not otherwise provided.\n * Assumes an English plural forms expression.\n *\n * @type {LocaleData}\n */\nconst DEFAULT_LOCALE_DATA = {\n\t'': {\n\t\t/** @param {number} n */\n\t\tplural_forms( n ) {\n\t\t\treturn n === 1 ? 0 : 1;\n\t\t},\n\t},\n};\n\n/*\n * Regular expression that matches i18n hooks like `i18n.gettext`, `i18n.ngettext`,\n * `i18n.gettext_domain` or `i18n.ngettext_with_context` or `i18n.has_translation`.\n */\nconst I18N_HOOK_REGEXP = /^i18n\\.(n?gettext|has_translation)(_|$)/;\n\n/**\n * @typedef {(domain?: string) => LocaleData} GetLocaleData\n *\n * Returns locale data by domain in a\n * Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/**\n * @typedef {(data?: LocaleData, domain?: string) => void} SetLocaleData\n *\n * Merges locale data into the Tannin instance by domain. Note that this\n * function will overwrite the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/**\n * @typedef {(data?: LocaleData, domain?: string) => void} AddLocaleData\n *\n * Merges locale data into the Tannin instance by domain. Note that this\n * function will also merge the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/**\n * @typedef {(data?: LocaleData, domain?: string) => void} ResetLocaleData\n *\n * Resets all current Tannin instance locale data and sets the specified\n * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.\n *\n * @see http://messageformat.github.io/Jed/\n */\n/** @typedef {() => void} SubscribeCallback */\n/** @typedef {() => void} UnsubscribeCallback */\n/**\n * @typedef {(callback: SubscribeCallback) => UnsubscribeCallback} Subscribe\n *\n * Subscribes to changes of locale data\n */\n/**\n * @typedef {(domain?: string) => string} GetFilterDomain\n * Retrieve the domain to use when calling domain-specific filters.\n */\n/**\n * @typedef {(text: string, domain?: string) => string} __\n *\n * Retrieve the translation of text.\n *\n * @see https://developer.wordpress.org/reference/functions/__/\n */\n/**\n * @typedef {(text: string, context: string, domain?: string) => string} _x\n *\n * Retrieve translated string with gettext context.\n *\n * @see https://developer.wordpress.org/reference/functions/_x/\n */\n/**\n * @typedef {(single: string, plural: string, number: number, domain?: string) => string} _n\n *\n * Translates and retrieves the singular or plural form based on the supplied\n * number.\n *\n * @see https://developer.wordpress.org/reference/functions/_n/\n */\n/**\n * @typedef {(single: string, plural: string, number: number, context: string, domain?: string) => string} _nx\n *\n * Translates and retrieves the singular or plural form based on the supplied\n * number, with gettext context.\n *\n * @see https://developer.wordpress.org/reference/functions/_nx/\n */\n/**\n * @typedef {() => boolean} IsRtl\n *\n * Check if current locale is RTL.\n *\n * **RTL (Right To Left)** is a locale property indicating that text is written from right to left.\n * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common\n * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,\n * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).\n */\n/**\n * @typedef {(single: string, context?: string, domain?: string) => boolean} HasTranslation\n *\n * Check if there is a translation for a given string in singular form.\n */\n/** @typedef {import('@wordpress/hooks').Hooks} Hooks */\n\n/**\n * An i18n instance\n *\n * @typedef I18n\n * @property {GetLocaleData} getLocaleData Returns locale data by domain in a Jed-formatted JSON object shape.\n * @property {SetLocaleData} setLocaleData Merges locale data into the Tannin instance by domain. Note that this\n * function will overwrite the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n * @property {AddLocaleData} addLocaleData Merges locale data into the Tannin instance by domain. Note that this\n * function will also merge the domain configuration. Accepts data in a\n * Jed-formatted JSON object shape.\n * @property {ResetLocaleData} resetLocaleData Resets all current Tannin instance locale data and sets the specified\n * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.\n * @property {Subscribe} subscribe Subscribes to changes of Tannin locale data.\n * @property {__} __ Retrieve the translation of text.\n * @property {_x} _x Retrieve translated string with gettext context.\n * @property {_n} _n Translates and retrieves the singular or plural form based on the supplied\n * number.\n * @property {_nx} _nx Translates and retrieves the singular or plural form based on the supplied\n * number, with gettext context.\n * @property {IsRtl} isRTL Check if current locale is RTL.\n * @property {HasTranslation} hasTranslation Check if there is a translation for a given string.\n */\n\n/**\n * Create an i18n instance\n *\n * @param {LocaleData} [initialData] Locale data configuration.\n * @param {string} [initialDomain] Domain for which configuration applies.\n * @param {Hooks} [hooks] Hooks implementation.\n *\n * @return {I18n} I18n instance.\n */\nexport const createI18n = ( initialData, initialDomain, hooks ) => {\n\t/**\n\t * The underlying instance of Tannin to which exported functions interface.\n\t *\n\t * @type {Tannin}\n\t */\n\tconst tannin = new Tannin( {} );\n\n\tconst listeners = new Set();\n\n\tconst notifyListeners = () => {\n\t\tlisteners.forEach( ( listener ) => listener() );\n\t};\n\n\t/**\n\t * Subscribe to changes of locale data.\n\t *\n\t * @param {SubscribeCallback} callback Subscription callback.\n\t * @return {UnsubscribeCallback} Unsubscribe callback.\n\t */\n\tconst subscribe = ( callback ) => {\n\t\tlisteners.add( callback );\n\t\treturn () => listeners.delete( callback );\n\t};\n\n\t/** @type {GetLocaleData} */\n\tconst getLocaleData = ( domain = 'default' ) => tannin.data[ domain ];\n\n\t/**\n\t * @param {LocaleData} [data]\n\t * @param {string} [domain]\n\t */\n\tconst doSetLocaleData = ( data, domain = 'default' ) => {\n\t\ttannin.data[ domain ] = {\n\t\t\t...tannin.data[ domain ],\n\t\t\t...data,\n\t\t};\n\n\t\t// Populate default domain configuration (supported locale date which omits\n\t\t// a plural forms expression).\n\t\ttannin.data[ domain ][ '' ] = {\n\t\t\t...DEFAULT_LOCALE_DATA[ '' ],\n\t\t\t...tannin.data[ domain ]?.[ '' ],\n\t\t};\n\n\t\t// Clean up cached plural forms functions cache as it might be updated.\n\t\tdelete tannin.pluralForms[ domain ];\n\t};\n\n\t/** @type {SetLocaleData} */\n\tconst setLocaleData = ( data, domain ) => {\n\t\tdoSetLocaleData( data, domain );\n\t\tnotifyListeners();\n\t};\n\n\t/** @type {AddLocaleData} */\n\tconst addLocaleData = ( data, domain = 'default' ) => {\n\t\ttannin.data[ domain ] = {\n\t\t\t...tannin.data[ domain ],\n\t\t\t...data,\n\t\t\t// Populate default domain configuration (supported locale date which omits\n\t\t\t// a plural forms expression).\n\t\t\t'': {\n\t\t\t\t...DEFAULT_LOCALE_DATA[ '' ],\n\t\t\t\t...tannin.data[ domain ]?.[ '' ],\n\t\t\t\t...data?.[ '' ],\n\t\t\t},\n\t\t};\n\n\t\t// Clean up cached plural forms functions cache as it might be updated.\n\t\tdelete tannin.pluralForms[ domain ];\n\n\t\tnotifyListeners();\n\t};\n\n\t/** @type {ResetLocaleData} */\n\tconst resetLocaleData = ( data, domain ) => {\n\t\t// Reset all current Tannin locale data.\n\t\ttannin.data = {};\n\n\t\t// Reset cached plural forms functions cache.\n\t\ttannin.pluralForms = {};\n\n\t\tsetLocaleData( data, domain );\n\t};\n\n\t/**\n\t * Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not\n\t * otherwise previously assigned.\n\t *\n\t * @param {string|undefined} domain Domain to retrieve the translated text.\n\t * @param {string|undefined} context Context information for the translators.\n\t * @param {string} single Text to translate if non-plural. Used as\n\t * fallback return value on a caught error.\n\t * @param {string} [plural] The text to be used if the number is\n\t * plural.\n\t * @param {number} [number] The number to compare against to use\n\t * either the singular or plural form.\n\t *\n\t * @return {string} The translated string.\n\t */\n\tconst dcnpgettext = (\n\t\tdomain = 'default',\n\t\tcontext,\n\t\tsingle,\n\t\tplural,\n\t\tnumber\n\t) => {\n\t\tif ( ! tannin.data[ domain ] ) {\n\t\t\t// Use `doSetLocaleData` to set silently, without notifying listeners.\n\t\t\tdoSetLocaleData( undefined, domain );\n\t\t}\n\n\t\treturn tannin.dcnpgettext( domain, context, single, plural, number );\n\t};\n\n\t/** @type {GetFilterDomain} */\n\tconst getFilterDomain = ( domain = 'default' ) => domain;\n\n\t/** @type {__} */\n\tconst __ = ( text, domain ) => {\n\t\tlet translation = dcnpgettext( domain, undefined, text );\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters text with its translation.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} text Text to translate.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext',\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {_x} */\n\tconst _x = ( text, context, domain ) => {\n\t\tlet translation = dcnpgettext( domain, context, text );\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters text with its translation based on context information.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} text Text to translate.\n\t\t * @param {string} context Context information for the translators.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext_with_context',\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.gettext_with_context_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\ttext,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {_n} */\n\tconst _n = ( single, plural, number, domain ) => {\n\t\tlet translation = dcnpgettext(\n\t\t\tdomain,\n\t\t\tundefined,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber\n\t\t);\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters the singular or plural form of a string.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} single The text to be used if the number is singular.\n\t\t * @param {string} plural The text to be used if the number is plural.\n\t\t * @param {string} number The number to compare against to use either the singular or plural form.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext',\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {_nx} */\n\tconst _nx = ( single, plural, number, context, domain ) => {\n\t\tlet translation = dcnpgettext(\n\t\t\tdomain,\n\t\t\tcontext,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber\n\t\t);\n\t\tif ( ! hooks ) {\n\t\t\treturn translation;\n\t\t}\n\n\t\t/**\n\t\t * Filters the singular or plural form of a string with gettext context.\n\t\t *\n\t\t * @param {string} translation Translated text.\n\t\t * @param {string} single The text to be used if the number is singular.\n\t\t * @param {string} plural The text to be used if the number is plural.\n\t\t * @param {string} number The number to compare against to use either the singular or plural form.\n\t\t * @param {string} context Context information for the translators.\n\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext_with_context',\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\n\t\treturn /** @type {string} */ (\n\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t'i18n.ngettext_with_context_' + getFilterDomain( domain ),\n\t\t\t\ttranslation,\n\t\t\t\tsingle,\n\t\t\t\tplural,\n\t\t\t\tnumber,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t)\n\t\t);\n\t};\n\n\t/** @type {IsRtl} */\n\tconst isRTL = () => {\n\t\treturn 'rtl' === _x( 'ltr', 'text direction' );\n\t};\n\n\t/** @type {HasTranslation} */\n\tconst hasTranslation = ( single, context, domain ) => {\n\t\tconst key = context ? context + '\\u0004' + single : single;\n\t\tlet result = !! tannin.data?.[ domain ?? 'default' ]?.[ key ];\n\t\tif ( hooks ) {\n\t\t\t/**\n\t\t\t * Filters the presence of a translation in the locale data.\n\t\t\t *\n\t\t\t * @param {boolean} hasTranslation Whether the translation is present or not..\n\t\t\t * @param {string} single The singular form of the translated text (used as key in locale data)\n\t\t\t * @param {string} context Context information for the translators.\n\t\t\t * @param {string} domain Text domain. Unique identifier for retrieving translated strings.\n\t\t\t */\n\t\t\tresult = /** @type { boolean } */ (\n\t\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t\t'i18n.has_translation',\n\t\t\t\t\tresult,\n\t\t\t\t\tsingle,\n\t\t\t\t\tcontext,\n\t\t\t\t\tdomain\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tresult = /** @type { boolean } */ (\n\t\t\t\t/** @type {*} */ hooks.applyFilters(\n\t\t\t\t\t'i18n.has_translation_' + getFilterDomain( domain ),\n\t\t\t\t\tresult,\n\t\t\t\t\tsingle,\n\t\t\t\t\tcontext,\n\t\t\t\t\tdomain\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn result;\n\t};\n\n\tif ( initialData ) {\n\t\tsetLocaleData( initialData, initialDomain );\n\t}\n\n\tif ( hooks ) {\n\t\t/**\n\t\t * @param {string} hookName\n\t\t */\n\t\tconst onHookAddedOrRemoved = ( hookName ) => {\n\t\t\tif ( I18N_HOOK_REGEXP.test( hookName ) ) {\n\t\t\t\tnotifyListeners();\n\t\t\t}\n\t\t};\n\n\t\thooks.addAction( 'hookAdded', 'core/i18n', onHookAddedOrRemoved );\n\t\thooks.addAction( 'hookRemoved', 'core/i18n', onHookAddedOrRemoved );\n\t}\n\n\treturn {\n\t\tgetLocaleData,\n\t\tsetLocaleData,\n\t\taddLocaleData,\n\t\tresetLocaleData,\n\t\tsubscribe,\n\t\t__,\n\t\t_x,\n\t\t_n,\n\t\t_nx,\n\t\tisRTL,\n\t\thasTranslation,\n\t};\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/i18n",
3
- "version": "4.3.0",
3
+ "version": "4.3.2-next.a55ed9455a.0",
4
4
  "description": "WordPress internationalization (i18n) library.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@babel/runtime": "^7.16.0",
33
- "@wordpress/hooks": "^3.3.0",
33
+ "@wordpress/hooks": "^3.3.2-next.a55ed9455a.0",
34
34
  "gettext-parser": "^1.3.1",
35
35
  "lodash": "^4.17.21",
36
36
  "memize": "^1.1.0",
@@ -40,5 +40,5 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "d95ccb9366e249133cdb1d7b25c382446b9ee502"
43
+ "gitHead": "c5108185851b824d531bce55991a3589947e8551"
44
44
  }
@@ -262,7 +262,7 @@ export const createI18n = ( initialData, initialDomain, hooks ) => {
262
262
  number
263
263
  ) => {
264
264
  if ( ! tannin.data[ domain ] ) {
265
- // use `doSetLocaleData` to set silently, without notifying listeners
265
+ // Use `doSetLocaleData` to set silently, without notifying listeners.
266
266
  doSetLocaleData( undefined, domain );
267
267
  }
268
268
 
@@ -20,10 +20,10 @@ const frenchLocale = {
20
20
 
21
21
  const localeData = {
22
22
  '': {
23
- // Domain name
23
+ // Domain name.
24
24
  domain: 'test_domain',
25
25
  lang: 'fr',
26
- // Plural form function for language
26
+ // Plural form function for language.
27
27
  plural_forms: 'nplurals=2; plural=(n != 1);',
28
28
  },
29
29
 
@@ -21,24 +21,24 @@ describe( 'i18n updates', () => {
21
21
 
22
22
  i18n.subscribe( doTranslation );
23
23
 
24
- // do translation on empty instance with no translation data
24
+ // Do translation on empty instance with no translation data.
25
25
  doTranslation();
26
26
 
27
- // set translation data
27
+ // Set translation data.
28
28
  i18n.setLocaleData( {
29
29
  original: [ 'translated' ],
30
30
  } );
31
31
 
32
- // add a filter and then remove it
32
+ // Add a filter and then remove it.
33
33
  const filter = ( text ) => '[' + text + ']';
34
34
  hooks.addFilter( 'i18n.gettext', 'test', filter );
35
35
  hooks.removeFilter( 'i18n.gettext', 'test', filter );
36
36
 
37
37
  expect( doneTranslations ).toEqual( [
38
- 'original', // no translations before setLocaleData
39
- 'translated', // after setLocaleData
40
- '[translated]', // after addFilter
41
- 'translated', // after removeFilter
38
+ 'original', // No translations before setLocaleData.
39
+ 'translated', // After setLocaleData.
40
+ '[translated]', // After addFilter.
41
+ 'translated', // After removeFilter.
42
42
  ] );
43
43
  } );
44
44
  } );
@@ -1 +1 @@
1
- {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/tannin/index.d.ts","../hooks/build-types/createaddhook.d.ts","../hooks/build-types/createremovehook.d.ts","../hooks/build-types/createhashook.d.ts","../hooks/build-types/createdoinghook.d.ts","../hooks/build-types/createdidhook.d.ts","../hooks/build-types/createhooks.d.ts","../hooks/build-types/index.d.ts","./src/create-i18n.js","./src/default-i18n.js","../../node_modules/memize/index.d.ts","../../node_modules/@types/sprintf-js/index.d.ts","./src/sprintf.js","./src/index.js"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},"0d1179b6e77f3c31405e0c31f52f13bc4270555bdd3157f0bc855d5e7fe2c4cf","d02ec79cefaf292fae64b3be5a4416e64b4e420a6429fd458fac6e1bb4c7950e","27abed653f600ea0d5c86e94181beb42824e0f3f16337e2f9e7e9e9c2c392edf","d7871e0e653aa7197fee88886db5678bee6d42164c1f36e4bce9421ddfa7ca49","11ed10bdb3bcc99893570507eac8fece4840add97ee1d4f5a7fbf41cbfdea0d4","429fb571d3db07d3eaa2e74d43eb4190ece3e0de832ed564aeeaf08873e598eb","d3060e0810fc0d0dc009e6f086ef413d3c8aeaaf07da25c8d25fd4e181646acf","406d52bf33d618d846aa0d831ee004290567e328edcd4517bbff2937cc977abf","ff4bc5dc257c7b2b8c5a5cd3623f7a5f8b7a07ad260abaae55e39dd044a0faa0","6f6bd86b465d4227fc4f37a7570679781b0877a81ba5fd9ac421176423d6907f","68e39d827a3bd5054e54a433fc90c118941096eb3e9f432b28ea5f88b0fe77b1","937a701de8090ddb1963aff55d3e95866fca72b71c062794beb2a03c846886c8","9914bdc43df748f22e9565b76e7b6a4ff0a4f0b6aaf50dd75aed9ab92242a7ff","d872b31a43d0d81f13ee111873a975df10fcd9c07cfd8698356e4d9a57bc4576"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[52],[46,47,48,49,50,52],[46,47,48,49,50,51],[45,52],[52,53],[53,54,57],[55,56]],"referencedMap":[[46,1],[50,1],[49,1],[48,1],[51,2],[47,1],[52,3],[53,4],[54,5],[58,6],[57,7]],"exportedModulesMap":[[46,1],[50,1],[49,1],[48,1],[51,2],[47,1],[52,3],[53,4],[54,5],[58,6],[57,7]],"semanticDiagnosticsPerFile":[56,55,45,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,46,50,49,48,51,47,52,53,54,58,57]},"version":"4.4.2"}
1
+ {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/tannin/index.d.ts","../hooks/build-types/createAddHook.d.ts","../hooks/build-types/createRemoveHook.d.ts","../hooks/build-types/createHasHook.d.ts","../hooks/build-types/createDoingHook.d.ts","../hooks/build-types/createDidHook.d.ts","../hooks/build-types/createHooks.d.ts","../hooks/build-types/index.d.ts","./src/create-i18n.js","./src/default-i18n.js","../../node_modules/memize/index.d.ts","../../node_modules/@types/sprintf-js/index.d.ts","./src/sprintf.js","./src/index.js"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},"0d1179b6e77f3c31405e0c31f52f13bc4270555bdd3157f0bc855d5e7fe2c4cf","d02ec79cefaf292fae64b3be5a4416e64b4e420a6429fd458fac6e1bb4c7950e","27abed653f600ea0d5c86e94181beb42824e0f3f16337e2f9e7e9e9c2c392edf","d7871e0e653aa7197fee88886db5678bee6d42164c1f36e4bce9421ddfa7ca49","11ed10bdb3bcc99893570507eac8fece4840add97ee1d4f5a7fbf41cbfdea0d4","429fb571d3db07d3eaa2e74d43eb4190ece3e0de832ed564aeeaf08873e598eb","d3060e0810fc0d0dc009e6f086ef413d3c8aeaaf07da25c8d25fd4e181646acf","406d52bf33d618d846aa0d831ee004290567e328edcd4517bbff2937cc977abf","49336a94346f7ca3f51592f6a91bc50f00d77372c2f2a5221256db955fb6cf51","6f6bd86b465d4227fc4f37a7570679781b0877a81ba5fd9ac421176423d6907f","68e39d827a3bd5054e54a433fc90c118941096eb3e9f432b28ea5f88b0fe77b1","937a701de8090ddb1963aff55d3e95866fca72b71c062794beb2a03c846886c8","9914bdc43df748f22e9565b76e7b6a4ff0a4f0b6aaf50dd75aed9ab92242a7ff","d872b31a43d0d81f13ee111873a975df10fcd9c07cfd8698356e4d9a57bc4576"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[52],[46,47,48,49,50,52],[46,47,48,49,50,51],[45,52],[52,53],[53,54,57],[55,56]],"referencedMap":[[46,1],[50,1],[49,1],[48,1],[51,2],[47,1],[52,3],[53,4],[54,5],[58,6],[57,7]],"exportedModulesMap":[[46,1],[50,1],[49,1],[48,1],[51,2],[47,1],[52,3],[53,4],[54,5],[58,6],[57,7]],"semanticDiagnosticsPerFile":[56,55,45,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,46,50,49,48,51,47,52,53,54,58,57]},"version":"4.4.2"}