@wordpress/i18n 6.4.1-next.f56bd8138.0 → 6.5.1-next.47f435fc9.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/CHANGELOG.md +2 -0
- package/build/create-i18n.js +150 -167
- package/build/create-i18n.js.map +7 -1
- package/build/default-i18n.js +59 -156
- package/build/default-i18n.js.map +7 -1
- package/build/index.js +60 -103
- package/build/index.js.map +7 -1
- package/build/sprintf.js +38 -28
- package/build/sprintf.js.map +7 -1
- package/build/types.js +16 -5
- package/build/types.js.map +7 -1
- package/build-module/create-i18n.js +118 -161
- package/build-module/create-i18n.js.map +7 -1
- package/build-module/default-i18n.js +28 -153
- package/build-module/default-i18n.js.map +7 -1
- package/build-module/index.js +30 -4
- package/build-module/index.js.map +7 -1
- package/build-module/sprintf.js +6 -23
- package/build-module/sprintf.js.map +7 -1
- package/build-module/types.js +1 -2
- package/build-module/types.js.map +7 -1
- package/package.json +11 -4
|
@@ -1,225 +1,182 @@
|
|
|
1
|
-
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import Tannin from 'tannin';
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* WordPress dependencies
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Default locale data to use for Tannin domain when not otherwise provided.
|
|
16
|
-
* Assumes an English plural forms expression.
|
|
17
|
-
*/
|
|
1
|
+
import Tannin from "tannin";
|
|
18
2
|
const DEFAULT_LOCALE_DATA = {
|
|
19
|
-
|
|
3
|
+
"": {
|
|
20
4
|
plural_forms(n) {
|
|
21
5
|
return n === 1 ? 0 : 1;
|
|
22
6
|
}
|
|
23
7
|
}
|
|
24
8
|
};
|
|
25
|
-
|
|
26
|
-
/*
|
|
27
|
-
* Regular expression that matches i18n hooks like `i18n.gettext`, `i18n.ngettext`,
|
|
28
|
-
* `i18n.gettext_domain` or `i18n.ngettext_with_context` or `i18n.has_translation`.
|
|
29
|
-
*/
|
|
30
9
|
const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Create an i18n instance
|
|
34
|
-
*
|
|
35
|
-
* @param [initialData] Locale data configuration.
|
|
36
|
-
* @param [initialDomain] Domain for which configuration applies.
|
|
37
|
-
* @param [hooks] Hooks implementation.
|
|
38
|
-
*
|
|
39
|
-
* @return I18n instance.
|
|
40
|
-
*/
|
|
41
|
-
export const createI18n = (initialData, initialDomain, hooks) => {
|
|
42
|
-
/**
|
|
43
|
-
* The underlying instance of Tannin to which exported functions interface.
|
|
44
|
-
*/
|
|
10
|
+
const createI18n = (initialData, initialDomain, hooks) => {
|
|
45
11
|
const tannin = new Tannin({});
|
|
46
|
-
const listeners = new Set();
|
|
12
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
47
13
|
const notifyListeners = () => {
|
|
48
|
-
listeners.forEach(listener => listener());
|
|
14
|
+
listeners.forEach((listener) => listener());
|
|
49
15
|
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Subscribe to changes of locale data.
|
|
53
|
-
*
|
|
54
|
-
* @param callback Subscription callback.
|
|
55
|
-
* @return Unsubscribe callback.
|
|
56
|
-
*/
|
|
57
|
-
const subscribe = callback => {
|
|
16
|
+
const subscribe = (callback) => {
|
|
58
17
|
listeners.add(callback);
|
|
59
18
|
return () => listeners.delete(callback);
|
|
60
19
|
};
|
|
61
|
-
const getLocaleData = (domain =
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @param [data]
|
|
65
|
-
* @param [domain]
|
|
66
|
-
*/
|
|
67
|
-
const doSetLocaleData = (data, domain = 'default') => {
|
|
20
|
+
const getLocaleData = (domain = "default") => tannin.data[domain];
|
|
21
|
+
const doSetLocaleData = (data, domain = "default") => {
|
|
68
22
|
tannin.data[domain] = {
|
|
69
23
|
...tannin.data[domain],
|
|
70
24
|
...data
|
|
71
25
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
tannin.data[domain][''] = {
|
|
76
|
-
...DEFAULT_LOCALE_DATA[''],
|
|
77
|
-
...tannin.data[domain]?.['']
|
|
26
|
+
tannin.data[domain][""] = {
|
|
27
|
+
...DEFAULT_LOCALE_DATA[""],
|
|
28
|
+
...tannin.data[domain]?.[""]
|
|
78
29
|
};
|
|
79
|
-
|
|
80
|
-
// Clean up cached plural forms functions cache as it might be updated.
|
|
81
30
|
delete tannin.pluralForms[domain];
|
|
82
31
|
};
|
|
83
32
|
const setLocaleData = (data, domain) => {
|
|
84
33
|
doSetLocaleData(data, domain);
|
|
85
34
|
notifyListeners();
|
|
86
35
|
};
|
|
87
|
-
const addLocaleData = (data, domain =
|
|
36
|
+
const addLocaleData = (data, domain = "default") => {
|
|
88
37
|
tannin.data[domain] = {
|
|
89
38
|
...tannin.data[domain],
|
|
90
39
|
...data,
|
|
91
40
|
// Populate default domain configuration (supported locale date which omits
|
|
92
41
|
// a plural forms expression).
|
|
93
|
-
|
|
94
|
-
...DEFAULT_LOCALE_DATA[
|
|
95
|
-
...tannin.data[domain]?.[
|
|
96
|
-
...data?.[
|
|
42
|
+
"": {
|
|
43
|
+
...DEFAULT_LOCALE_DATA[""],
|
|
44
|
+
...tannin.data[domain]?.[""],
|
|
45
|
+
...data?.[""]
|
|
97
46
|
}
|
|
98
47
|
};
|
|
99
|
-
|
|
100
|
-
// Clean up cached plural forms functions cache as it might be updated.
|
|
101
48
|
delete tannin.pluralForms[domain];
|
|
102
49
|
notifyListeners();
|
|
103
50
|
};
|
|
104
51
|
const resetLocaleData = (data, domain) => {
|
|
105
|
-
// Reset all current Tannin locale data.
|
|
106
52
|
tannin.data = {};
|
|
107
|
-
|
|
108
|
-
// Reset cached plural forms functions cache.
|
|
109
53
|
tannin.pluralForms = {};
|
|
110
54
|
setLocaleData(data, domain);
|
|
111
55
|
};
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not
|
|
115
|
-
* otherwise previously assigned.
|
|
116
|
-
*
|
|
117
|
-
* @param domain Domain to retrieve the translated text.
|
|
118
|
-
* @param context Context information for the translators.
|
|
119
|
-
* @param single Text to translate if non-plural. Used as
|
|
120
|
-
* fallback return value on a caught error.
|
|
121
|
-
* @param [plural] The text to be used if the number is
|
|
122
|
-
* plural.
|
|
123
|
-
* @param [number] The number to compare against to use
|
|
124
|
-
* either the singular or plural form.
|
|
125
|
-
*
|
|
126
|
-
* @return The translated string.
|
|
127
|
-
*/
|
|
128
|
-
const dcnpgettext = (domain = 'default', context, single, plural, number) => {
|
|
56
|
+
const dcnpgettext = (domain = "default", context, single, plural, number) => {
|
|
129
57
|
if (!tannin.data[domain]) {
|
|
130
|
-
|
|
131
|
-
doSetLocaleData(undefined, domain);
|
|
58
|
+
doSetLocaleData(void 0, domain);
|
|
132
59
|
}
|
|
133
60
|
return tannin.dcnpgettext(domain, context, single, plural, number);
|
|
134
61
|
};
|
|
135
|
-
const getFilterDomain = domain => domain ||
|
|
62
|
+
const getFilterDomain = (domain) => domain || "default";
|
|
136
63
|
const __ = (text, domain) => {
|
|
137
|
-
let translation = dcnpgettext(domain,
|
|
64
|
+
let translation = dcnpgettext(domain, void 0, text);
|
|
138
65
|
if (!hooks) {
|
|
139
66
|
return translation;
|
|
140
67
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
68
|
+
translation = hooks.applyFilters(
|
|
69
|
+
"i18n.gettext",
|
|
70
|
+
translation,
|
|
71
|
+
text,
|
|
72
|
+
domain
|
|
73
|
+
);
|
|
74
|
+
return hooks.applyFilters(
|
|
75
|
+
"i18n.gettext_" + getFilterDomain(domain),
|
|
76
|
+
translation,
|
|
77
|
+
text,
|
|
78
|
+
domain
|
|
79
|
+
);
|
|
151
80
|
};
|
|
152
81
|
const _x = (text, context, domain) => {
|
|
153
82
|
let translation = dcnpgettext(domain, context, text);
|
|
154
83
|
if (!hooks) {
|
|
155
84
|
return translation;
|
|
156
85
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
86
|
+
translation = hooks.applyFilters(
|
|
87
|
+
"i18n.gettext_with_context",
|
|
88
|
+
translation,
|
|
89
|
+
text,
|
|
90
|
+
context,
|
|
91
|
+
domain
|
|
92
|
+
);
|
|
93
|
+
return hooks.applyFilters(
|
|
94
|
+
"i18n.gettext_with_context_" + getFilterDomain(domain),
|
|
95
|
+
translation,
|
|
96
|
+
text,
|
|
97
|
+
context,
|
|
98
|
+
domain
|
|
99
|
+
);
|
|
168
100
|
};
|
|
169
101
|
const _n = (single, plural, number, domain) => {
|
|
170
|
-
let translation = dcnpgettext(
|
|
102
|
+
let translation = dcnpgettext(
|
|
103
|
+
domain,
|
|
104
|
+
void 0,
|
|
105
|
+
single,
|
|
106
|
+
plural,
|
|
107
|
+
number
|
|
108
|
+
);
|
|
171
109
|
if (!hooks) {
|
|
172
110
|
return translation;
|
|
173
111
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
112
|
+
translation = hooks.applyFilters(
|
|
113
|
+
"i18n.ngettext",
|
|
114
|
+
translation,
|
|
115
|
+
single,
|
|
116
|
+
plural,
|
|
117
|
+
number,
|
|
118
|
+
domain
|
|
119
|
+
);
|
|
120
|
+
return hooks.applyFilters(
|
|
121
|
+
"i18n.ngettext_" + getFilterDomain(domain),
|
|
122
|
+
translation,
|
|
123
|
+
single,
|
|
124
|
+
plural,
|
|
125
|
+
number,
|
|
126
|
+
domain
|
|
127
|
+
);
|
|
186
128
|
};
|
|
187
129
|
const _nx = (single, plural, number, context, domain) => {
|
|
188
|
-
let translation = dcnpgettext(
|
|
130
|
+
let translation = dcnpgettext(
|
|
131
|
+
domain,
|
|
132
|
+
context,
|
|
133
|
+
single,
|
|
134
|
+
plural,
|
|
135
|
+
number
|
|
136
|
+
);
|
|
189
137
|
if (!hooks) {
|
|
190
138
|
return translation;
|
|
191
139
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
140
|
+
translation = hooks.applyFilters(
|
|
141
|
+
"i18n.ngettext_with_context",
|
|
142
|
+
translation,
|
|
143
|
+
single,
|
|
144
|
+
plural,
|
|
145
|
+
number,
|
|
146
|
+
context,
|
|
147
|
+
domain
|
|
148
|
+
);
|
|
149
|
+
return hooks.applyFilters(
|
|
150
|
+
"i18n.ngettext_with_context_" + getFilterDomain(domain),
|
|
151
|
+
translation,
|
|
152
|
+
single,
|
|
153
|
+
plural,
|
|
154
|
+
number,
|
|
155
|
+
context,
|
|
156
|
+
domain
|
|
157
|
+
);
|
|
205
158
|
};
|
|
206
159
|
const isRTL = () => {
|
|
207
|
-
return
|
|
160
|
+
return "rtl" === _x("ltr", "text direction");
|
|
208
161
|
};
|
|
209
162
|
const hasTranslation = (single, context, domain) => {
|
|
210
|
-
const key = context ? context +
|
|
211
|
-
let result = !!tannin.data?.[domain
|
|
163
|
+
const key = context ? context + "" + single : single;
|
|
164
|
+
let result = !!tannin.data?.[domain ?? "default"]?.[key];
|
|
212
165
|
if (hooks) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
166
|
+
result = hooks.applyFilters(
|
|
167
|
+
"i18n.has_translation",
|
|
168
|
+
result,
|
|
169
|
+
single,
|
|
170
|
+
context,
|
|
171
|
+
domain
|
|
172
|
+
);
|
|
173
|
+
result = hooks.applyFilters(
|
|
174
|
+
"i18n.has_translation_" + getFilterDomain(domain),
|
|
175
|
+
result,
|
|
176
|
+
single,
|
|
177
|
+
context,
|
|
178
|
+
domain
|
|
179
|
+
);
|
|
223
180
|
}
|
|
224
181
|
return result;
|
|
225
182
|
};
|
|
@@ -227,16 +184,13 @@ export const createI18n = (initialData, initialDomain, hooks) => {
|
|
|
227
184
|
setLocaleData(initialData, initialDomain);
|
|
228
185
|
}
|
|
229
186
|
if (hooks) {
|
|
230
|
-
|
|
231
|
-
* @param hookName
|
|
232
|
-
*/
|
|
233
|
-
const onHookAddedOrRemoved = hookName => {
|
|
187
|
+
const onHookAddedOrRemoved = (hookName) => {
|
|
234
188
|
if (I18N_HOOK_REGEXP.test(hookName)) {
|
|
235
189
|
notifyListeners();
|
|
236
190
|
}
|
|
237
191
|
};
|
|
238
|
-
hooks.addAction(
|
|
239
|
-
hooks.addAction(
|
|
192
|
+
hooks.addAction("hookAdded", "core/i18n", onHookAddedOrRemoved);
|
|
193
|
+
hooks.addAction("hookRemoved", "core/i18n", onHookAddedOrRemoved);
|
|
240
194
|
}
|
|
241
195
|
return {
|
|
242
196
|
getLocaleData,
|
|
@@ -252,4 +206,7 @@ export const createI18n = (initialData, initialDomain, hooks) => {
|
|
|
252
206
|
hasTranslation
|
|
253
207
|
};
|
|
254
208
|
};
|
|
255
|
-
|
|
209
|
+
export {
|
|
210
|
+
createI18n
|
|
211
|
+
};
|
|
212
|
+
//# sourceMappingURL=create-i18n.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"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"],"sources":["@wordpress/i18n/src/create-i18n.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { TanninLocaleDomain } from 'tannin';\nimport Tannin from 'tannin';\n/**\n * Internal dependencies\n */\nimport type {\n\tgetFilterDomain,\n\tI18n,\n\tLocaleData,\n\tSubscribeCallback,\n\tTranslatableText,\n\tUnsubscribeCallback,\n} from './types';\n/**\n * WordPress dependencies\n */\nimport type { Hooks } from '@wordpress/hooks';\n/**\n * Default locale data to use for Tannin domain when not otherwise provided.\n * Assumes an English plural forms expression.\n */\nconst DEFAULT_LOCALE_DATA: LocaleData = {\n\t'': {\n\t\tplural_forms( n: number ) {\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 * Create an i18n instance\n *\n * @param [initialData] Locale data configuration.\n * @param [initialDomain] Domain for which configuration applies.\n * @param [hooks] Hooks implementation.\n *\n * @return I18n instance.\n */\nexport const createI18n = < TextDomain extends string >(\n\tinitialData?: LocaleData< TextDomain >,\n\tinitialDomain?: TextDomain,\n\thooks?: Hooks\n): I18n< TextDomain > => {\n\t/**\n\t * The underlying instance of Tannin to which exported functions interface.\n\t */\n\tconst tannin = new Tannin( {} );\n\n\tconst listeners = new Set< () => void >();\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 callback Subscription callback.\n\t * @return Unsubscribe callback.\n\t */\n\tconst subscribe = ( callback: SubscribeCallback ): UnsubscribeCallback => {\n\t\tlisteners.add( callback );\n\t\treturn () => listeners.delete( callback );\n\t};\n\n\tconst getLocaleData: I18n< TextDomain >[ 'getLocaleData' ] = (\n\t\tdomain = 'default' as TextDomain\n\t) => tannin.data[ domain ] as LocaleData< TextDomain >;\n\n\t/**\n\t * @param [data]\n\t * @param [domain]\n\t */\n\tconst doSetLocaleData = (\n\t\tdata?: LocaleData,\n\t\tdomain: TextDomain = 'default' as TextDomain\n\t) => {\n\t\ttannin.data[ domain ] = {\n\t\t\t...tannin.data[ domain ],\n\t\t\t...data,\n\t\t} as TanninLocaleDomain;\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\tconst setLocaleData: I18n< TextDomain >[ 'setLocaleData' ] = (\n\t\tdata,\n\t\tdomain\n\t) => {\n\t\tdoSetLocaleData( data, domain );\n\t\tnotifyListeners();\n\t};\n\n\tconst addLocaleData: I18n< TextDomain >[ 'addLocaleData' ] = (\n\t\tdata,\n\t\tdomain = 'default' as TextDomain\n\t) => {\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} as TanninLocaleDomain;\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\tconst resetLocaleData: I18n< TextDomain >[ 'resetLocaleData' ] = (\n\t\tdata,\n\t\tdomain\n\t) => {\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 domain Domain to retrieve the translated text.\n\t * @param context Context information for the translators.\n\t * @param single Text to translate if non-plural. Used as\n\t * fallback return value on a caught error.\n\t * @param [plural] The text to be used if the number is\n\t * plural.\n\t * @param [number] The number to compare against to use\n\t * either the singular or plural form.\n\t *\n\t * @return The translated string.\n\t */\n\tconst dcnpgettext = (\n\t\tdomain = 'default' as TextDomain,\n\t\tcontext: string | void,\n\t\tsingle: string,\n\t\tplural?: string,\n\t\tnumber?: number\n\t): string => {\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\tconst getFilterDomain: getFilterDomain = ( domain ) => domain || 'default';\n\n\tconst __: I18n< TextDomain >[ '__' ] = ( text, domain ) => {\n\t\tlet translation = dcnpgettext( domain, undefined, text );\n\t\tif ( ! hooks ) {\n\t\t\treturn translation as TranslatableText< typeof text >;\n\t\t}\n\n\t\t/**\n\t\t * Filters text with its translation.\n\t\t *\n\t\t * @param translation Translated text.\n\t\t * @param text Text to translate.\n\t\t * @param domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = hooks.applyFilters(\n\t\t\t'i18n.gettext',\n\t\t\ttranslation,\n\t\t\ttext,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof text >;\n\n\t\treturn hooks.applyFilters(\n\t\t\t'i18n.gettext_' + getFilterDomain( domain ),\n\t\t\ttranslation,\n\t\t\ttext,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof text >;\n\t};\n\n\tconst _x: I18n< TextDomain >[ '_x' ] = ( text, context, domain ) => {\n\t\tlet translation = dcnpgettext( domain, context, text );\n\t\tif ( ! hooks ) {\n\t\t\treturn translation as TranslatableText< typeof text >;\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 translation Translated text.\n\t\t * @param text Text to translate.\n\t\t * @param context Context information for the translators.\n\t\t * @param domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = hooks.applyFilters(\n\t\t\t'i18n.gettext_with_context',\n\t\t\ttranslation,\n\t\t\ttext,\n\t\t\tcontext,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof text >;\n\n\t\treturn hooks.applyFilters(\n\t\t\t'i18n.gettext_with_context_' + getFilterDomain( domain ),\n\t\t\ttranslation,\n\t\t\ttext,\n\t\t\tcontext,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof text >;\n\t};\n\n\tconst _n: I18n< TextDomain >[ '_n' ] = (\n\t\tsingle,\n\t\tplural,\n\t\tnumber,\n\t\tdomain\n\t) => {\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 as TranslatableText<\n\t\t\t\ttypeof single | typeof plural\n\t\t\t>;\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 translation Translated text.\n\t\t * @param single The text to be used if the number is singular.\n\t\t * @param plural The text to be used if the number is plural.\n\t\t * @param number The number to compare against to use either the singular or plural form.\n\t\t * @param domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = hooks.applyFilters(\n\t\t\t'i18n.ngettext',\n\t\t\ttranslation,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof single | typeof plural >;\n\n\t\treturn hooks.applyFilters(\n\t\t\t'i18n.ngettext_' + getFilterDomain( domain ),\n\t\t\ttranslation,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof single | typeof plural >;\n\t};\n\n\tconst _nx: I18n< TextDomain >[ '_nx' ] = (\n\t\tsingle,\n\t\tplural,\n\t\tnumber,\n\t\tcontext,\n\t\tdomain\n\t) => {\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 as TranslatableText<\n\t\t\t\ttypeof single | typeof plural\n\t\t\t>;\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 translation Translated text.\n\t\t * @param single The text to be used if the number is singular.\n\t\t * @param plural The text to be used if the number is plural.\n\t\t * @param number The number to compare against to use either the singular or plural form.\n\t\t * @param context Context information for the translators.\n\t\t * @param domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = hooks.applyFilters(\n\t\t\t'i18n.ngettext_with_context',\n\t\t\ttranslation,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber,\n\t\t\tcontext,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof single | typeof plural >;\n\n\t\treturn hooks.applyFilters(\n\t\t\t'i18n.ngettext_with_context_' + getFilterDomain( domain ),\n\t\t\ttranslation,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber,\n\t\t\tcontext,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof single | typeof plural >;\n\t};\n\n\tconst isRTL: I18n< TextDomain >[ 'isRTL' ] = () => {\n\t\treturn 'rtl' === _x( 'ltr', 'text direction' );\n\t};\n\n\tconst hasTranslation: I18n< TextDomain >[ 'hasTranslation' ] = (\n\t\tsingle,\n\t\tcontext,\n\t\tdomain\n\t) => {\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 hasTranslation Whether the translation is present or not..\n\t\t\t * @param single The singular form of the translated text (used as key in locale data)\n\t\t\t * @param context Context information for the translators.\n\t\t\t * @param domain Text domain. Unique identifier for retrieving translated strings.\n\t\t\t */\n\t\t\tresult = hooks.applyFilters(\n\t\t\t\t'i18n.has_translation',\n\t\t\t\tresult,\n\t\t\t\tsingle,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t) as boolean;\n\n\t\t\tresult = hooks.applyFilters(\n\t\t\t\t'i18n.has_translation_' + getFilterDomain( domain ),\n\t\t\t\tresult,\n\t\t\t\tsingle,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t) as boolean;\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 hookName\n\t\t */\n\t\tconst onHookAddedOrRemoved = ( hookName: string ) => {\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":"AAAA;AACA;AACA;;AAEA,OAAOA,MAAM,MAAM,QAAQ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ACFI,EAAE;IACFC,EAAE;IACFC,GAAG;IACHC,KAAK;IACLC;EACD,CAAC;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/create-i18n.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { TanninLocaleDomain } from 'tannin';\nimport Tannin from 'tannin';\n/**\n * Internal dependencies\n */\nimport type {\n\tgetFilterDomain,\n\tI18n,\n\tLocaleData,\n\tSubscribeCallback,\n\tTranslatableText,\n\tUnsubscribeCallback,\n} from './types';\n/**\n * WordPress dependencies\n */\nimport type { Hooks } from '@wordpress/hooks';\n/**\n * Default locale data to use for Tannin domain when not otherwise provided.\n * Assumes an English plural forms expression.\n */\nconst DEFAULT_LOCALE_DATA: LocaleData = {\n\t'': {\n\t\tplural_forms( n: number ) {\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 * Create an i18n instance\n *\n * @param [initialData] Locale data configuration.\n * @param [initialDomain] Domain for which configuration applies.\n * @param [hooks] Hooks implementation.\n *\n * @return I18n instance.\n */\nexport const createI18n = < TextDomain extends string >(\n\tinitialData?: LocaleData< TextDomain >,\n\tinitialDomain?: TextDomain,\n\thooks?: Hooks\n): I18n< TextDomain > => {\n\t/**\n\t * The underlying instance of Tannin to which exported functions interface.\n\t */\n\tconst tannin = new Tannin( {} );\n\n\tconst listeners = new Set< () => void >();\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 callback Subscription callback.\n\t * @return Unsubscribe callback.\n\t */\n\tconst subscribe = ( callback: SubscribeCallback ): UnsubscribeCallback => {\n\t\tlisteners.add( callback );\n\t\treturn () => listeners.delete( callback );\n\t};\n\n\tconst getLocaleData: I18n< TextDomain >[ 'getLocaleData' ] = (\n\t\tdomain = 'default' as TextDomain\n\t) => tannin.data[ domain ] as LocaleData< TextDomain >;\n\n\t/**\n\t * @param [data]\n\t * @param [domain]\n\t */\n\tconst doSetLocaleData = (\n\t\tdata?: LocaleData,\n\t\tdomain: TextDomain = 'default' as TextDomain\n\t) => {\n\t\ttannin.data[ domain ] = {\n\t\t\t...tannin.data[ domain ],\n\t\t\t...data,\n\t\t} as TanninLocaleDomain;\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\tconst setLocaleData: I18n< TextDomain >[ 'setLocaleData' ] = (\n\t\tdata,\n\t\tdomain\n\t) => {\n\t\tdoSetLocaleData( data, domain );\n\t\tnotifyListeners();\n\t};\n\n\tconst addLocaleData: I18n< TextDomain >[ 'addLocaleData' ] = (\n\t\tdata,\n\t\tdomain = 'default' as TextDomain\n\t) => {\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} as TanninLocaleDomain;\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\tconst resetLocaleData: I18n< TextDomain >[ 'resetLocaleData' ] = (\n\t\tdata,\n\t\tdomain\n\t) => {\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 domain Domain to retrieve the translated text.\n\t * @param context Context information for the translators.\n\t * @param single Text to translate if non-plural. Used as\n\t * fallback return value on a caught error.\n\t * @param [plural] The text to be used if the number is\n\t * plural.\n\t * @param [number] The number to compare against to use\n\t * either the singular or plural form.\n\t *\n\t * @return The translated string.\n\t */\n\tconst dcnpgettext = (\n\t\tdomain = 'default' as TextDomain,\n\t\tcontext: string | void,\n\t\tsingle: string,\n\t\tplural?: string,\n\t\tnumber?: number\n\t): string => {\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\tconst getFilterDomain: getFilterDomain = ( domain ) => domain || 'default';\n\n\tconst __: I18n< TextDomain >[ '__' ] = ( text, domain ) => {\n\t\tlet translation = dcnpgettext( domain, undefined, text );\n\t\tif ( ! hooks ) {\n\t\t\treturn translation as TranslatableText< typeof text >;\n\t\t}\n\n\t\t/**\n\t\t * Filters text with its translation.\n\t\t *\n\t\t * @param translation Translated text.\n\t\t * @param text Text to translate.\n\t\t * @param domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = hooks.applyFilters(\n\t\t\t'i18n.gettext',\n\t\t\ttranslation,\n\t\t\ttext,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof text >;\n\n\t\treturn hooks.applyFilters(\n\t\t\t'i18n.gettext_' + getFilterDomain( domain ),\n\t\t\ttranslation,\n\t\t\ttext,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof text >;\n\t};\n\n\tconst _x: I18n< TextDomain >[ '_x' ] = ( text, context, domain ) => {\n\t\tlet translation = dcnpgettext( domain, context, text );\n\t\tif ( ! hooks ) {\n\t\t\treturn translation as TranslatableText< typeof text >;\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 translation Translated text.\n\t\t * @param text Text to translate.\n\t\t * @param context Context information for the translators.\n\t\t * @param domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = hooks.applyFilters(\n\t\t\t'i18n.gettext_with_context',\n\t\t\ttranslation,\n\t\t\ttext,\n\t\t\tcontext,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof text >;\n\n\t\treturn hooks.applyFilters(\n\t\t\t'i18n.gettext_with_context_' + getFilterDomain( domain ),\n\t\t\ttranslation,\n\t\t\ttext,\n\t\t\tcontext,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof text >;\n\t};\n\n\tconst _n: I18n< TextDomain >[ '_n' ] = (\n\t\tsingle,\n\t\tplural,\n\t\tnumber,\n\t\tdomain\n\t) => {\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 as TranslatableText<\n\t\t\t\ttypeof single | typeof plural\n\t\t\t>;\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 translation Translated text.\n\t\t * @param single The text to be used if the number is singular.\n\t\t * @param plural The text to be used if the number is plural.\n\t\t * @param number The number to compare against to use either the singular or plural form.\n\t\t * @param domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = hooks.applyFilters(\n\t\t\t'i18n.ngettext',\n\t\t\ttranslation,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof single | typeof plural >;\n\n\t\treturn hooks.applyFilters(\n\t\t\t'i18n.ngettext_' + getFilterDomain( domain ),\n\t\t\ttranslation,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof single | typeof plural >;\n\t};\n\n\tconst _nx: I18n< TextDomain >[ '_nx' ] = (\n\t\tsingle,\n\t\tplural,\n\t\tnumber,\n\t\tcontext,\n\t\tdomain\n\t) => {\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 as TranslatableText<\n\t\t\t\ttypeof single | typeof plural\n\t\t\t>;\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 translation Translated text.\n\t\t * @param single The text to be used if the number is singular.\n\t\t * @param plural The text to be used if the number is plural.\n\t\t * @param number The number to compare against to use either the singular or plural form.\n\t\t * @param context Context information for the translators.\n\t\t * @param domain Text domain. Unique identifier for retrieving translated strings.\n\t\t */\n\t\ttranslation = hooks.applyFilters(\n\t\t\t'i18n.ngettext_with_context',\n\t\t\ttranslation,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber,\n\t\t\tcontext,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof single | typeof plural >;\n\n\t\treturn hooks.applyFilters(\n\t\t\t'i18n.ngettext_with_context_' + getFilterDomain( domain ),\n\t\t\ttranslation,\n\t\t\tsingle,\n\t\t\tplural,\n\t\t\tnumber,\n\t\t\tcontext,\n\t\t\tdomain\n\t\t) as TranslatableText< typeof single | typeof plural >;\n\t};\n\n\tconst isRTL: I18n< TextDomain >[ 'isRTL' ] = () => {\n\t\treturn 'rtl' === _x( 'ltr', 'text direction' );\n\t};\n\n\tconst hasTranslation: I18n< TextDomain >[ 'hasTranslation' ] = (\n\t\tsingle,\n\t\tcontext,\n\t\tdomain\n\t) => {\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 hasTranslation Whether the translation is present or not..\n\t\t\t * @param single The singular form of the translated text (used as key in locale data)\n\t\t\t * @param context Context information for the translators.\n\t\t\t * @param domain Text domain. Unique identifier for retrieving translated strings.\n\t\t\t */\n\t\t\tresult = hooks.applyFilters(\n\t\t\t\t'i18n.has_translation',\n\t\t\t\tresult,\n\t\t\t\tsingle,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t) as boolean;\n\n\t\t\tresult = hooks.applyFilters(\n\t\t\t\t'i18n.has_translation_' + getFilterDomain( domain ),\n\t\t\t\tresult,\n\t\t\t\tsingle,\n\t\t\t\tcontext,\n\t\t\t\tdomain\n\t\t\t) as boolean;\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 hookName\n\t\t */\n\t\tconst onHookAddedOrRemoved = ( hookName: string ) => {\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"],
|
|
5
|
+
"mappings": "AAIA,OAAO,YAAY;AAoBnB,MAAM,sBAAkC;AAAA,EACvC,IAAI;AAAA,IACH,aAAc,GAAY;AACzB,aAAO,MAAM,IA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EA,UAAM,UAAW,aAAa,aAAa,oBAAqB;AAChE,UAAM,UAAW,eAAe,aAAa,oBAAqB;AAAA,EACnE;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,153 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
export const getLocaleData = i18n.getLocaleData.bind(i18n);
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Merges locale data into the Tannin instance by domain. Accepts data in a
|
|
34
|
-
* Jed-formatted JSON object shape.
|
|
35
|
-
*
|
|
36
|
-
* @see http://messageformat.github.io/Jed/
|
|
37
|
-
*
|
|
38
|
-
* @param {LocaleData } [data] Locale data configuration.
|
|
39
|
-
* @param {string | undefined} [domain] Domain for which configuration applies.
|
|
40
|
-
*/
|
|
41
|
-
export const setLocaleData = i18n.setLocaleData.bind(i18n);
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Resets all current Tannin instance locale data and sets the specified
|
|
45
|
-
* locale data for the domain. Accepts data in a Jed-formatted JSON object shape.
|
|
46
|
-
*
|
|
47
|
-
* @see http://messageformat.github.io/Jed/
|
|
48
|
-
*
|
|
49
|
-
* @param {LocaleData} [data] Locale data configuration.
|
|
50
|
-
* @param {string | undefined} [domain] Domain for which configuration applies.
|
|
51
|
-
*/
|
|
52
|
-
export const resetLocaleData = i18n.resetLocaleData.bind(i18n);
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Subscribes to changes of locale data
|
|
56
|
-
*
|
|
57
|
-
* @param {SubscribeCallback} callback Subscription callback
|
|
58
|
-
* @return {UnsubscribeCallback} Unsubscribe callback
|
|
59
|
-
*/
|
|
60
|
-
export const subscribe = i18n.subscribe.bind(i18n);
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Retrieve the translation of text.
|
|
64
|
-
*
|
|
65
|
-
* @see https://developer.wordpress.org/reference/functions/__/
|
|
66
|
-
*
|
|
67
|
-
* @template {string} Text
|
|
68
|
-
*
|
|
69
|
-
* @param {Text} text Text to translate.
|
|
70
|
-
* @param {string | undefined} domain Domain to retrieve the translated text.
|
|
71
|
-
*
|
|
72
|
-
* @return {TranslatableText<Text>} Translated text.
|
|
73
|
-
*/
|
|
74
|
-
export const __ = i18n.__.bind(i18n);
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Retrieve translated string with gettext context.
|
|
78
|
-
*
|
|
79
|
-
* @see https://developer.wordpress.org/reference/functions/_x/
|
|
80
|
-
*
|
|
81
|
-
* @template {string} Text
|
|
82
|
-
*
|
|
83
|
-
* @param {Text} text Text to translate.
|
|
84
|
-
* @param {string} context Context information for the translators.
|
|
85
|
-
* @param {string | undefined} domain Domain to retrieve the translated text.
|
|
86
|
-
*
|
|
87
|
-
* @return {TranslatableText<Text>} Translated context string without pipe.
|
|
88
|
-
*/
|
|
89
|
-
export const _x = i18n._x.bind(i18n);
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Translates and retrieves the singular or plural form based on the supplied
|
|
93
|
-
* number.
|
|
94
|
-
*
|
|
95
|
-
* @see https://developer.wordpress.org/reference/functions/_n/
|
|
96
|
-
*
|
|
97
|
-
* @template {string} Single
|
|
98
|
-
* @template {string} Plural
|
|
99
|
-
*
|
|
100
|
-
* @param {Single} single The text to be used if the number is singular.
|
|
101
|
-
* @param {Plural} plural The text to be used if the number is plural.
|
|
102
|
-
* @param {number} number The number to compare against to use either the
|
|
103
|
-
* singular or plural form.
|
|
104
|
-
* @param {string | undefined} domain Domain to retrieve the translated text.
|
|
105
|
-
*
|
|
106
|
-
* @return {TranslatableText<Single | Plural>} The translated singular or plural form.
|
|
107
|
-
*/
|
|
108
|
-
export const _n = i18n._n.bind(i18n);
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Translates and retrieves the singular or plural form based on the supplied
|
|
112
|
-
* number, with gettext context.
|
|
113
|
-
*
|
|
114
|
-
* @see https://developer.wordpress.org/reference/functions/_nx/
|
|
115
|
-
*
|
|
116
|
-
* @template {string} Single
|
|
117
|
-
* @template {string} Plural
|
|
118
|
-
* @param {Single} single The text to be used if the number is singular.
|
|
119
|
-
*
|
|
120
|
-
* @param {Single} single The text to be used if the number is singular.
|
|
121
|
-
* @param {Plural} plural The text to be used if the number is plural.
|
|
122
|
-
* @param {number} number The number to compare against to use either the
|
|
123
|
-
* singular or plural form.
|
|
124
|
-
* @param {string} context Context information for the translators.
|
|
125
|
-
* @param {string | undefined} [domain] Domain to retrieve the translated text.
|
|
126
|
-
*
|
|
127
|
-
* @return {TranslatableText<Single | Plural>} The translated singular or plural form.
|
|
128
|
-
*/
|
|
129
|
-
export const _nx = i18n._nx.bind(i18n);
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Check if current locale is RTL.
|
|
133
|
-
*
|
|
134
|
-
* **RTL (Right To Left)** is a locale property indicating that text is written from right to left.
|
|
135
|
-
* For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common
|
|
136
|
-
* language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,
|
|
137
|
-
* including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).
|
|
138
|
-
*
|
|
139
|
-
* @return {boolean} Whether locale is RTL.
|
|
140
|
-
*/
|
|
141
|
-
export const isRTL = i18n.isRTL.bind(i18n);
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Check if there is a translation for a given string (in singular form).
|
|
145
|
-
*
|
|
146
|
-
* @param {string} single Singular form of the string to look up.
|
|
147
|
-
* @param {string} context Context information for the translators.
|
|
148
|
-
* @param {string} domain Domain to retrieve the translated text.
|
|
149
|
-
*
|
|
150
|
-
* @return {boolean} Whether the translation exists or not.
|
|
151
|
-
*/
|
|
152
|
-
export const hasTranslation = i18n.hasTranslation.bind(i18n);
|
|
153
|
-
//# sourceMappingURL=default-i18n.js.map
|
|
1
|
+
import { createI18n } from "./create-i18n";
|
|
2
|
+
import { defaultHooks } from "@wordpress/hooks";
|
|
3
|
+
const i18n = createI18n(void 0, void 0, defaultHooks);
|
|
4
|
+
var default_i18n_default = i18n;
|
|
5
|
+
const getLocaleData = i18n.getLocaleData.bind(i18n);
|
|
6
|
+
const setLocaleData = i18n.setLocaleData.bind(i18n);
|
|
7
|
+
const resetLocaleData = i18n.resetLocaleData.bind(i18n);
|
|
8
|
+
const subscribe = i18n.subscribe.bind(i18n);
|
|
9
|
+
const __ = i18n.__.bind(i18n);
|
|
10
|
+
const _x = i18n._x.bind(i18n);
|
|
11
|
+
const _n = i18n._n.bind(i18n);
|
|
12
|
+
const _nx = i18n._nx.bind(i18n);
|
|
13
|
+
const isRTL = i18n.isRTL.bind(i18n);
|
|
14
|
+
const hasTranslation = i18n.hasTranslation.bind(i18n);
|
|
15
|
+
export {
|
|
16
|
+
__,
|
|
17
|
+
_n,
|
|
18
|
+
_nx,
|
|
19
|
+
_x,
|
|
20
|
+
default_i18n_default as default,
|
|
21
|
+
getLocaleData,
|
|
22
|
+
hasTranslation,
|
|
23
|
+
isRTL,
|
|
24
|
+
resetLocaleData,
|
|
25
|
+
setLocaleData,
|
|
26
|
+
subscribe
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=default-i18n.js.map
|