@wordpress/i18n 4.39.0 → 4.40.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.40.0 (2023-08-16)
6
+
5
7
  ## 4.39.0 (2023-08-10)
6
8
 
7
9
  ## 4.38.0 (2023-07-20)
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createI18n = void 0;
9
-
10
8
  var _tannin = _interopRequireDefault(require("tannin"));
11
-
12
9
  /**
13
10
  * External dependencies
14
11
  */
@@ -29,15 +26,15 @@ const DEFAULT_LOCALE_DATA = {
29
26
  plural_forms(n) {
30
27
  return n === 1 ? 0 : 1;
31
28
  }
32
-
33
29
  }
34
30
  };
31
+
35
32
  /*
36
33
  * Regular expression that matches i18n hooks like `i18n.gettext`, `i18n.ngettext`,
37
34
  * `i18n.gettext_domain` or `i18n.ngettext_with_context` or `i18n.has_translation`.
38
35
  */
39
-
40
36
  const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
37
+
41
38
  /**
42
39
  * @typedef {(domain?: string) => LocaleData} GetLocaleData
43
40
  *
@@ -46,7 +43,6 @@ const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
46
43
  *
47
44
  * @see http://messageformat.github.io/Jed/
48
45
  */
49
-
50
46
  /**
51
47
  * @typedef {(data?: LocaleData, domain?: string) => void} SetLocaleData
52
48
  *
@@ -56,7 +52,6 @@ const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
56
52
  *
57
53
  * @see http://messageformat.github.io/Jed/
58
54
  */
59
-
60
55
  /**
61
56
  * @typedef {(data?: LocaleData, domain?: string) => void} AddLocaleData
62
57
  *
@@ -66,7 +61,6 @@ const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
66
61
  *
67
62
  * @see http://messageformat.github.io/Jed/
68
63
  */
69
-
70
64
  /**
71
65
  * @typedef {(data?: LocaleData, domain?: string) => void} ResetLocaleData
72
66
  *
@@ -75,22 +69,17 @@ const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
75
69
  *
76
70
  * @see http://messageformat.github.io/Jed/
77
71
  */
78
-
79
72
  /** @typedef {() => void} SubscribeCallback */
80
-
81
73
  /** @typedef {() => void} UnsubscribeCallback */
82
-
83
74
  /**
84
75
  * @typedef {(callback: SubscribeCallback) => UnsubscribeCallback} Subscribe
85
76
  *
86
77
  * Subscribes to changes of locale data
87
78
  */
88
-
89
79
  /**
90
80
  * @typedef {(domain?: string) => string} GetFilterDomain
91
81
  * Retrieve the domain to use when calling domain-specific filters.
92
82
  */
93
-
94
83
  /**
95
84
  * @typedef {(text: string, domain?: string) => string} __
96
85
  *
@@ -98,7 +87,6 @@ const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
98
87
  *
99
88
  * @see https://developer.wordpress.org/reference/functions/__/
100
89
  */
101
-
102
90
  /**
103
91
  * @typedef {(text: string, context: string, domain?: string) => string} _x
104
92
  *
@@ -106,7 +94,6 @@ const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
106
94
  *
107
95
  * @see https://developer.wordpress.org/reference/functions/_x/
108
96
  */
109
-
110
97
  /**
111
98
  * @typedef {(single: string, plural: string, number: number, domain?: string) => string} _n
112
99
  *
@@ -115,7 +102,6 @@ const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
115
102
  *
116
103
  * @see https://developer.wordpress.org/reference/functions/_n/
117
104
  */
118
-
119
105
  /**
120
106
  * @typedef {(single: string, plural: string, number: number, context: string, domain?: string) => string} _nx
121
107
  *
@@ -124,7 +110,6 @@ const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
124
110
  *
125
111
  * @see https://developer.wordpress.org/reference/functions/_nx/
126
112
  */
127
-
128
113
  /**
129
114
  * @typedef {() => boolean} IsRtl
130
115
  *
@@ -135,13 +120,11 @@ const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
135
120
  * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,
136
121
  * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).
137
122
  */
138
-
139
123
  /**
140
124
  * @typedef {(single: string, context?: string, domain?: string) => boolean} HasTranslation
141
125
  *
142
126
  * Check if there is a translation for a given string in singular form.
143
127
  */
144
-
145
128
  /** @typedef {import('@wordpress/hooks').Hooks} Hooks */
146
129
 
147
130
  /**
@@ -177,7 +160,6 @@ const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
177
160
  *
178
161
  * @return {I18n} I18n instance.
179
162
  */
180
-
181
163
  const createI18n = (initialData, initialDomain, hooks) => {
182
164
  /**
183
165
  * The underlying instance of Tannin to which exported functions interface.
@@ -186,78 +168,80 @@ const createI18n = (initialData, initialDomain, hooks) => {
186
168
  */
187
169
  const tannin = new _tannin.default({});
188
170
  const listeners = new Set();
189
-
190
171
  const notifyListeners = () => {
191
172
  listeners.forEach(listener => listener());
192
173
  };
174
+
193
175
  /**
194
176
  * Subscribe to changes of locale data.
195
177
  *
196
178
  * @param {SubscribeCallback} callback Subscription callback.
197
179
  * @return {UnsubscribeCallback} Unsubscribe callback.
198
180
  */
199
-
200
-
201
181
  const subscribe = callback => {
202
182
  listeners.add(callback);
203
183
  return () => listeners.delete(callback);
204
184
  };
205
- /** @type {GetLocaleData} */
206
-
207
185
 
186
+ /** @type {GetLocaleData} */
208
187
  const getLocaleData = (domain = 'default') => tannin.data[domain];
188
+
209
189
  /**
210
190
  * @param {LocaleData} [data]
211
191
  * @param {string} [domain]
212
192
  */
213
-
214
-
215
193
  const doSetLocaleData = (data, domain = 'default') => {
216
- tannin.data[domain] = { ...tannin.data[domain],
194
+ tannin.data[domain] = {
195
+ ...tannin.data[domain],
217
196
  ...data
218
- }; // Populate default domain configuration (supported locale date which omits
219
- // a plural forms expression).
197
+ };
220
198
 
221
- tannin.data[domain][''] = { ...DEFAULT_LOCALE_DATA[''],
199
+ // Populate default domain configuration (supported locale date which omits
200
+ // a plural forms expression).
201
+ tannin.data[domain][''] = {
202
+ ...DEFAULT_LOCALE_DATA[''],
222
203
  ...tannin.data[domain]?.['']
223
- }; // Clean up cached plural forms functions cache as it might be updated.
204
+ };
224
205
 
206
+ // Clean up cached plural forms functions cache as it might be updated.
225
207
  delete tannin.pluralForms[domain];
226
208
  };
227
- /** @type {SetLocaleData} */
228
-
229
209
 
210
+ /** @type {SetLocaleData} */
230
211
  const setLocaleData = (data, domain) => {
231
212
  doSetLocaleData(data, domain);
232
213
  notifyListeners();
233
214
  };
234
- /** @type {AddLocaleData} */
235
-
236
215
 
216
+ /** @type {AddLocaleData} */
237
217
  const addLocaleData = (data, domain = 'default') => {
238
- tannin.data[domain] = { ...tannin.data[domain],
218
+ tannin.data[domain] = {
219
+ ...tannin.data[domain],
239
220
  ...data,
240
221
  // Populate default domain configuration (supported locale date which omits
241
222
  // a plural forms expression).
242
- '': { ...DEFAULT_LOCALE_DATA[''],
223
+ '': {
224
+ ...DEFAULT_LOCALE_DATA[''],
243
225
  ...tannin.data[domain]?.[''],
244
226
  ...data?.['']
245
227
  }
246
- }; // Clean up cached plural forms functions cache as it might be updated.
228
+ };
247
229
 
230
+ // Clean up cached plural forms functions cache as it might be updated.
248
231
  delete tannin.pluralForms[domain];
249
232
  notifyListeners();
250
233
  };
251
- /** @type {ResetLocaleData} */
252
-
253
234
 
235
+ /** @type {ResetLocaleData} */
254
236
  const resetLocaleData = (data, domain) => {
255
237
  // Reset all current Tannin locale data.
256
- tannin.data = {}; // Reset cached plural forms functions cache.
238
+ tannin.data = {};
257
239
 
240
+ // Reset cached plural forms functions cache.
258
241
  tannin.pluralForms = {};
259
242
  setLocaleData(data, domain);
260
243
  };
244
+
261
245
  /**
262
246
  * Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not
263
247
  * otherwise previously assigned.
@@ -273,29 +257,24 @@ const createI18n = (initialData, initialDomain, hooks) => {
273
257
  *
274
258
  * @return {string} The translated string.
275
259
  */
276
-
277
-
278
260
  const dcnpgettext = (domain = 'default', context, single, plural, number) => {
279
261
  if (!tannin.data[domain]) {
280
262
  // Use `doSetLocaleData` to set silently, without notifying listeners.
281
263
  doSetLocaleData(undefined, domain);
282
264
  }
283
-
284
265
  return tannin.dcnpgettext(domain, context, single, plural, number);
285
266
  };
286
- /** @type {GetFilterDomain} */
287
-
288
267
 
268
+ /** @type {GetFilterDomain} */
289
269
  const getFilterDomain = (domain = 'default') => domain;
290
- /** @type {__} */
291
-
292
270
 
271
+ /** @type {__} */
293
272
  const __ = (text, domain) => {
294
273
  let translation = dcnpgettext(domain, undefined, text);
295
-
296
274
  if (!hooks) {
297
275
  return translation;
298
276
  }
277
+
299
278
  /**
300
279
  * Filters text with its translation.
301
280
  *
@@ -303,29 +282,20 @@ const createI18n = (initialData, initialDomain, hooks) => {
303
282
  * @param {string} text Text to translate.
304
283
  * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
305
284
  */
306
-
307
-
308
- translation =
309
- /** @type {string} */
310
-
311
- /** @type {*} */
312
- hooks.applyFilters('i18n.gettext', translation, text, domain);
313
- return (
314
- /** @type {string} */
315
-
316
- /** @type {*} */
317
- hooks.applyFilters('i18n.gettext_' + getFilterDomain(domain), translation, text, domain)
285
+ translation = /** @type {string} */
286
+ /** @type {*} */hooks.applyFilters('i18n.gettext', translation, text, domain);
287
+ return (/** @type {string} */
288
+ /** @type {*} */hooks.applyFilters('i18n.gettext_' + getFilterDomain(domain), translation, text, domain)
318
289
  );
319
290
  };
320
- /** @type {_x} */
321
-
322
291
 
292
+ /** @type {_x} */
323
293
  const _x = (text, context, domain) => {
324
294
  let translation = dcnpgettext(domain, context, text);
325
-
326
295
  if (!hooks) {
327
296
  return translation;
328
297
  }
298
+
329
299
  /**
330
300
  * Filters text with its translation based on context information.
331
301
  *
@@ -334,29 +304,20 @@ const createI18n = (initialData, initialDomain, hooks) => {
334
304
  * @param {string} context Context information for the translators.
335
305
  * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
336
306
  */
337
-
338
-
339
- translation =
340
- /** @type {string} */
341
-
342
- /** @type {*} */
343
- hooks.applyFilters('i18n.gettext_with_context', translation, text, context, domain);
344
- return (
345
- /** @type {string} */
346
-
347
- /** @type {*} */
348
- hooks.applyFilters('i18n.gettext_with_context_' + getFilterDomain(domain), translation, text, context, domain)
307
+ translation = /** @type {string} */
308
+ /** @type {*} */hooks.applyFilters('i18n.gettext_with_context', translation, text, context, domain);
309
+ return (/** @type {string} */
310
+ /** @type {*} */hooks.applyFilters('i18n.gettext_with_context_' + getFilterDomain(domain), translation, text, context, domain)
349
311
  );
350
312
  };
351
- /** @type {_n} */
352
-
353
313
 
314
+ /** @type {_n} */
354
315
  const _n = (single, plural, number, domain) => {
355
316
  let translation = dcnpgettext(domain, undefined, single, plural, number);
356
-
357
317
  if (!hooks) {
358
318
  return translation;
359
319
  }
320
+
360
321
  /**
361
322
  * Filters the singular or plural form of a string.
362
323
  *
@@ -366,29 +327,20 @@ const createI18n = (initialData, initialDomain, hooks) => {
366
327
  * @param {string} number The number to compare against to use either the singular or plural form.
367
328
  * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
368
329
  */
369
-
370
-
371
- translation =
372
- /** @type {string} */
373
-
374
- /** @type {*} */
375
- hooks.applyFilters('i18n.ngettext', translation, single, plural, number, domain);
376
- return (
377
- /** @type {string} */
378
-
379
- /** @type {*} */
380
- hooks.applyFilters('i18n.ngettext_' + getFilterDomain(domain), translation, single, plural, number, domain)
330
+ translation = /** @type {string} */
331
+ /** @type {*} */hooks.applyFilters('i18n.ngettext', translation, single, plural, number, domain);
332
+ return (/** @type {string} */
333
+ /** @type {*} */hooks.applyFilters('i18n.ngettext_' + getFilterDomain(domain), translation, single, plural, number, domain)
381
334
  );
382
335
  };
383
- /** @type {_nx} */
384
-
385
336
 
337
+ /** @type {_nx} */
386
338
  const _nx = (single, plural, number, context, domain) => {
387
339
  let translation = dcnpgettext(domain, context, single, plural, number);
388
-
389
340
  if (!hooks) {
390
341
  return translation;
391
342
  }
343
+
392
344
  /**
393
345
  * Filters the singular or plural form of a string with gettext context.
394
346
  *
@@ -399,33 +351,22 @@ const createI18n = (initialData, initialDomain, hooks) => {
399
351
  * @param {string} context Context information for the translators.
400
352
  * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
401
353
  */
402
-
403
-
404
- translation =
405
- /** @type {string} */
406
-
407
- /** @type {*} */
408
- hooks.applyFilters('i18n.ngettext_with_context', translation, single, plural, number, context, domain);
409
- return (
410
- /** @type {string} */
411
-
412
- /** @type {*} */
413
- hooks.applyFilters('i18n.ngettext_with_context_' + getFilterDomain(domain), translation, single, plural, number, context, domain)
354
+ translation = /** @type {string} */
355
+ /** @type {*} */hooks.applyFilters('i18n.ngettext_with_context', translation, single, plural, number, context, domain);
356
+ return (/** @type {string} */
357
+ /** @type {*} */hooks.applyFilters('i18n.ngettext_with_context_' + getFilterDomain(domain), translation, single, plural, number, context, domain)
414
358
  );
415
359
  };
416
- /** @type {IsRtl} */
417
-
418
360
 
361
+ /** @type {IsRtl} */
419
362
  const isRTL = () => {
420
363
  return 'rtl' === _x('ltr', 'text direction');
421
364
  };
422
- /** @type {HasTranslation} */
423
-
424
365
 
366
+ /** @type {HasTranslation} */
425
367
  const hasTranslation = (single, context, domain) => {
426
368
  const key = context ? context + '\u0004' + single : single;
427
369
  let result = !!tannin.data?.[domain !== null && domain !== void 0 ? domain : 'default']?.[key];
428
-
429
370
  if (hooks) {
430
371
  /**
431
372
  * Filters the presence of a translation in the locale data.
@@ -435,25 +376,16 @@ const createI18n = (initialData, initialDomain, hooks) => {
435
376
  * @param {string} context Context information for the translators.
436
377
  * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
437
378
  */
438
- result =
439
- /** @type { boolean } */
440
-
441
- /** @type {*} */
442
- hooks.applyFilters('i18n.has_translation', result, single, context, domain);
443
- result =
444
- /** @type { boolean } */
445
-
446
- /** @type {*} */
447
- hooks.applyFilters('i18n.has_translation_' + getFilterDomain(domain), result, single, context, domain);
379
+ result = /** @type { boolean } */
380
+ /** @type {*} */hooks.applyFilters('i18n.has_translation', result, single, context, domain);
381
+ result = /** @type { boolean } */
382
+ /** @type {*} */hooks.applyFilters('i18n.has_translation_' + getFilterDomain(domain), result, single, context, domain);
448
383
  }
449
-
450
384
  return result;
451
385
  };
452
-
453
386
  if (initialData) {
454
387
  setLocaleData(initialData, initialDomain);
455
388
  }
456
-
457
389
  if (hooks) {
458
390
  /**
459
391
  * @param {string} hookName
@@ -463,11 +395,9 @@ const createI18n = (initialData, initialDomain, hooks) => {
463
395
  notifyListeners();
464
396
  }
465
397
  };
466
-
467
398
  hooks.addAction('hookAdded', 'core/i18n', onHookAddedOrRemoved);
468
399
  hooks.addAction('hookRemoved', 'core/i18n', onHookAddedOrRemoved);
469
400
  }
470
-
471
401
  return {
472
402
  getLocaleData,
473
403
  setLocaleData,
@@ -482,6 +412,5 @@ const createI18n = (initialData, initialDomain, hooks) => {
482
412
  hasTranslation
483
413
  };
484
414
  };
485
-
486
415
  exports.createI18n = createI18n;
487
416
  //# sourceMappingURL=create-i18n.js.map
@@ -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,IAA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AA,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,"names":["_tannin","_interopRequireDefault","require","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","exports"],"sources":["@wordpress/i18n/src/create-i18n.js"],"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"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,mBAAmB,GAAG;EAC3B,EAAE,EAAE;IACH;IACAC,YAAYA,CAAEC,CAAC,EAAG;MACjB,OAAOA,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;IACvB;EACD;AACD,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG,yCAAyC;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;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