@asafarim/shared-i18n 0.6.6 → 0.8.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/demo/dist/Icon Dropdown_Limited Languages.png +0 -0
- package/demo/dist/Select Dropdown_Text Only.png +0 -0
- package/demo/dist/assets/favicon-BZYZvBLo.svg +4 -0
- package/demo/dist/assets/index-BdjqKw_N.css +1 -0
- package/demo/dist/assets/index-C1Tq1uEr.js +191 -0
- package/demo/dist/favicon.svg +4 -0
- package/demo/dist/index.html +27 -0
- package/demo/dist/logo.svg +24 -0
- package/demo/node_modules/.bin/browserslist +21 -0
- package/demo/node_modules/.bin/browserslist.CMD +12 -0
- package/demo/node_modules/.bin/browserslist.ps1 +41 -0
- package/demo/node_modules/.bin/tsc +4 -4
- package/demo/node_modules/.bin/tsc.CMD +12 -0
- package/demo/node_modules/.bin/tsc.ps1 +41 -0
- package/demo/node_modules/.bin/tsserver +4 -4
- package/demo/node_modules/.bin/tsserver.CMD +12 -0
- package/demo/node_modules/.bin/tsserver.ps1 +41 -0
- package/demo/node_modules/.bin/vite +4 -4
- package/demo/node_modules/.bin/vite.CMD +12 -0
- package/demo/node_modules/.bin/vite.ps1 +41 -0
- package/demo/node_modules/.vite/deps/@asafarim_country-language-selector.js +848 -0
- package/demo/node_modules/.vite/deps/@asafarim_country-language-selector.js.map +7 -0
- package/demo/node_modules/.vite/deps/_metadata.json +76 -0
- package/demo/node_modules/.vite/deps/chunk-5WRI5ZAA.js +30 -0
- package/demo/node_modules/.vite/deps/chunk-5WRI5ZAA.js.map +7 -0
- package/demo/node_modules/.vite/deps/chunk-B3AHR5EX.js +1004 -0
- package/demo/node_modules/.vite/deps/chunk-B3AHR5EX.js.map +7 -0
- package/demo/node_modules/.vite/deps/chunk-E6BG6WAU.js +292 -0
- package/demo/node_modules/.vite/deps/chunk-E6BG6WAU.js.map +7 -0
- package/demo/node_modules/.vite/deps/chunk-MVARZQEG.js +280 -0
- package/demo/node_modules/.vite/deps/chunk-MVARZQEG.js.map +7 -0
- package/demo/node_modules/.vite/deps/i18next-browser-languagedetector.js +400 -0
- package/demo/node_modules/.vite/deps/i18next-browser-languagedetector.js.map +7 -0
- package/demo/node_modules/.vite/deps/i18next.js +2392 -0
- package/demo/node_modules/.vite/deps/i18next.js.map +7 -0
- package/demo/node_modules/.vite/deps/package.json +3 -0
- package/demo/node_modules/.vite/deps/react-dom.js +6 -0
- package/demo/node_modules/.vite/deps/react-dom.js.map +7 -0
- package/demo/node_modules/.vite/deps/react-dom_client.js +20217 -0
- package/demo/node_modules/.vite/deps/react-dom_client.js.map +7 -0
- package/demo/node_modules/.vite/deps/react-i18next.js +869 -0
- package/demo/node_modules/.vite/deps/react-i18next.js.map +7 -0
- package/demo/node_modules/.vite/deps/react.js +5 -0
- package/demo/node_modules/.vite/deps/react.js.map +7 -0
- package/demo/node_modules/.vite/deps/react_jsx-dev-runtime.js +278 -0
- package/demo/node_modules/.vite/deps/react_jsx-dev-runtime.js.map +7 -0
- package/demo/node_modules/.vite/deps/react_jsx-runtime.js +6 -0
- package/demo/node_modules/.vite/deps/react_jsx-runtime.js.map +7 -0
- package/demo/package.json +27 -24
- package/demo/public/favicon.svg +4 -4
- package/demo/public/logo.svg +24 -24
- package/demo/src/App.tsx +129 -116
- package/demo/src/components/CountryLanguageDemo.tsx +140 -0
- package/demo/src/components/GetStartedSection.tsx +56 -56
- package/demo/src/components/KeyTable.tsx +29 -29
- package/demo/src/components/LanguageBar.tsx +102 -18
- package/demo/src/components/LanguageSwitcherDemo.module.css +114 -113
- package/demo/src/components/LanguageSwitcherDemo.tsx +256 -202
- package/demo/src/components/Logo.tsx +6 -6
- package/demo/src/components/OverviewSection.tsx +43 -43
- package/demo/src/components/Panel.tsx +15 -15
- package/demo/src/components/StatusCard.tsx +109 -109
- package/demo/src/index.css +644 -605
- package/demo/src/locales/de/demo.json +85 -0
- package/demo/src/locales/en/demo.json +85 -85
- package/demo/src/locales/fr/demo.json +85 -85
- package/demo/src/locales/it/demo.json +85 -0
- package/demo/src/locales/nl/demo.json +85 -85
- package/demo/src/main.tsx +29 -24
- package/demo/tsconfig.json +18 -18
- package/demo/tsconfig.node.json +10 -10
- package/demo/tsconfig.tsbuildinfo +1 -1
- package/demo/vite-env.d.ts +7 -7
- package/demo/vite.config.d.ts +2 -2
- package/demo/vite.config.js +10 -10
- package/dist/components/LanguageSwitcher.module.css +303 -303
- package/dist/locales/de/common.json +68 -0
- package/dist/locales/it/common.json +68 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +85 -84
|
@@ -0,0 +1,869 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_react
|
|
3
|
+
} from "./chunk-B3AHR5EX.js";
|
|
4
|
+
import {
|
|
5
|
+
__commonJS,
|
|
6
|
+
__toESM
|
|
7
|
+
} from "./chunk-5WRI5ZAA.js";
|
|
8
|
+
|
|
9
|
+
// ../node_modules/.pnpm/void-elements@3.1.0/node_modules/void-elements/index.js
|
|
10
|
+
var require_void_elements = __commonJS({
|
|
11
|
+
"../node_modules/.pnpm/void-elements@3.1.0/node_modules/void-elements/index.js"(exports, module) {
|
|
12
|
+
module.exports = {
|
|
13
|
+
"area": true,
|
|
14
|
+
"base": true,
|
|
15
|
+
"br": true,
|
|
16
|
+
"col": true,
|
|
17
|
+
"embed": true,
|
|
18
|
+
"hr": true,
|
|
19
|
+
"img": true,
|
|
20
|
+
"input": true,
|
|
21
|
+
"link": true,
|
|
22
|
+
"meta": true,
|
|
23
|
+
"param": true,
|
|
24
|
+
"source": true,
|
|
25
|
+
"track": true,
|
|
26
|
+
"wbr": true
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/Trans.js
|
|
32
|
+
var import_react3 = __toESM(require_react(), 1);
|
|
33
|
+
|
|
34
|
+
// ../node_modules/.pnpm/@babel+runtime@7.28.4/node_modules/@babel/runtime/helpers/esm/extends.js
|
|
35
|
+
function _extends() {
|
|
36
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n2) {
|
|
37
|
+
for (var e2 = 1; e2 < arguments.length; e2++) {
|
|
38
|
+
var t2 = arguments[e2];
|
|
39
|
+
for (var r2 in t2) ({}).hasOwnProperty.call(t2, r2) && (n2[r2] = t2[r2]);
|
|
40
|
+
}
|
|
41
|
+
return n2;
|
|
42
|
+
}, _extends.apply(null, arguments);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/TransWithoutContext.js
|
|
46
|
+
var import_react = __toESM(require_react(), 1);
|
|
47
|
+
|
|
48
|
+
// ../node_modules/.pnpm/html-parse-stringify@3.0.1/node_modules/html-parse-stringify/dist/html-parse-stringify.module.js
|
|
49
|
+
var import_void_elements = __toESM(require_void_elements());
|
|
50
|
+
var t = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
|
|
51
|
+
function n(n2) {
|
|
52
|
+
var r2 = { type: "tag", name: "", voidElement: false, attrs: {}, children: [] }, i2 = n2.match(/<\/?([^\s]+?)[/\s>]/);
|
|
53
|
+
if (i2 && (r2.name = i2[1], (import_void_elements.default[i2[1]] || "/" === n2.charAt(n2.length - 2)) && (r2.voidElement = true), r2.name.startsWith("!--"))) {
|
|
54
|
+
var s2 = n2.indexOf("-->");
|
|
55
|
+
return { type: "comment", comment: -1 !== s2 ? n2.slice(4, s2) : "" };
|
|
56
|
+
}
|
|
57
|
+
for (var a2 = new RegExp(t), c2 = null; null !== (c2 = a2.exec(n2)); ) if (c2[0].trim()) if (c2[1]) {
|
|
58
|
+
var o = c2[1].trim(), l = [o, ""];
|
|
59
|
+
o.indexOf("=") > -1 && (l = o.split("=")), r2.attrs[l[0]] = l[1], a2.lastIndex--;
|
|
60
|
+
} else c2[2] && (r2.attrs[c2[2]] = c2[3].trim().substring(1, c2[3].length - 1));
|
|
61
|
+
return r2;
|
|
62
|
+
}
|
|
63
|
+
var r = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g;
|
|
64
|
+
var i = /^\s*$/;
|
|
65
|
+
var s = /* @__PURE__ */ Object.create(null);
|
|
66
|
+
function a(e2, t2) {
|
|
67
|
+
switch (t2.type) {
|
|
68
|
+
case "text":
|
|
69
|
+
return e2 + t2.content;
|
|
70
|
+
case "tag":
|
|
71
|
+
return e2 += "<" + t2.name + (t2.attrs ? (function(e3) {
|
|
72
|
+
var t3 = [];
|
|
73
|
+
for (var n2 in e3) t3.push(n2 + '="' + e3[n2] + '"');
|
|
74
|
+
return t3.length ? " " + t3.join(" ") : "";
|
|
75
|
+
})(t2.attrs) : "") + (t2.voidElement ? "/>" : ">"), t2.voidElement ? e2 : e2 + t2.children.reduce(a, "") + "</" + t2.name + ">";
|
|
76
|
+
case "comment":
|
|
77
|
+
return e2 + "<!--" + t2.comment + "-->";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
var c = { parse: function(e2, t2) {
|
|
81
|
+
t2 || (t2 = {}), t2.components || (t2.components = s);
|
|
82
|
+
var a2, c2 = [], o = [], l = -1, m = false;
|
|
83
|
+
if (0 !== e2.indexOf("<")) {
|
|
84
|
+
var u = e2.indexOf("<");
|
|
85
|
+
c2.push({ type: "text", content: -1 === u ? e2 : e2.substring(0, u) });
|
|
86
|
+
}
|
|
87
|
+
return e2.replace(r, function(r2, s2) {
|
|
88
|
+
if (m) {
|
|
89
|
+
if (r2 !== "</" + a2.name + ">") return;
|
|
90
|
+
m = false;
|
|
91
|
+
}
|
|
92
|
+
var u2, f = "/" !== r2.charAt(1), h = r2.startsWith("<!--"), p = s2 + r2.length, d = e2.charAt(p);
|
|
93
|
+
if (h) {
|
|
94
|
+
var v = n(r2);
|
|
95
|
+
return l < 0 ? (c2.push(v), c2) : ((u2 = o[l]).children.push(v), c2);
|
|
96
|
+
}
|
|
97
|
+
if (f && (l++, "tag" === (a2 = n(r2)).type && t2.components[a2.name] && (a2.type = "component", m = true), a2.voidElement || m || !d || "<" === d || a2.children.push({ type: "text", content: e2.slice(p, e2.indexOf("<", p)) }), 0 === l && c2.push(a2), (u2 = o[l - 1]) && u2.children.push(a2), o[l] = a2), (!f || a2.voidElement) && (l > -1 && (a2.voidElement || a2.name === r2.slice(2, -1)) && (l--, a2 = -1 === l ? c2 : o[l]), !m && "<" !== d && d)) {
|
|
98
|
+
u2 = -1 === l ? c2 : o[l].children;
|
|
99
|
+
var x = e2.indexOf("<", p), g = e2.slice(p, -1 === x ? void 0 : x);
|
|
100
|
+
i.test(g) && (g = " "), (x > -1 && l + u2.length >= 0 || " " !== g) && u2.push({ type: "text", content: g });
|
|
101
|
+
}
|
|
102
|
+
}), c2;
|
|
103
|
+
}, stringify: function(e2) {
|
|
104
|
+
return e2.reduce(function(e3, t2) {
|
|
105
|
+
return e3 + a("", t2);
|
|
106
|
+
}, "");
|
|
107
|
+
} };
|
|
108
|
+
var html_parse_stringify_module_default = c;
|
|
109
|
+
|
|
110
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/utils.js
|
|
111
|
+
function warn() {
|
|
112
|
+
if (console && console.warn) {
|
|
113
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
114
|
+
args[_key] = arguments[_key];
|
|
115
|
+
}
|
|
116
|
+
if (typeof args[0] === "string") args[0] = `react-i18next:: ${args[0]}`;
|
|
117
|
+
console.warn(...args);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
var alreadyWarned = {};
|
|
121
|
+
function warnOnce() {
|
|
122
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
123
|
+
args[_key2] = arguments[_key2];
|
|
124
|
+
}
|
|
125
|
+
if (typeof args[0] === "string" && alreadyWarned[args[0]]) return;
|
|
126
|
+
if (typeof args[0] === "string") alreadyWarned[args[0]] = /* @__PURE__ */ new Date();
|
|
127
|
+
warn(...args);
|
|
128
|
+
}
|
|
129
|
+
var loadedClb = (i18n, cb) => () => {
|
|
130
|
+
if (i18n.isInitialized) {
|
|
131
|
+
cb();
|
|
132
|
+
} else {
|
|
133
|
+
const initialized = () => {
|
|
134
|
+
setTimeout(() => {
|
|
135
|
+
i18n.off("initialized", initialized);
|
|
136
|
+
}, 0);
|
|
137
|
+
cb();
|
|
138
|
+
};
|
|
139
|
+
i18n.on("initialized", initialized);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
function loadNamespaces(i18n, ns, cb) {
|
|
143
|
+
i18n.loadNamespaces(ns, loadedClb(i18n, cb));
|
|
144
|
+
}
|
|
145
|
+
function loadLanguages(i18n, lng, ns, cb) {
|
|
146
|
+
if (typeof ns === "string") ns = [ns];
|
|
147
|
+
ns.forEach((n2) => {
|
|
148
|
+
if (i18n.options.ns.indexOf(n2) < 0) i18n.options.ns.push(n2);
|
|
149
|
+
});
|
|
150
|
+
i18n.loadLanguages(lng, loadedClb(i18n, cb));
|
|
151
|
+
}
|
|
152
|
+
function oldI18nextHasLoadedNamespace(ns, i18n) {
|
|
153
|
+
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
154
|
+
const lng = i18n.languages[0];
|
|
155
|
+
const fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
|
|
156
|
+
const lastLng = i18n.languages[i18n.languages.length - 1];
|
|
157
|
+
if (lng.toLowerCase() === "cimode") return true;
|
|
158
|
+
const loadNotPending = (l, n2) => {
|
|
159
|
+
const loadState = i18n.services.backendConnector.state[`${l}|${n2}`];
|
|
160
|
+
return loadState === -1 || loadState === 2;
|
|
161
|
+
};
|
|
162
|
+
if (options.bindI18n && options.bindI18n.indexOf("languageChanging") > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
|
|
163
|
+
if (i18n.hasResourceBundle(lng, ns)) return true;
|
|
164
|
+
if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
|
|
165
|
+
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
function hasLoadedNamespace(ns, i18n) {
|
|
169
|
+
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
170
|
+
if (!i18n.languages || !i18n.languages.length) {
|
|
171
|
+
warnOnce("i18n.languages were undefined or empty", i18n.languages);
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
const isNewerI18next = i18n.options.ignoreJSONStructure !== void 0;
|
|
175
|
+
if (!isNewerI18next) {
|
|
176
|
+
return oldI18nextHasLoadedNamespace(ns, i18n, options);
|
|
177
|
+
}
|
|
178
|
+
return i18n.hasLoadedNamespace(ns, {
|
|
179
|
+
lng: options.lng,
|
|
180
|
+
precheck: (i18nInstance2, loadNotPending) => {
|
|
181
|
+
if (options.bindI18n && options.bindI18n.indexOf("languageChanging") > -1 && i18nInstance2.services.backendConnector.backend && i18nInstance2.isLanguageChangingTo && !loadNotPending(i18nInstance2.isLanguageChangingTo, ns)) return false;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function getDisplayName(Component) {
|
|
186
|
+
return Component.displayName || Component.name || (typeof Component === "string" && Component.length > 0 ? Component : "Unknown");
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/unescape.js
|
|
190
|
+
var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
|
|
191
|
+
var htmlEntities = {
|
|
192
|
+
"&": "&",
|
|
193
|
+
"&": "&",
|
|
194
|
+
"<": "<",
|
|
195
|
+
"<": "<",
|
|
196
|
+
">": ">",
|
|
197
|
+
">": ">",
|
|
198
|
+
"'": "'",
|
|
199
|
+
"'": "'",
|
|
200
|
+
""": '"',
|
|
201
|
+
""": '"',
|
|
202
|
+
" ": " ",
|
|
203
|
+
" ": " ",
|
|
204
|
+
"©": "©",
|
|
205
|
+
"©": "©",
|
|
206
|
+
"®": "®",
|
|
207
|
+
"®": "®",
|
|
208
|
+
"…": "…",
|
|
209
|
+
"…": "…",
|
|
210
|
+
"/": "/",
|
|
211
|
+
"/": "/"
|
|
212
|
+
};
|
|
213
|
+
var unescapeHtmlEntity = (m) => htmlEntities[m];
|
|
214
|
+
var unescape = (text) => text.replace(matchHtmlEntity, unescapeHtmlEntity);
|
|
215
|
+
|
|
216
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/defaults.js
|
|
217
|
+
var defaultOptions = {
|
|
218
|
+
bindI18n: "languageChanged",
|
|
219
|
+
bindI18nStore: "",
|
|
220
|
+
transEmptyNodeValue: "",
|
|
221
|
+
transSupportBasicHtmlNodes: true,
|
|
222
|
+
transWrapTextNodes: "",
|
|
223
|
+
transKeepBasicHtmlNodesFor: ["br", "strong", "i", "p"],
|
|
224
|
+
useSuspense: true,
|
|
225
|
+
unescape
|
|
226
|
+
};
|
|
227
|
+
function setDefaults() {
|
|
228
|
+
let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
229
|
+
defaultOptions = {
|
|
230
|
+
...defaultOptions,
|
|
231
|
+
...options
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function getDefaults() {
|
|
235
|
+
return defaultOptions;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/i18nInstance.js
|
|
239
|
+
var i18nInstance;
|
|
240
|
+
function setI18n(instance) {
|
|
241
|
+
i18nInstance = instance;
|
|
242
|
+
}
|
|
243
|
+
function getI18n() {
|
|
244
|
+
return i18nInstance;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/TransWithoutContext.js
|
|
248
|
+
function hasChildren(node, checkLength) {
|
|
249
|
+
if (!node) return false;
|
|
250
|
+
const base = node.props ? node.props.children : node.children;
|
|
251
|
+
if (checkLength) return base.length > 0;
|
|
252
|
+
return !!base;
|
|
253
|
+
}
|
|
254
|
+
function getChildren(node) {
|
|
255
|
+
if (!node) return [];
|
|
256
|
+
const children = node.props ? node.props.children : node.children;
|
|
257
|
+
return node.props && node.props.i18nIsDynamicList ? getAsArray(children) : children;
|
|
258
|
+
}
|
|
259
|
+
function hasValidReactChildren(children) {
|
|
260
|
+
if (Object.prototype.toString.call(children) !== "[object Array]") return false;
|
|
261
|
+
return children.every((child) => (0, import_react.isValidElement)(child));
|
|
262
|
+
}
|
|
263
|
+
function getAsArray(data) {
|
|
264
|
+
return Array.isArray(data) ? data : [data];
|
|
265
|
+
}
|
|
266
|
+
function mergeProps(source, target) {
|
|
267
|
+
const newTarget = {
|
|
268
|
+
...target
|
|
269
|
+
};
|
|
270
|
+
newTarget.props = Object.assign(source.props, target.props);
|
|
271
|
+
return newTarget;
|
|
272
|
+
}
|
|
273
|
+
function nodesToString(children, i18nOptions) {
|
|
274
|
+
if (!children) return "";
|
|
275
|
+
let stringNode = "";
|
|
276
|
+
const childrenArray = getAsArray(children);
|
|
277
|
+
const keepArray = i18nOptions.transSupportBasicHtmlNodes && i18nOptions.transKeepBasicHtmlNodesFor ? i18nOptions.transKeepBasicHtmlNodesFor : [];
|
|
278
|
+
childrenArray.forEach((child, childIndex) => {
|
|
279
|
+
if (typeof child === "string") {
|
|
280
|
+
stringNode += `${child}`;
|
|
281
|
+
} else if ((0, import_react.isValidElement)(child)) {
|
|
282
|
+
const childPropsCount = Object.keys(child.props).length;
|
|
283
|
+
const shouldKeepChild = keepArray.indexOf(child.type) > -1;
|
|
284
|
+
const childChildren = child.props.children;
|
|
285
|
+
if (!childChildren && shouldKeepChild && childPropsCount === 0) {
|
|
286
|
+
stringNode += `<${child.type}/>`;
|
|
287
|
+
} else if (!childChildren && (!shouldKeepChild || childPropsCount !== 0)) {
|
|
288
|
+
stringNode += `<${childIndex}></${childIndex}>`;
|
|
289
|
+
} else if (child.props.i18nIsDynamicList) {
|
|
290
|
+
stringNode += `<${childIndex}></${childIndex}>`;
|
|
291
|
+
} else if (shouldKeepChild && childPropsCount === 1 && typeof childChildren === "string") {
|
|
292
|
+
stringNode += `<${child.type}>${childChildren}</${child.type}>`;
|
|
293
|
+
} else {
|
|
294
|
+
const content = nodesToString(childChildren, i18nOptions);
|
|
295
|
+
stringNode += `<${childIndex}>${content}</${childIndex}>`;
|
|
296
|
+
}
|
|
297
|
+
} else if (child === null) {
|
|
298
|
+
warn(`Trans: the passed in value is invalid - seems you passed in a null child.`);
|
|
299
|
+
} else if (typeof child === "object") {
|
|
300
|
+
const {
|
|
301
|
+
format,
|
|
302
|
+
...clone
|
|
303
|
+
} = child;
|
|
304
|
+
const keys = Object.keys(clone);
|
|
305
|
+
if (keys.length === 1) {
|
|
306
|
+
const value = format ? `${keys[0]}, ${format}` : keys[0];
|
|
307
|
+
stringNode += `{{${value}}}`;
|
|
308
|
+
} else {
|
|
309
|
+
warn(`react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.`, child);
|
|
310
|
+
}
|
|
311
|
+
} else {
|
|
312
|
+
warn(`Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.`, child);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
return stringNode;
|
|
316
|
+
}
|
|
317
|
+
function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) {
|
|
318
|
+
if (targetString === "") return [];
|
|
319
|
+
const keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
|
|
320
|
+
const emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.map((keep) => `<${keep}`).join("|")).test(targetString);
|
|
321
|
+
if (!children && !emptyChildrenButNeedsHandling && !shouldUnescape) return [targetString];
|
|
322
|
+
const data = {};
|
|
323
|
+
function getData(childs) {
|
|
324
|
+
const childrenArray = getAsArray(childs);
|
|
325
|
+
childrenArray.forEach((child) => {
|
|
326
|
+
if (typeof child === "string") return;
|
|
327
|
+
if (hasChildren(child)) getData(getChildren(child));
|
|
328
|
+
else if (typeof child === "object" && !(0, import_react.isValidElement)(child)) Object.assign(data, child);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
getData(children);
|
|
332
|
+
const ast = html_parse_stringify_module_default.parse(`<0>${targetString}</0>`);
|
|
333
|
+
const opts = {
|
|
334
|
+
...data,
|
|
335
|
+
...combinedTOpts
|
|
336
|
+
};
|
|
337
|
+
function renderInner(child, node, rootReactNode) {
|
|
338
|
+
const childs = getChildren(child);
|
|
339
|
+
const mappedChildren = mapAST(childs, node.children, rootReactNode);
|
|
340
|
+
return hasValidReactChildren(childs) && mappedChildren.length === 0 || child.props && child.props.i18nIsDynamicList ? childs : mappedChildren;
|
|
341
|
+
}
|
|
342
|
+
function pushTranslatedJSX(child, inner, mem, i2, isVoid) {
|
|
343
|
+
if (child.dummy) {
|
|
344
|
+
child.children = inner;
|
|
345
|
+
mem.push((0, import_react.cloneElement)(child, {
|
|
346
|
+
key: i2
|
|
347
|
+
}, isVoid ? void 0 : inner));
|
|
348
|
+
} else {
|
|
349
|
+
mem.push(...import_react.Children.map([child], (c2) => {
|
|
350
|
+
const props = {
|
|
351
|
+
...c2.props
|
|
352
|
+
};
|
|
353
|
+
delete props.i18nIsDynamicList;
|
|
354
|
+
return import_react.default.createElement(c2.type, _extends({}, props, {
|
|
355
|
+
key: i2,
|
|
356
|
+
ref: c2.ref
|
|
357
|
+
}, isVoid ? {} : {
|
|
358
|
+
children: inner
|
|
359
|
+
}));
|
|
360
|
+
}));
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
function mapAST(reactNode, astNode, rootReactNode) {
|
|
364
|
+
const reactNodes = getAsArray(reactNode);
|
|
365
|
+
const astNodes = getAsArray(astNode);
|
|
366
|
+
return astNodes.reduce((mem, node, i2) => {
|
|
367
|
+
const translationContent = node.children && node.children[0] && node.children[0].content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
|
|
368
|
+
if (node.type === "tag") {
|
|
369
|
+
let tmp = reactNodes[parseInt(node.name, 10)];
|
|
370
|
+
if (rootReactNode.length === 1 && !tmp) tmp = rootReactNode[0][node.name];
|
|
371
|
+
if (!tmp) tmp = {};
|
|
372
|
+
const child = Object.keys(node.attrs).length !== 0 ? mergeProps({
|
|
373
|
+
props: node.attrs
|
|
374
|
+
}, tmp) : tmp;
|
|
375
|
+
const isElement = (0, import_react.isValidElement)(child);
|
|
376
|
+
const isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement;
|
|
377
|
+
const isEmptyTransWithHTML = emptyChildrenButNeedsHandling && typeof child === "object" && child.dummy && !isElement;
|
|
378
|
+
const isKnownComponent = typeof children === "object" && children !== null && Object.hasOwnProperty.call(children, node.name);
|
|
379
|
+
if (typeof child === "string") {
|
|
380
|
+
const value = i18n.services.interpolator.interpolate(child, opts, i18n.language);
|
|
381
|
+
mem.push(value);
|
|
382
|
+
} else if (hasChildren(child) || isValidTranslationWithChildren) {
|
|
383
|
+
const inner = renderInner(child, node, rootReactNode);
|
|
384
|
+
pushTranslatedJSX(child, inner, mem, i2);
|
|
385
|
+
} else if (isEmptyTransWithHTML) {
|
|
386
|
+
const inner = mapAST(reactNodes, node.children, rootReactNode);
|
|
387
|
+
pushTranslatedJSX(child, inner, mem, i2);
|
|
388
|
+
} else if (Number.isNaN(parseFloat(node.name))) {
|
|
389
|
+
if (isKnownComponent) {
|
|
390
|
+
const inner = renderInner(child, node, rootReactNode);
|
|
391
|
+
pushTranslatedJSX(child, inner, mem, i2, node.voidElement);
|
|
392
|
+
} else if (i18nOptions.transSupportBasicHtmlNodes && keepArray.indexOf(node.name) > -1) {
|
|
393
|
+
if (node.voidElement) {
|
|
394
|
+
mem.push((0, import_react.createElement)(node.name, {
|
|
395
|
+
key: `${node.name}-${i2}`
|
|
396
|
+
}));
|
|
397
|
+
} else {
|
|
398
|
+
const inner = mapAST(reactNodes, node.children, rootReactNode);
|
|
399
|
+
mem.push((0, import_react.createElement)(node.name, {
|
|
400
|
+
key: `${node.name}-${i2}`
|
|
401
|
+
}, inner));
|
|
402
|
+
}
|
|
403
|
+
} else if (node.voidElement) {
|
|
404
|
+
mem.push(`<${node.name} />`);
|
|
405
|
+
} else {
|
|
406
|
+
const inner = mapAST(reactNodes, node.children, rootReactNode);
|
|
407
|
+
mem.push(`<${node.name}>${inner}</${node.name}>`);
|
|
408
|
+
}
|
|
409
|
+
} else if (typeof child === "object" && !isElement) {
|
|
410
|
+
const content = node.children[0] ? translationContent : null;
|
|
411
|
+
if (content) mem.push(content);
|
|
412
|
+
} else {
|
|
413
|
+
pushTranslatedJSX(child, translationContent, mem, i2, node.children.length !== 1 || !translationContent);
|
|
414
|
+
}
|
|
415
|
+
} else if (node.type === "text") {
|
|
416
|
+
const wrapTextNodes = i18nOptions.transWrapTextNodes;
|
|
417
|
+
const content = shouldUnescape ? i18nOptions.unescape(i18n.services.interpolator.interpolate(node.content, opts, i18n.language)) : i18n.services.interpolator.interpolate(node.content, opts, i18n.language);
|
|
418
|
+
if (wrapTextNodes) {
|
|
419
|
+
mem.push((0, import_react.createElement)(wrapTextNodes, {
|
|
420
|
+
key: `${node.name}-${i2}`
|
|
421
|
+
}, content));
|
|
422
|
+
} else {
|
|
423
|
+
mem.push(content);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return mem;
|
|
427
|
+
}, []);
|
|
428
|
+
}
|
|
429
|
+
const result = mapAST([{
|
|
430
|
+
dummy: true,
|
|
431
|
+
children: children || []
|
|
432
|
+
}], ast, getAsArray(children || []));
|
|
433
|
+
return getChildren(result[0]);
|
|
434
|
+
}
|
|
435
|
+
function Trans(_ref) {
|
|
436
|
+
let {
|
|
437
|
+
children,
|
|
438
|
+
count,
|
|
439
|
+
parent,
|
|
440
|
+
i18nKey,
|
|
441
|
+
context,
|
|
442
|
+
tOptions = {},
|
|
443
|
+
values,
|
|
444
|
+
defaults,
|
|
445
|
+
components,
|
|
446
|
+
ns,
|
|
447
|
+
i18n: i18nFromProps,
|
|
448
|
+
t: tFromProps,
|
|
449
|
+
shouldUnescape,
|
|
450
|
+
...additionalProps
|
|
451
|
+
} = _ref;
|
|
452
|
+
const i18n = i18nFromProps || getI18n();
|
|
453
|
+
if (!i18n) {
|
|
454
|
+
warnOnce("You will need to pass in an i18next instance by using i18nextReactModule");
|
|
455
|
+
return children;
|
|
456
|
+
}
|
|
457
|
+
const t2 = tFromProps || i18n.t.bind(i18n) || ((k) => k);
|
|
458
|
+
if (context) tOptions.context = context;
|
|
459
|
+
const reactI18nextOptions = {
|
|
460
|
+
...getDefaults(),
|
|
461
|
+
...i18n.options && i18n.options.react
|
|
462
|
+
};
|
|
463
|
+
let namespaces = ns || t2.ns || i18n.options && i18n.options.defaultNS;
|
|
464
|
+
namespaces = typeof namespaces === "string" ? [namespaces] : namespaces || ["translation"];
|
|
465
|
+
const nodeAsString = nodesToString(children, reactI18nextOptions);
|
|
466
|
+
const defaultValue = defaults || nodeAsString || reactI18nextOptions.transEmptyNodeValue || i18nKey;
|
|
467
|
+
const {
|
|
468
|
+
hashTransKey
|
|
469
|
+
} = reactI18nextOptions;
|
|
470
|
+
const key = i18nKey || (hashTransKey ? hashTransKey(nodeAsString || defaultValue) : nodeAsString || defaultValue);
|
|
471
|
+
if (i18n.options && i18n.options.interpolation && i18n.options.interpolation.defaultVariables) {
|
|
472
|
+
values = values && Object.keys(values).length > 0 ? {
|
|
473
|
+
...values,
|
|
474
|
+
...i18n.options.interpolation.defaultVariables
|
|
475
|
+
} : {
|
|
476
|
+
...i18n.options.interpolation.defaultVariables
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
const interpolationOverride = values ? tOptions.interpolation : {
|
|
480
|
+
interpolation: {
|
|
481
|
+
...tOptions.interpolation,
|
|
482
|
+
prefix: "#$?",
|
|
483
|
+
suffix: "?$#"
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
const combinedTOpts = {
|
|
487
|
+
...tOptions,
|
|
488
|
+
count,
|
|
489
|
+
...values,
|
|
490
|
+
...interpolationOverride,
|
|
491
|
+
defaultValue,
|
|
492
|
+
ns: namespaces
|
|
493
|
+
};
|
|
494
|
+
const translation = key ? t2(key, combinedTOpts) : defaultValue;
|
|
495
|
+
if (components) {
|
|
496
|
+
Object.keys(components).forEach((c2) => {
|
|
497
|
+
const comp = components[c2];
|
|
498
|
+
if (typeof comp.type === "function" || !comp.props || !comp.props.children || translation.indexOf(`${c2}/>`) < 0 && translation.indexOf(`${c2} />`) < 0) return;
|
|
499
|
+
function Componentized() {
|
|
500
|
+
return import_react.default.createElement(import_react.default.Fragment, null, comp);
|
|
501
|
+
}
|
|
502
|
+
components[c2] = import_react.default.createElement(Componentized, null);
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
const content = renderNodes(components || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
|
|
506
|
+
const useAsParent = parent !== void 0 ? parent : reactI18nextOptions.defaultTransParent;
|
|
507
|
+
return useAsParent ? (0, import_react.createElement)(useAsParent, additionalProps, content) : content;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/context.js
|
|
511
|
+
var import_react2 = __toESM(require_react(), 1);
|
|
512
|
+
|
|
513
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/initReactI18next.js
|
|
514
|
+
var initReactI18next = {
|
|
515
|
+
type: "3rdParty",
|
|
516
|
+
init(instance) {
|
|
517
|
+
setDefaults(instance.options.react);
|
|
518
|
+
setI18n(instance);
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/context.js
|
|
523
|
+
var I18nContext = (0, import_react2.createContext)();
|
|
524
|
+
var ReportNamespaces = class {
|
|
525
|
+
constructor() {
|
|
526
|
+
this.usedNamespaces = {};
|
|
527
|
+
}
|
|
528
|
+
addUsedNamespaces(namespaces) {
|
|
529
|
+
namespaces.forEach((ns) => {
|
|
530
|
+
if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
getUsedNamespaces() {
|
|
534
|
+
return Object.keys(this.usedNamespaces);
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
function composeInitialProps(ForComponent) {
|
|
538
|
+
return (ctx) => new Promise((resolve) => {
|
|
539
|
+
const i18nInitialProps = getInitialProps();
|
|
540
|
+
if (ForComponent.getInitialProps) {
|
|
541
|
+
ForComponent.getInitialProps(ctx).then((componentsInitialProps) => {
|
|
542
|
+
resolve({
|
|
543
|
+
...componentsInitialProps,
|
|
544
|
+
...i18nInitialProps
|
|
545
|
+
});
|
|
546
|
+
});
|
|
547
|
+
} else {
|
|
548
|
+
resolve(i18nInitialProps);
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
function getInitialProps() {
|
|
553
|
+
const i18n = getI18n();
|
|
554
|
+
const namespaces = i18n.reportNamespaces ? i18n.reportNamespaces.getUsedNamespaces() : [];
|
|
555
|
+
const ret = {};
|
|
556
|
+
const initialI18nStore = {};
|
|
557
|
+
i18n.languages.forEach((l) => {
|
|
558
|
+
initialI18nStore[l] = {};
|
|
559
|
+
namespaces.forEach((ns) => {
|
|
560
|
+
initialI18nStore[l][ns] = i18n.getResourceBundle(l, ns) || {};
|
|
561
|
+
});
|
|
562
|
+
});
|
|
563
|
+
ret.initialI18nStore = initialI18nStore;
|
|
564
|
+
ret.initialLanguage = i18n.language;
|
|
565
|
+
return ret;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/Trans.js
|
|
569
|
+
function Trans2(_ref) {
|
|
570
|
+
let {
|
|
571
|
+
children,
|
|
572
|
+
count,
|
|
573
|
+
parent,
|
|
574
|
+
i18nKey,
|
|
575
|
+
context,
|
|
576
|
+
tOptions = {},
|
|
577
|
+
values,
|
|
578
|
+
defaults,
|
|
579
|
+
components,
|
|
580
|
+
ns,
|
|
581
|
+
i18n: i18nFromProps,
|
|
582
|
+
t: tFromProps,
|
|
583
|
+
shouldUnescape,
|
|
584
|
+
...additionalProps
|
|
585
|
+
} = _ref;
|
|
586
|
+
const {
|
|
587
|
+
i18n: i18nFromContext,
|
|
588
|
+
defaultNS: defaultNSFromContext
|
|
589
|
+
} = (0, import_react3.useContext)(I18nContext) || {};
|
|
590
|
+
const i18n = i18nFromProps || i18nFromContext || getI18n();
|
|
591
|
+
const t2 = tFromProps || i18n && i18n.t.bind(i18n);
|
|
592
|
+
return Trans({
|
|
593
|
+
children,
|
|
594
|
+
count,
|
|
595
|
+
parent,
|
|
596
|
+
i18nKey,
|
|
597
|
+
context,
|
|
598
|
+
tOptions,
|
|
599
|
+
values,
|
|
600
|
+
defaults,
|
|
601
|
+
components,
|
|
602
|
+
ns: ns || t2 && t2.ns || defaultNSFromContext || i18n && i18n.options && i18n.options.defaultNS,
|
|
603
|
+
i18n,
|
|
604
|
+
t: tFromProps,
|
|
605
|
+
shouldUnescape,
|
|
606
|
+
...additionalProps
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/useTranslation.js
|
|
611
|
+
var import_react4 = __toESM(require_react(), 1);
|
|
612
|
+
var usePrevious = (value, ignore) => {
|
|
613
|
+
const ref = (0, import_react4.useRef)();
|
|
614
|
+
(0, import_react4.useEffect)(() => {
|
|
615
|
+
ref.current = ignore ? ref.current : value;
|
|
616
|
+
}, [value, ignore]);
|
|
617
|
+
return ref.current;
|
|
618
|
+
};
|
|
619
|
+
function useTranslation(ns) {
|
|
620
|
+
let props = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
621
|
+
const {
|
|
622
|
+
i18n: i18nFromProps
|
|
623
|
+
} = props;
|
|
624
|
+
const {
|
|
625
|
+
i18n: i18nFromContext,
|
|
626
|
+
defaultNS: defaultNSFromContext
|
|
627
|
+
} = (0, import_react4.useContext)(I18nContext) || {};
|
|
628
|
+
const i18n = i18nFromProps || i18nFromContext || getI18n();
|
|
629
|
+
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
|
|
630
|
+
if (!i18n) {
|
|
631
|
+
warnOnce("You will need to pass in an i18next instance by using initReactI18next");
|
|
632
|
+
const notReadyT = (k, optsOrDefaultValue) => {
|
|
633
|
+
if (typeof optsOrDefaultValue === "string") return optsOrDefaultValue;
|
|
634
|
+
if (optsOrDefaultValue && typeof optsOrDefaultValue === "object" && typeof optsOrDefaultValue.defaultValue === "string") return optsOrDefaultValue.defaultValue;
|
|
635
|
+
return Array.isArray(k) ? k[k.length - 1] : k;
|
|
636
|
+
};
|
|
637
|
+
const retNotReady = [notReadyT, {}, false];
|
|
638
|
+
retNotReady.t = notReadyT;
|
|
639
|
+
retNotReady.i18n = {};
|
|
640
|
+
retNotReady.ready = false;
|
|
641
|
+
return retNotReady;
|
|
642
|
+
}
|
|
643
|
+
if (i18n.options.react && i18n.options.react.wait !== void 0) warnOnce("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
|
|
644
|
+
const i18nOptions = {
|
|
645
|
+
...getDefaults(),
|
|
646
|
+
...i18n.options.react,
|
|
647
|
+
...props
|
|
648
|
+
};
|
|
649
|
+
const {
|
|
650
|
+
useSuspense,
|
|
651
|
+
keyPrefix
|
|
652
|
+
} = i18nOptions;
|
|
653
|
+
let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
|
|
654
|
+
namespaces = typeof namespaces === "string" ? [namespaces] : namespaces || ["translation"];
|
|
655
|
+
if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
|
|
656
|
+
const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every((n2) => hasLoadedNamespace(n2, i18n, i18nOptions));
|
|
657
|
+
function getT() {
|
|
658
|
+
return i18n.getFixedT(props.lng || null, i18nOptions.nsMode === "fallback" ? namespaces : namespaces[0], keyPrefix);
|
|
659
|
+
}
|
|
660
|
+
const [t2, setT] = (0, import_react4.useState)(getT);
|
|
661
|
+
let joinedNS = namespaces.join();
|
|
662
|
+
if (props.lng) joinedNS = `${props.lng}${joinedNS}`;
|
|
663
|
+
const previousJoinedNS = usePrevious(joinedNS);
|
|
664
|
+
const isMounted = (0, import_react4.useRef)(true);
|
|
665
|
+
(0, import_react4.useEffect)(() => {
|
|
666
|
+
const {
|
|
667
|
+
bindI18n,
|
|
668
|
+
bindI18nStore
|
|
669
|
+
} = i18nOptions;
|
|
670
|
+
isMounted.current = true;
|
|
671
|
+
if (!ready && !useSuspense) {
|
|
672
|
+
if (props.lng) {
|
|
673
|
+
loadLanguages(i18n, props.lng, namespaces, () => {
|
|
674
|
+
if (isMounted.current) setT(getT);
|
|
675
|
+
});
|
|
676
|
+
} else {
|
|
677
|
+
loadNamespaces(i18n, namespaces, () => {
|
|
678
|
+
if (isMounted.current) setT(getT);
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
|
|
683
|
+
setT(getT);
|
|
684
|
+
}
|
|
685
|
+
function boundReset() {
|
|
686
|
+
if (isMounted.current) setT(getT);
|
|
687
|
+
}
|
|
688
|
+
if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
|
|
689
|
+
if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
|
|
690
|
+
return () => {
|
|
691
|
+
isMounted.current = false;
|
|
692
|
+
if (bindI18n && i18n) bindI18n.split(" ").forEach((e2) => i18n.off(e2, boundReset));
|
|
693
|
+
if (bindI18nStore && i18n) bindI18nStore.split(" ").forEach((e2) => i18n.store.off(e2, boundReset));
|
|
694
|
+
};
|
|
695
|
+
}, [i18n, joinedNS]);
|
|
696
|
+
const isInitial = (0, import_react4.useRef)(true);
|
|
697
|
+
(0, import_react4.useEffect)(() => {
|
|
698
|
+
if (isMounted.current && !isInitial.current) {
|
|
699
|
+
setT(getT);
|
|
700
|
+
}
|
|
701
|
+
isInitial.current = false;
|
|
702
|
+
}, [i18n, keyPrefix]);
|
|
703
|
+
const ret = [t2, i18n, ready];
|
|
704
|
+
ret.t = t2;
|
|
705
|
+
ret.i18n = i18n;
|
|
706
|
+
ret.ready = ready;
|
|
707
|
+
if (ready) return ret;
|
|
708
|
+
if (!ready && !useSuspense) return ret;
|
|
709
|
+
throw new Promise((resolve) => {
|
|
710
|
+
if (props.lng) {
|
|
711
|
+
loadLanguages(i18n, props.lng, namespaces, () => resolve());
|
|
712
|
+
} else {
|
|
713
|
+
loadNamespaces(i18n, namespaces, () => resolve());
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/withTranslation.js
|
|
719
|
+
var import_react5 = __toESM(require_react(), 1);
|
|
720
|
+
function withTranslation(ns) {
|
|
721
|
+
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
722
|
+
return function Extend(WrappedComponent) {
|
|
723
|
+
function I18nextWithTranslation(_ref) {
|
|
724
|
+
let {
|
|
725
|
+
forwardedRef,
|
|
726
|
+
...rest
|
|
727
|
+
} = _ref;
|
|
728
|
+
const [t2, i18n, ready] = useTranslation(ns, {
|
|
729
|
+
...rest,
|
|
730
|
+
keyPrefix: options.keyPrefix
|
|
731
|
+
});
|
|
732
|
+
const passDownProps = {
|
|
733
|
+
...rest,
|
|
734
|
+
t: t2,
|
|
735
|
+
i18n,
|
|
736
|
+
tReady: ready
|
|
737
|
+
};
|
|
738
|
+
if (options.withRef && forwardedRef) {
|
|
739
|
+
passDownProps.ref = forwardedRef;
|
|
740
|
+
} else if (!options.withRef && forwardedRef) {
|
|
741
|
+
passDownProps.forwardedRef = forwardedRef;
|
|
742
|
+
}
|
|
743
|
+
return (0, import_react5.createElement)(WrappedComponent, passDownProps);
|
|
744
|
+
}
|
|
745
|
+
I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(WrappedComponent)})`;
|
|
746
|
+
I18nextWithTranslation.WrappedComponent = WrappedComponent;
|
|
747
|
+
const forwardRef = (props, ref) => (0, import_react5.createElement)(I18nextWithTranslation, Object.assign({}, props, {
|
|
748
|
+
forwardedRef: ref
|
|
749
|
+
}));
|
|
750
|
+
return options.withRef ? (0, import_react5.forwardRef)(forwardRef) : I18nextWithTranslation;
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/Translation.js
|
|
755
|
+
function Translation(props) {
|
|
756
|
+
const {
|
|
757
|
+
ns,
|
|
758
|
+
children,
|
|
759
|
+
...options
|
|
760
|
+
} = props;
|
|
761
|
+
const [t2, i18n, ready] = useTranslation(ns, options);
|
|
762
|
+
return children(t2, {
|
|
763
|
+
i18n,
|
|
764
|
+
lng: i18n.language
|
|
765
|
+
}, ready);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/I18nextProvider.js
|
|
769
|
+
var import_react6 = __toESM(require_react(), 1);
|
|
770
|
+
function I18nextProvider(_ref) {
|
|
771
|
+
let {
|
|
772
|
+
i18n,
|
|
773
|
+
defaultNS,
|
|
774
|
+
children
|
|
775
|
+
} = _ref;
|
|
776
|
+
const value = (0, import_react6.useMemo)(() => ({
|
|
777
|
+
i18n,
|
|
778
|
+
defaultNS
|
|
779
|
+
}), [i18n, defaultNS]);
|
|
780
|
+
return (0, import_react6.createElement)(I18nContext.Provider, {
|
|
781
|
+
value
|
|
782
|
+
}, children);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/withSSR.js
|
|
786
|
+
var import_react8 = __toESM(require_react(), 1);
|
|
787
|
+
|
|
788
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/useSSR.js
|
|
789
|
+
var import_react7 = __toESM(require_react(), 1);
|
|
790
|
+
function useSSR(initialI18nStore, initialLanguage) {
|
|
791
|
+
let props = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
792
|
+
const {
|
|
793
|
+
i18n: i18nFromProps
|
|
794
|
+
} = props;
|
|
795
|
+
const {
|
|
796
|
+
i18n: i18nFromContext
|
|
797
|
+
} = (0, import_react7.useContext)(I18nContext) || {};
|
|
798
|
+
const i18n = i18nFromProps || i18nFromContext || getI18n();
|
|
799
|
+
if (i18n.options && i18n.options.isClone) return;
|
|
800
|
+
if (initialI18nStore && !i18n.initializedStoreOnce) {
|
|
801
|
+
i18n.services.resourceStore.data = initialI18nStore;
|
|
802
|
+
i18n.options.ns = Object.values(initialI18nStore).reduce((mem, lngResources) => {
|
|
803
|
+
Object.keys(lngResources).forEach((ns) => {
|
|
804
|
+
if (mem.indexOf(ns) < 0) mem.push(ns);
|
|
805
|
+
});
|
|
806
|
+
return mem;
|
|
807
|
+
}, i18n.options.ns);
|
|
808
|
+
i18n.initializedStoreOnce = true;
|
|
809
|
+
i18n.isInitialized = true;
|
|
810
|
+
}
|
|
811
|
+
if (initialLanguage && !i18n.initializedLanguageOnce) {
|
|
812
|
+
i18n.changeLanguage(initialLanguage);
|
|
813
|
+
i18n.initializedLanguageOnce = true;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/withSSR.js
|
|
818
|
+
function withSSR() {
|
|
819
|
+
return function Extend(WrappedComponent) {
|
|
820
|
+
function I18nextWithSSR(_ref) {
|
|
821
|
+
let {
|
|
822
|
+
initialI18nStore,
|
|
823
|
+
initialLanguage,
|
|
824
|
+
...rest
|
|
825
|
+
} = _ref;
|
|
826
|
+
useSSR(initialI18nStore, initialLanguage);
|
|
827
|
+
return (0, import_react8.createElement)(WrappedComponent, {
|
|
828
|
+
...rest
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
I18nextWithSSR.getInitialProps = composeInitialProps(WrappedComponent);
|
|
832
|
+
I18nextWithSSR.displayName = `withI18nextSSR(${getDisplayName(WrappedComponent)})`;
|
|
833
|
+
I18nextWithSSR.WrappedComponent = WrappedComponent;
|
|
834
|
+
return I18nextWithSSR;
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// ../node_modules/.pnpm/react-i18next@13.5.0_i18nex_6dec3e272014f80cb40c06a5db44526d/node_modules/react-i18next/dist/es/index.js
|
|
839
|
+
var date = () => "";
|
|
840
|
+
var time = () => "";
|
|
841
|
+
var number = () => "";
|
|
842
|
+
var select = () => "";
|
|
843
|
+
var plural = () => "";
|
|
844
|
+
var selectOrdinal = () => "";
|
|
845
|
+
export {
|
|
846
|
+
I18nContext,
|
|
847
|
+
I18nextProvider,
|
|
848
|
+
Trans2 as Trans,
|
|
849
|
+
Trans as TransWithoutContext,
|
|
850
|
+
Translation,
|
|
851
|
+
composeInitialProps,
|
|
852
|
+
date,
|
|
853
|
+
getDefaults,
|
|
854
|
+
getI18n,
|
|
855
|
+
getInitialProps,
|
|
856
|
+
initReactI18next,
|
|
857
|
+
number,
|
|
858
|
+
plural,
|
|
859
|
+
select,
|
|
860
|
+
selectOrdinal,
|
|
861
|
+
setDefaults,
|
|
862
|
+
setI18n,
|
|
863
|
+
time,
|
|
864
|
+
useSSR,
|
|
865
|
+
useTranslation,
|
|
866
|
+
withSSR,
|
|
867
|
+
withTranslation
|
|
868
|
+
};
|
|
869
|
+
//# sourceMappingURL=react-i18next.js.map
|