@deriv-com/translations 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -25
- package/dist/components/index.js +2 -2
- package/dist/components/localize.js +253 -224
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/use-translations.js +15 -81
- package/dist/index.js +1 -1
- package/dist/useTranslation-DWHGHs02.js +132 -0
- package/dist/utils/localize.d.ts +0 -2
- package/package.json +1 -1
- package/dist/components/localize.d.ts +0 -9
- package/dist/utils-6G1tiZlP.js +0 -61
package/README.md
CHANGED
|
@@ -36,14 +36,15 @@ To get started, one would need few things to setup first which are:
|
|
|
36
36
|
- Create a new bucket in the R2 account.
|
|
37
37
|
- Create a new access key in the R2 account.
|
|
38
38
|
3. Add the following secrets to your repository:
|
|
39
|
-
- `CROWDIN_PROJECT_ID`: Open your crowdin project and navigate to `Tools` tab, you will be able to get the Project ID, store that in your github secrets
|
|
40
|
-
- `CROWDIN_PERSONAL_TOKEN`: This can be obtained by logging in to your crowdin account and clicking on your profile icon and goto `Settings > API` and create a new personal access token, store that in your github secrets
|
|
41
|
-
- `R2_ACCOUNT_ID`: R2 account ID from the Cloudflare R2 dashboard
|
|
42
|
-
- `R2_ACCESS_KEY_ID`: R2 access key ID from the Cloudflare R2 dashboard
|
|
43
|
-
- `R2_SECRET_ACCESS_KEY`: R2 secret access key from the Cloudflare R2 dashboard
|
|
44
|
-
- `R2_BUCKET_NAME`: R2 bucket name from the Cloudflare R2 dashboard
|
|
39
|
+
- `CROWDIN_PROJECT_ID`: Open your crowdin project and navigate to `Tools` tab, you will be able to get the Project ID, store that in your github secrets.
|
|
40
|
+
- `CROWDIN_PERSONAL_TOKEN`: This can be obtained by logging in to your crowdin account and clicking on your profile icon and goto `Settings > API` and create a new personal access token, store that in your github secrets.
|
|
41
|
+
- `R2_ACCOUNT_ID`: R2 account ID from the Cloudflare R2 dashboard.
|
|
42
|
+
- `R2_ACCESS_KEY_ID`: R2 access key ID from the Cloudflare R2 dashboard.
|
|
43
|
+
- `R2_SECRET_ACCESS_KEY`: R2 secret access key from the Cloudflare R2 dashboard.
|
|
44
|
+
- `R2_BUCKET_NAME`: R2 bucket name from the Cloudflare R2 dashboard.
|
|
45
45
|
4. Add the following environment variable in your repository:
|
|
46
|
-
- `PROJECT_NAME`: Add project name in your environment variable which will be used for Cloudflare R2 folder name for translations
|
|
46
|
+
- `PROJECT_NAME`: Add project name in your environment variable which will be used for Cloudflare R2 folder name for translations.
|
|
47
|
+
- `CROWDIN_BRANCH_NAME`: Add the branch name for your crowdin project to separate the translations based on environment, this needs to be put into the environment variable instead of secret because the consumer of the package needs it while defining the `cdnUrl` to access the translations.
|
|
47
48
|
5. Setup the github action to sync the translations to the CDN, refer to the [Syncing translations](#syncing-translations) section for more details.
|
|
48
49
|
|
|
49
50
|
Install the package by running:
|
|
@@ -54,7 +55,7 @@ npm install @deriv-com/translations
|
|
|
54
55
|
|
|
55
56
|
### Setup
|
|
56
57
|
|
|
57
|
-
- initialize translations in main component by importing and calling `initializeI18n` outside of the component function
|
|
58
|
+
- initialize translations in main component by importing and calling `initializeI18n` outside of the component function.
|
|
58
59
|
- pass the return value to the `TranslationProvider` component from `@deriv-com/translations`.
|
|
59
60
|
- pass default language to the `TranslationProvider` component.
|
|
60
61
|
|
|
@@ -86,7 +87,7 @@ import initializeI18n from "@deriv-com/translations";
|
|
|
86
87
|
initializeI18n({ cdnUrl: "https://cdn.example.com" });
|
|
87
88
|
```
|
|
88
89
|
|
|
89
|
-
- For strings use either `localize(...)` or `<Localize
|
|
90
|
+
- For strings use either `localize(...)` or `<Localize />`.
|
|
90
91
|
|
|
91
92
|
### `Localize` component example:
|
|
92
93
|
|
|
@@ -137,22 +138,22 @@ There is a github action that syncs the translations from Crowdin to the CDN.
|
|
|
137
138
|
|
|
138
139
|
The action takes following inputs:
|
|
139
140
|
|
|
140
|
-
- `PROJECT_SOURCE_DIRECTORY`: Source directory of your project by default it is `src
|
|
141
|
-
- `CROWDIN_BASE_PATH`: Base path of the translations in the Crowdin project by default it is
|
|
142
|
-
- `CROWDIN_BASE_URL`: Base URL of the CDN where the translations are stored, default is `https://api.crowdin.com
|
|
143
|
-
- `CROWDIN_BRANCH_NAME`: Running on production, test or staging etc
|
|
144
|
-
- `CROWDIN_PROJECT_ID`: Crowdin project ID which can be found in the crowdin project settings
|
|
145
|
-
- `CROWDIN_PERSONAL_TOKEN`: Crowdin personal token which can be found in the crowdin account settings
|
|
146
|
-
- `R2_ACCOUNT_ID`: R2 account ID from the Cloudflare R2 dashboard
|
|
147
|
-
- `R2_ACCESS_KEY_ID`: R2 access key ID from the Cloudflare R2 dashboard
|
|
148
|
-
- `R2_SECRET_ACCESS_KEY`: R2 secret access key from the Cloudflare R2 dashboard
|
|
149
|
-
- `R2_BUCKET_NAME`: R2 bucket name from the Cloudflare R2 dashboard
|
|
141
|
+
- `PROJECT_SOURCE_DIRECTORY`: Source directory of your project by default it is `src`.
|
|
142
|
+
- `CROWDIN_BASE_PATH`: Base path of the translations in the Crowdin project by default it is `.`.
|
|
143
|
+
- `CROWDIN_BASE_URL`: Base URL of the CDN where the translations are stored, default is `https://api.crowdin.com`.
|
|
144
|
+
- `CROWDIN_BRANCH_NAME`: Running on production, test or staging etc.
|
|
145
|
+
- `CROWDIN_PROJECT_ID`: Crowdin project ID which can be found in the crowdin project settings.
|
|
146
|
+
- `CROWDIN_PERSONAL_TOKEN`: Crowdin personal token which can be found in the crowdin account settings.
|
|
147
|
+
- `R2_ACCOUNT_ID`: R2 account ID from the Cloudflare R2 dashboard.
|
|
148
|
+
- `R2_ACCESS_KEY_ID`: R2 access key ID from the Cloudflare R2 dashboard.
|
|
149
|
+
- `R2_SECRET_ACCESS_KEY`: R2 secret access key from the Cloudflare R2 dashboard.
|
|
150
|
+
- `R2_BUCKET_NAME`: R2 bucket name from the Cloudflare R2 dashboard.
|
|
150
151
|
|
|
151
|
-
Refer to the action file [here](https://github.com/deriv-com/translations/blob/main/.github/actions/extract_and_sync_translations/action.yml)
|
|
152
|
+
Refer to the action file [here](https://github.com/deriv-com/translations/blob/main/.github/actions/extract_and_sync_translations/action.yml).
|
|
152
153
|
|
|
153
154
|
### Example usage of the action in the workflow file:
|
|
154
155
|
|
|
155
|
-
Copy and paste the following workflow code in your repository in this path`.github/workflows/sync_translations.yml
|
|
156
|
+
Copy and paste the following workflow code in your repository in this path`.github/workflows/sync_translations.yml`.
|
|
156
157
|
|
|
157
158
|
```yaml
|
|
158
159
|
name: Sync translations
|
|
@@ -161,19 +162,18 @@ on:
|
|
|
161
162
|
push:
|
|
162
163
|
branches:
|
|
163
164
|
- 'main'
|
|
165
|
+
schedule:
|
|
166
|
+
- cron: '0 */12 * * *'
|
|
164
167
|
|
|
165
168
|
jobs:
|
|
166
169
|
sync_translations:
|
|
167
170
|
runs-on: ubuntu-latest
|
|
168
171
|
steps:
|
|
169
|
-
- name: Checkout to main branch
|
|
170
|
-
uses: actions/checkout@v3
|
|
171
|
-
|
|
172
172
|
- name: Sync translations
|
|
173
173
|
uses: deriv-com/translations/.github/actions/extract_and_sync_translations@main
|
|
174
174
|
with:
|
|
175
175
|
PROJECT_NAME: ${{ env.PROJECT_NAME }}
|
|
176
|
-
CROWDIN_BRANCH_NAME: ${{
|
|
176
|
+
CROWDIN_BRANCH_NAME: ${{ env.CROWDIN_BRANCH_NAME }}
|
|
177
177
|
CROWDIN_BASE_URL: ${{ env.CROWDIN_BASE_URL }}
|
|
178
178
|
CROWDIN_BASE_PATH: ${{ env.CROWDIN_BASE_PATH }}
|
|
179
179
|
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
package/dist/components/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { default as e } from "./localize.js";
|
|
2
2
|
import "react/jsx-runtime";
|
|
3
3
|
import "react";
|
|
4
|
-
import "../
|
|
5
|
-
import "../i18nInstance-D20fwFYr.js";
|
|
4
|
+
import "../useTranslation-DWHGHs02.js";
|
|
6
5
|
import "../context-f4Bcf4Hs.js";
|
|
6
|
+
import "../i18nInstance-D20fwFYr.js";
|
|
7
7
|
export {
|
|
8
8
|
e as Localize
|
|
9
9
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createElement as T, isValidElement as
|
|
3
|
-
import { w as X,
|
|
4
|
-
import { g as
|
|
5
|
-
import { I as
|
|
6
|
-
function
|
|
7
|
-
return
|
|
1
|
+
import { jsx as W } from "react/jsx-runtime";
|
|
2
|
+
import { createElement as T, isValidElement as D, Fragment as z, cloneElement as M, Children as _, useContext as J, forwardRef as U } from "react";
|
|
3
|
+
import { w as X, a as K, g as Y, u as Z } from "../useTranslation-DWHGHs02.js";
|
|
4
|
+
import { g as q, b as V } from "../i18nInstance-D20fwFYr.js";
|
|
5
|
+
import { I as G } from "../context-f4Bcf4Hs.js";
|
|
6
|
+
function Q(e) {
|
|
7
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
8
8
|
}
|
|
9
|
-
var
|
|
9
|
+
var ee = {
|
|
10
10
|
area: !0,
|
|
11
11
|
base: !0,
|
|
12
12
|
br: !0,
|
|
@@ -22,344 +22,373 @@ var G = {
|
|
|
22
22
|
track: !0,
|
|
23
23
|
wbr: !0
|
|
24
24
|
};
|
|
25
|
-
const
|
|
26
|
-
var
|
|
27
|
-
function
|
|
28
|
-
var
|
|
29
|
-
if (n && (
|
|
30
|
-
var o =
|
|
31
|
-
return { type: "comment", comment: o !== -1 ?
|
|
25
|
+
const te = /* @__PURE__ */ Q(ee);
|
|
26
|
+
var ne = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
|
|
27
|
+
function S(e) {
|
|
28
|
+
var t = { type: "tag", name: "", voidElement: !1, attrs: {}, children: [] }, n = e.match(/<\/?([^\s]+?)[/\s>]/);
|
|
29
|
+
if (n && (t.name = n[1], (te[n[1]] || e.charAt(e.length - 2) === "/") && (t.voidElement = !0), t.name.startsWith("!--"))) {
|
|
30
|
+
var o = e.indexOf("-->");
|
|
31
|
+
return { type: "comment", comment: o !== -1 ? e.slice(4, o) : "" };
|
|
32
32
|
}
|
|
33
|
-
for (var
|
|
33
|
+
for (var p = new RegExp(ne), s = null; (s = p.exec(e)) !== null; )
|
|
34
34
|
if (s[0].trim())
|
|
35
35
|
if (s[1]) {
|
|
36
|
-
var
|
|
37
|
-
|
|
36
|
+
var i = s[1].trim(), a = [i, ""];
|
|
37
|
+
i.indexOf("=") > -1 && (a = i.split("=")), t.attrs[a[0]] = a[1], p.lastIndex--;
|
|
38
38
|
} else
|
|
39
|
-
s[2] && (
|
|
40
|
-
return
|
|
39
|
+
s[2] && (t.attrs[s[2]] = s[3].trim().substring(1, s[3].length - 1));
|
|
40
|
+
return t;
|
|
41
41
|
}
|
|
42
|
-
var
|
|
43
|
-
function
|
|
44
|
-
switch (
|
|
42
|
+
var se = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g, re = /^\s*$/, oe = /* @__PURE__ */ Object.create(null);
|
|
43
|
+
function B(e, t) {
|
|
44
|
+
switch (t.type) {
|
|
45
45
|
case "text":
|
|
46
|
-
return
|
|
46
|
+
return e + t.content;
|
|
47
47
|
case "tag":
|
|
48
|
-
return
|
|
48
|
+
return e += "<" + t.name + (t.attrs ? function(n) {
|
|
49
49
|
var o = [];
|
|
50
|
-
for (var
|
|
51
|
-
o.push(
|
|
50
|
+
for (var p in n)
|
|
51
|
+
o.push(p + '="' + n[p] + '"');
|
|
52
52
|
return o.length ? " " + o.join(" ") : "";
|
|
53
|
-
}(
|
|
53
|
+
}(t.attrs) : "") + (t.voidElement ? "/>" : ">"), t.voidElement ? e : e + t.children.reduce(B, "") + "</" + t.name + ">";
|
|
54
54
|
case "comment":
|
|
55
|
-
return
|
|
55
|
+
return e + "<!--" + t.comment + "-->";
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
var n, o = [],
|
|
61
|
-
if (
|
|
62
|
-
var
|
|
63
|
-
o.push({ type: "text", content:
|
|
58
|
+
var ae = { parse: function(e, t) {
|
|
59
|
+
t || (t = {}), t.components || (t.components = oe);
|
|
60
|
+
var n, o = [], p = [], s = -1, i = !1;
|
|
61
|
+
if (e.indexOf("<") !== 0) {
|
|
62
|
+
var a = e.indexOf("<");
|
|
63
|
+
o.push({ type: "text", content: a === -1 ? e : e.substring(0, a) });
|
|
64
64
|
}
|
|
65
|
-
return
|
|
66
|
-
if (
|
|
67
|
-
if (
|
|
65
|
+
return e.replace(se, function(f, c) {
|
|
66
|
+
if (i) {
|
|
67
|
+
if (f !== "</" + n.name + ">")
|
|
68
68
|
return;
|
|
69
|
-
|
|
69
|
+
i = !1;
|
|
70
70
|
}
|
|
71
|
-
var
|
|
72
|
-
if (
|
|
73
|
-
var y =
|
|
74
|
-
return s < 0 ? (o.push(y), o) : ((
|
|
71
|
+
var g, j = f.charAt(1) !== "/", w = f.startsWith("<!--"), b = c + f.length, x = e.charAt(b);
|
|
72
|
+
if (w) {
|
|
73
|
+
var y = S(f);
|
|
74
|
+
return s < 0 ? (o.push(y), o) : ((g = p[s]).children.push(y), o);
|
|
75
75
|
}
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
var
|
|
79
|
-
|
|
76
|
+
if (j && (s++, (n = S(f)).type === "tag" && t.components[n.name] && (n.type = "component", i = !0), n.voidElement || i || !x || x === "<" || n.children.push({ type: "text", content: e.slice(b, e.indexOf("<", b)) }), s === 0 && o.push(n), (g = p[s - 1]) && g.children.push(n), p[s] = n), (!j || n.voidElement) && (s > -1 && (n.voidElement || n.name === f.slice(2, -1)) && (s--, n = s === -1 ? o : p[s]), !i && x !== "<" && x)) {
|
|
77
|
+
g = s === -1 ? o : p[s].children;
|
|
78
|
+
var m = e.indexOf("<", b), u = e.slice(b, m === -1 ? void 0 : m);
|
|
79
|
+
re.test(u) && (u = " "), (m > -1 && s + g.length >= 0 || u !== " ") && g.push({ type: "text", content: u });
|
|
80
80
|
}
|
|
81
81
|
}), o;
|
|
82
|
-
}, stringify: function(
|
|
83
|
-
return
|
|
84
|
-
return
|
|
82
|
+
}, stringify: function(e) {
|
|
83
|
+
return e.reduce(function(t, n) {
|
|
84
|
+
return t + B("", n);
|
|
85
85
|
}, "");
|
|
86
86
|
} };
|
|
87
|
-
function
|
|
88
|
-
if (!
|
|
87
|
+
function H(e, t) {
|
|
88
|
+
if (!e)
|
|
89
89
|
return !1;
|
|
90
|
-
const n =
|
|
91
|
-
return
|
|
90
|
+
const n = e.props ? e.props.children : e.children;
|
|
91
|
+
return t ? n.length > 0 : !!n;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
if (!
|
|
93
|
+
function R(e) {
|
|
94
|
+
if (!e)
|
|
95
95
|
return [];
|
|
96
|
-
const
|
|
97
|
-
return
|
|
96
|
+
const t = e.props ? e.props.children : e.children;
|
|
97
|
+
return e.props && e.props.i18nIsDynamicList ? F(t) : t;
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
return Object.prototype.toString.call(
|
|
99
|
+
function ie(e) {
|
|
100
|
+
return Object.prototype.toString.call(e) !== "[object Array]" ? !1 : e.every((t) => D(t));
|
|
101
101
|
}
|
|
102
|
-
function
|
|
103
|
-
return Array.isArray(
|
|
102
|
+
function F(e) {
|
|
103
|
+
return Array.isArray(e) ? e : [e];
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function le(e, t) {
|
|
106
106
|
const n = {
|
|
107
|
-
...
|
|
107
|
+
...t
|
|
108
108
|
};
|
|
109
|
-
return n.props = Object.assign(
|
|
109
|
+
return n.props = Object.assign(e.props, t.props), n;
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
if (!
|
|
111
|
+
function L(e, t) {
|
|
112
|
+
if (!e)
|
|
113
113
|
return "";
|
|
114
114
|
let n = "";
|
|
115
|
-
const o =
|
|
116
|
-
return o.forEach((s,
|
|
115
|
+
const o = F(e), p = t.transSupportBasicHtmlNodes && t.transKeepBasicHtmlNodesFor ? t.transKeepBasicHtmlNodesFor : [];
|
|
116
|
+
return o.forEach((s, i) => {
|
|
117
117
|
if (typeof s == "string")
|
|
118
118
|
n += `${s}`;
|
|
119
|
-
else if (
|
|
120
|
-
const
|
|
121
|
-
if (!
|
|
119
|
+
else if (D(s)) {
|
|
120
|
+
const a = Object.keys(s.props).length, f = p.indexOf(s.type) > -1, c = s.props.children;
|
|
121
|
+
if (!c && f && a === 0)
|
|
122
122
|
n += `<${s.type}/>`;
|
|
123
|
-
else if (!
|
|
124
|
-
n += `<${
|
|
123
|
+
else if (!c && (!f || a !== 0))
|
|
124
|
+
n += `<${i}></${i}>`;
|
|
125
125
|
else if (s.props.i18nIsDynamicList)
|
|
126
|
-
n += `<${
|
|
127
|
-
else if (
|
|
128
|
-
n += `<${s.type}>${
|
|
126
|
+
n += `<${i}></${i}>`;
|
|
127
|
+
else if (f && a === 1 && typeof c == "string")
|
|
128
|
+
n += `<${s.type}>${c}</${s.type}>`;
|
|
129
129
|
else {
|
|
130
|
-
const
|
|
131
|
-
n += `<${
|
|
130
|
+
const g = L(c, t);
|
|
131
|
+
n += `<${i}>${g}</${i}>`;
|
|
132
132
|
}
|
|
133
133
|
} else if (s === null)
|
|
134
|
-
|
|
134
|
+
K("Trans: the passed in value is invalid - seems you passed in a null child.");
|
|
135
135
|
else if (typeof s == "object") {
|
|
136
136
|
const {
|
|
137
|
-
format:
|
|
138
|
-
...
|
|
139
|
-
} = s,
|
|
140
|
-
if (
|
|
141
|
-
const
|
|
142
|
-
n += `{{${
|
|
137
|
+
format: a,
|
|
138
|
+
...f
|
|
139
|
+
} = s, c = Object.keys(f);
|
|
140
|
+
if (c.length === 1) {
|
|
141
|
+
const g = a ? `${c[0]}, ${a}` : c[0];
|
|
142
|
+
n += `{{${g}}}`;
|
|
143
143
|
} else
|
|
144
|
-
|
|
144
|
+
K("react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.", s);
|
|
145
145
|
} else
|
|
146
|
-
|
|
146
|
+
K("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}}.", s);
|
|
147
147
|
}), n;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
if (
|
|
149
|
+
function pe(e, t, n, o, p, s) {
|
|
150
|
+
if (t === "")
|
|
151
151
|
return [];
|
|
152
|
-
const
|
|
153
|
-
if (!
|
|
154
|
-
return [
|
|
155
|
-
const
|
|
156
|
-
function
|
|
157
|
-
|
|
158
|
-
typeof
|
|
152
|
+
const i = o.transKeepBasicHtmlNodesFor || [], a = t && new RegExp(i.map((m) => `<${m}`).join("|")).test(t);
|
|
153
|
+
if (!e && !a && !s)
|
|
154
|
+
return [t];
|
|
155
|
+
const f = {};
|
|
156
|
+
function c(m) {
|
|
157
|
+
F(m).forEach((l) => {
|
|
158
|
+
typeof l != "string" && (H(l) ? c(R(l)) : typeof l == "object" && !D(l) && Object.assign(f, l));
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
...
|
|
164
|
-
...
|
|
161
|
+
c(e);
|
|
162
|
+
const g = ae.parse(`<0>${t}</0>`), j = {
|
|
163
|
+
...f,
|
|
164
|
+
...p
|
|
165
165
|
};
|
|
166
|
-
function
|
|
167
|
-
const
|
|
168
|
-
return
|
|
166
|
+
function w(m, u, l) {
|
|
167
|
+
const v = R(m), O = x(v, u.children, l);
|
|
168
|
+
return ie(v) && O.length === 0 || m.props && m.props.i18nIsDynamicList ? v : O;
|
|
169
169
|
}
|
|
170
|
-
function b(
|
|
171
|
-
|
|
172
|
-
key:
|
|
173
|
-
}, O ? void 0 :
|
|
170
|
+
function b(m, u, l, v, O) {
|
|
171
|
+
m.dummy ? (m.children = u, l.push(M(m, {
|
|
172
|
+
key: v
|
|
173
|
+
}, O ? void 0 : u))) : l.push(..._.map([m], (h) => {
|
|
174
174
|
const r = {
|
|
175
175
|
...h.props
|
|
176
176
|
};
|
|
177
177
|
return delete r.i18nIsDynamicList, T(h.type, {
|
|
178
178
|
...r,
|
|
179
|
-
key:
|
|
179
|
+
key: v,
|
|
180
180
|
ref: h.ref
|
|
181
|
-
}, O ? null :
|
|
181
|
+
}, O ? null : u);
|
|
182
182
|
}));
|
|
183
183
|
}
|
|
184
|
-
function
|
|
185
|
-
const
|
|
186
|
-
return
|
|
187
|
-
const
|
|
184
|
+
function x(m, u, l) {
|
|
185
|
+
const v = F(m);
|
|
186
|
+
return F(u).reduce((h, r, k) => {
|
|
187
|
+
const C = r.children && r.children[0] && r.children[0].content && n.services.interpolator.interpolate(r.children[0].content, j, n.language);
|
|
188
188
|
if (r.type === "tag") {
|
|
189
|
-
let
|
|
190
|
-
|
|
191
|
-
const d = Object.keys(r.attrs).length !== 0 ?
|
|
189
|
+
let E = v[parseInt(r.name, 10)];
|
|
190
|
+
l.length === 1 && !E && (E = l[0][r.name]), E || (E = {});
|
|
191
|
+
const d = Object.keys(r.attrs).length !== 0 ? le({
|
|
192
192
|
props: r.attrs
|
|
193
|
-
},
|
|
193
|
+
}, E) : E, N = D(d), A = N && H(r, !0) && !r.voidElement, P = a && typeof d == "object" && d.dummy && !N, I = typeof e == "object" && e !== null && Object.hasOwnProperty.call(e, r.name);
|
|
194
194
|
if (typeof d == "string") {
|
|
195
|
-
const
|
|
196
|
-
h.push(
|
|
197
|
-
} else if (
|
|
198
|
-
const
|
|
199
|
-
b(d,
|
|
200
|
-
} else if (
|
|
201
|
-
const
|
|
202
|
-
b(d,
|
|
195
|
+
const $ = n.services.interpolator.interpolate(d, j, n.language);
|
|
196
|
+
h.push($);
|
|
197
|
+
} else if (H(d) || A) {
|
|
198
|
+
const $ = w(d, r, l);
|
|
199
|
+
b(d, $, h, k);
|
|
200
|
+
} else if (P) {
|
|
201
|
+
const $ = x(v, r.children, l);
|
|
202
|
+
b(d, $, h, k);
|
|
203
203
|
} else if (Number.isNaN(parseFloat(r.name)))
|
|
204
|
-
if (
|
|
205
|
-
const
|
|
206
|
-
b(d,
|
|
207
|
-
} else if (o.transSupportBasicHtmlNodes &&
|
|
204
|
+
if (I) {
|
|
205
|
+
const $ = w(d, r, l);
|
|
206
|
+
b(d, $, h, k, r.voidElement);
|
|
207
|
+
} else if (o.transSupportBasicHtmlNodes && i.indexOf(r.name) > -1)
|
|
208
208
|
if (r.voidElement)
|
|
209
209
|
h.push(T(r.name, {
|
|
210
|
-
key: `${r.name}-${
|
|
210
|
+
key: `${r.name}-${k}`
|
|
211
211
|
}));
|
|
212
212
|
else {
|
|
213
|
-
const
|
|
213
|
+
const $ = x(v, r.children, l);
|
|
214
214
|
h.push(T(r.name, {
|
|
215
|
-
key: `${r.name}-${
|
|
216
|
-
},
|
|
215
|
+
key: `${r.name}-${k}`
|
|
216
|
+
}, $));
|
|
217
217
|
}
|
|
218
218
|
else if (r.voidElement)
|
|
219
219
|
h.push(`<${r.name} />`);
|
|
220
220
|
else {
|
|
221
|
-
const
|
|
222
|
-
h.push(`<${r.name}>${
|
|
221
|
+
const $ = x(v, r.children, l);
|
|
222
|
+
h.push(`<${r.name}>${$}</${r.name}>`);
|
|
223
223
|
}
|
|
224
|
-
else if (typeof d == "object" && !
|
|
225
|
-
const
|
|
226
|
-
|
|
224
|
+
else if (typeof d == "object" && !N) {
|
|
225
|
+
const $ = r.children[0] ? C : null;
|
|
226
|
+
$ && h.push($);
|
|
227
227
|
} else
|
|
228
|
-
b(d,
|
|
228
|
+
b(d, C, h, k, r.children.length !== 1 || !C);
|
|
229
229
|
} else if (r.type === "text") {
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
key: `${r.name}-${
|
|
230
|
+
const E = o.transWrapTextNodes, d = s ? o.unescape(n.services.interpolator.interpolate(r.content, j, n.language)) : n.services.interpolator.interpolate(r.content, j, n.language);
|
|
231
|
+
E ? h.push(T(E, {
|
|
232
|
+
key: `${r.name}-${k}`
|
|
233
233
|
}, d)) : h.push(d);
|
|
234
234
|
}
|
|
235
235
|
return h;
|
|
236
236
|
}, []);
|
|
237
237
|
}
|
|
238
|
-
const y =
|
|
238
|
+
const y = x([{
|
|
239
239
|
dummy: !0,
|
|
240
|
-
children:
|
|
241
|
-
}],
|
|
242
|
-
return
|
|
240
|
+
children: e || []
|
|
241
|
+
}], g, F(e || []));
|
|
242
|
+
return R(y[0]);
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function ue(e) {
|
|
245
245
|
let {
|
|
246
|
-
children:
|
|
246
|
+
children: t,
|
|
247
247
|
count: n,
|
|
248
248
|
parent: o,
|
|
249
|
-
i18nKey:
|
|
249
|
+
i18nKey: p,
|
|
250
250
|
context: s,
|
|
251
|
-
tOptions:
|
|
252
|
-
values:
|
|
253
|
-
defaults:
|
|
254
|
-
components:
|
|
255
|
-
ns:
|
|
256
|
-
i18n:
|
|
257
|
-
t:
|
|
251
|
+
tOptions: i = {},
|
|
252
|
+
values: a,
|
|
253
|
+
defaults: f,
|
|
254
|
+
components: c,
|
|
255
|
+
ns: g,
|
|
256
|
+
i18n: j,
|
|
257
|
+
t: w,
|
|
258
258
|
shouldUnescape: b,
|
|
259
|
-
|
|
260
|
-
} =
|
|
261
|
-
const y =
|
|
259
|
+
...x
|
|
260
|
+
} = e;
|
|
261
|
+
const y = j || V();
|
|
262
262
|
if (!y)
|
|
263
|
-
return X("You will need to pass in an i18next instance by using i18nextReactModule"),
|
|
264
|
-
const
|
|
265
|
-
s && (
|
|
266
|
-
const
|
|
267
|
-
...
|
|
263
|
+
return X("You will need to pass in an i18next instance by using i18nextReactModule"), t;
|
|
264
|
+
const m = w || y.t.bind(y) || ((A) => A);
|
|
265
|
+
s && (i.context = s);
|
|
266
|
+
const u = {
|
|
267
|
+
...q(),
|
|
268
268
|
...y.options && y.options.react
|
|
269
269
|
};
|
|
270
|
-
let
|
|
271
|
-
|
|
272
|
-
const
|
|
270
|
+
let l = g || m.ns || y.options && y.options.defaultNS;
|
|
271
|
+
l = typeof l == "string" ? [l] : l || ["translation"];
|
|
272
|
+
const v = L(t, u), O = f || v || u.transEmptyNodeValue || p, {
|
|
273
273
|
hashTransKey: h
|
|
274
|
-
} =
|
|
275
|
-
y.options && y.options.interpolation && y.options.interpolation.defaultVariables && (
|
|
276
|
-
...
|
|
274
|
+
} = u, r = p || (h ? h(v || O) : v || O);
|
|
275
|
+
y.options && y.options.interpolation && y.options.interpolation.defaultVariables && (a = a && Object.keys(a).length > 0 ? {
|
|
276
|
+
...a,
|
|
277
277
|
...y.options.interpolation.defaultVariables
|
|
278
278
|
} : {
|
|
279
279
|
...y.options.interpolation.defaultVariables
|
|
280
280
|
});
|
|
281
|
-
const
|
|
281
|
+
const k = a ? i.interpolation : {
|
|
282
282
|
interpolation: {
|
|
283
|
-
...
|
|
283
|
+
...i.interpolation,
|
|
284
284
|
prefix: "#$?",
|
|
285
285
|
suffix: "?$#"
|
|
286
286
|
}
|
|
287
|
-
},
|
|
288
|
-
...
|
|
287
|
+
}, C = {
|
|
288
|
+
...i,
|
|
289
289
|
count: n,
|
|
290
|
-
...
|
|
291
|
-
...
|
|
290
|
+
...a,
|
|
291
|
+
...k,
|
|
292
292
|
defaultValue: O,
|
|
293
|
-
ns:
|
|
294
|
-
},
|
|
295
|
-
|
|
296
|
-
const
|
|
297
|
-
if (typeof
|
|
293
|
+
ns: l
|
|
294
|
+
}, E = r ? m(r, C) : O;
|
|
295
|
+
c && Object.keys(c).forEach((A) => {
|
|
296
|
+
const P = c[A];
|
|
297
|
+
if (typeof P.type == "function" || !P.props || !P.props.children || E.indexOf(`${A}/>`) < 0 && E.indexOf(`${A} />`) < 0)
|
|
298
298
|
return;
|
|
299
|
-
function
|
|
300
|
-
return T(
|
|
299
|
+
function I() {
|
|
300
|
+
return T(z, null, P);
|
|
301
301
|
}
|
|
302
|
-
|
|
302
|
+
c[A] = T(I);
|
|
303
303
|
});
|
|
304
|
-
const d =
|
|
305
|
-
return
|
|
304
|
+
const d = pe(c || t, E, y, u, C, b), N = o !== void 0 ? o : u.defaultTransParent;
|
|
305
|
+
return N ? T(N, x, d) : d;
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function ce(e) {
|
|
308
308
|
let {
|
|
309
|
-
children:
|
|
309
|
+
children: t,
|
|
310
310
|
count: n,
|
|
311
311
|
parent: o,
|
|
312
|
-
i18nKey:
|
|
312
|
+
i18nKey: p,
|
|
313
313
|
context: s,
|
|
314
|
-
tOptions:
|
|
315
|
-
values:
|
|
316
|
-
defaults:
|
|
317
|
-
components:
|
|
318
|
-
ns:
|
|
319
|
-
i18n:
|
|
320
|
-
t:
|
|
314
|
+
tOptions: i = {},
|
|
315
|
+
values: a,
|
|
316
|
+
defaults: f,
|
|
317
|
+
components: c,
|
|
318
|
+
ns: g,
|
|
319
|
+
i18n: j,
|
|
320
|
+
t: w,
|
|
321
321
|
shouldUnescape: b,
|
|
322
|
-
|
|
323
|
-
} =
|
|
322
|
+
...x
|
|
323
|
+
} = e;
|
|
324
324
|
const {
|
|
325
325
|
i18n: y,
|
|
326
|
-
defaultNS:
|
|
327
|
-
} =
|
|
328
|
-
return
|
|
329
|
-
children:
|
|
326
|
+
defaultNS: m
|
|
327
|
+
} = J(G) || {}, u = j || y || V(), l = w || u && u.t.bind(u);
|
|
328
|
+
return ue({
|
|
329
|
+
children: t,
|
|
330
330
|
count: n,
|
|
331
331
|
parent: o,
|
|
332
|
-
i18nKey:
|
|
332
|
+
i18nKey: p,
|
|
333
333
|
context: s,
|
|
334
|
-
tOptions:
|
|
335
|
-
values:
|
|
336
|
-
defaults:
|
|
337
|
-
components:
|
|
338
|
-
ns:
|
|
339
|
-
i18n:
|
|
340
|
-
t:
|
|
334
|
+
tOptions: i,
|
|
335
|
+
values: a,
|
|
336
|
+
defaults: f,
|
|
337
|
+
components: c,
|
|
338
|
+
ns: g || l && l.ns || m || u && u.options && u.options.defaultNS,
|
|
339
|
+
i18n: u,
|
|
340
|
+
t: w,
|
|
341
341
|
shouldUnescape: b,
|
|
342
|
-
|
|
342
|
+
...x
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
|
-
function
|
|
345
|
+
function fe(e) {
|
|
346
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
347
|
+
return function(o) {
|
|
348
|
+
function p(i) {
|
|
349
|
+
let {
|
|
350
|
+
forwardedRef: a,
|
|
351
|
+
...f
|
|
352
|
+
} = i;
|
|
353
|
+
const [c, g, j] = Z(e, {
|
|
354
|
+
...f,
|
|
355
|
+
keyPrefix: t.keyPrefix
|
|
356
|
+
}), w = {
|
|
357
|
+
...f,
|
|
358
|
+
t: c,
|
|
359
|
+
i18n: g,
|
|
360
|
+
tReady: j
|
|
361
|
+
};
|
|
362
|
+
return t.withRef && a ? w.ref = a : !t.withRef && a && (w.forwardedRef = a), T(o, w);
|
|
363
|
+
}
|
|
364
|
+
p.displayName = `withI18nextTranslation(${Y(o)})`, p.WrappedComponent = o;
|
|
365
|
+
const s = (i, a) => T(p, Object.assign({}, i, {
|
|
366
|
+
forwardedRef: a
|
|
367
|
+
}));
|
|
368
|
+
return t.withRef ? U(s) : p;
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function me({
|
|
372
|
+
i18n: e,
|
|
346
373
|
i18n_default_text: t,
|
|
347
|
-
values:
|
|
348
|
-
components:
|
|
349
|
-
options:
|
|
350
|
-
shouldUnescape:
|
|
374
|
+
values: n,
|
|
375
|
+
components: o,
|
|
376
|
+
options: p,
|
|
377
|
+
shouldUnescape: s
|
|
351
378
|
}) {
|
|
352
|
-
return /* @__PURE__ */
|
|
353
|
-
|
|
379
|
+
return /* @__PURE__ */ W(
|
|
380
|
+
ce,
|
|
354
381
|
{
|
|
355
382
|
defaults: t,
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
383
|
+
i18n: e,
|
|
384
|
+
values: n,
|
|
385
|
+
components: o,
|
|
386
|
+
tOptions: p,
|
|
387
|
+
shouldUnescape: s
|
|
360
388
|
}
|
|
361
389
|
);
|
|
362
390
|
}
|
|
391
|
+
const be = fe()(me);
|
|
363
392
|
export {
|
|
364
|
-
|
|
393
|
+
be as default
|
|
365
394
|
};
|
package/dist/hooks/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import "react/jsx-runtime";
|
|
|
5
5
|
import "../crc32-LCGpXEbE.js";
|
|
6
6
|
import "../constants-C3Rdpvgf.js";
|
|
7
7
|
import "../context-f4Bcf4Hs.js";
|
|
8
|
-
import "../
|
|
8
|
+
import "../useTranslation-DWHGHs02.js";
|
|
9
9
|
import "../i18nInstance-D20fwFYr.js";
|
|
10
10
|
export {
|
|
11
11
|
l as useTranslations
|
|
@@ -1,91 +1,25 @@
|
|
|
1
|
-
import { useContext as
|
|
2
|
-
import { TranslationContext as
|
|
3
|
-
import { c
|
|
4
|
-
import {
|
|
5
|
-
import { w as R, h as A, l as C, a as L } from "../utils-6G1tiZlP.js";
|
|
6
|
-
import { g as M, b as U } from "../i18nInstance-D20fwFYr.js";
|
|
1
|
+
import { useContext as s } from "react";
|
|
2
|
+
import { TranslationContext as u } from "../provider/translation-provider.js";
|
|
3
|
+
import { c } from "../crc32-LCGpXEbE.js";
|
|
4
|
+
import { u as m } from "../useTranslation-DWHGHs02.js";
|
|
7
5
|
import "react/jsx-runtime";
|
|
8
6
|
import "../constants-C3Rdpvgf.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
function J(a) {
|
|
16
|
-
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
17
|
-
const {
|
|
18
|
-
i18n: u
|
|
19
|
-
} = t, {
|
|
20
|
-
i18n: y,
|
|
21
|
-
defaultNS: h
|
|
22
|
-
} = P(v) || {}, e = u || y || U();
|
|
23
|
-
if (e && !e.reportNamespaces && (e.reportNamespaces = new z()), !e) {
|
|
24
|
-
R("You will need to pass in an i18next instance by using initReactI18next");
|
|
25
|
-
const r = (i, s) => typeof s == "string" ? s : s && typeof s == "object" && typeof s.defaultValue == "string" ? s.defaultValue : Array.isArray(i) ? i[i.length - 1] : i, o = [r, {}, !1];
|
|
26
|
-
return o.t = r, o.i18n = {}, o.ready = !1, o;
|
|
27
|
-
}
|
|
28
|
-
e.options.react && e.options.react.wait !== void 0 && R("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
|
|
29
|
-
const f = {
|
|
30
|
-
...M(),
|
|
31
|
-
...e.options.react,
|
|
32
|
-
...t
|
|
33
|
-
}, {
|
|
34
|
-
useSuspense: x,
|
|
35
|
-
keyPrefix: S
|
|
36
|
-
} = f;
|
|
37
|
-
let n = h || e.options && e.options.defaultNS;
|
|
38
|
-
n = typeof n == "string" ? [n] : n || ["translation"], e.reportNamespaces.addUsedNamespaces && e.reportNamespaces.addUsedNamespaces(n);
|
|
39
|
-
const l = (e.isInitialized || e.initializedStoreOnce) && n.every((r) => A(r, e, f));
|
|
40
|
-
function d() {
|
|
41
|
-
return e.getFixedT(t.lng || null, f.nsMode === "fallback" ? n : n[0], S);
|
|
42
|
-
}
|
|
43
|
-
const [b, p] = E(d);
|
|
44
|
-
let m = n.join();
|
|
45
|
-
t.lng && (m = `${t.lng}${m}`);
|
|
46
|
-
const I = $(m), c = N(!0);
|
|
47
|
-
w(() => {
|
|
48
|
-
const {
|
|
49
|
-
bindI18n: r,
|
|
50
|
-
bindI18nStore: o
|
|
51
|
-
} = f;
|
|
52
|
-
c.current = !0, !l && !x && (t.lng ? C(e, t.lng, n, () => {
|
|
53
|
-
c.current && p(d);
|
|
54
|
-
}) : L(e, n, () => {
|
|
55
|
-
c.current && p(d);
|
|
56
|
-
})), l && I && I !== m && c.current && p(d);
|
|
57
|
-
function i() {
|
|
58
|
-
c.current && p(d);
|
|
59
|
-
}
|
|
60
|
-
return r && e && e.on(r, i), o && e && e.store.on(o, i), () => {
|
|
61
|
-
c.current = !1, r && e && r.split(" ").forEach((s) => e.off(s, i)), o && e && o.split(" ").forEach((s) => e.store.off(s, i));
|
|
62
|
-
};
|
|
63
|
-
}, [e, m]);
|
|
64
|
-
const T = N(!0);
|
|
65
|
-
w(() => {
|
|
66
|
-
c.current && !T.current && p(d), T.current = !1;
|
|
67
|
-
}, [e, S]);
|
|
68
|
-
const g = [b, e, l];
|
|
69
|
-
if (g.t = b, g.i18n = e, g.ready = l, l || !l && !x)
|
|
70
|
-
return g;
|
|
71
|
-
throw new Promise((r) => {
|
|
72
|
-
t.lng ? C(e, t.lng, n, () => r()) : L(e, n, () => r());
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
function X() {
|
|
76
|
-
const a = P(F), { ready: t, t: u, i18n: y } = J(), h = (e, f = {}) => u(j.str(e).toString(), { defaultValue: e, ...f });
|
|
77
|
-
if (!a)
|
|
7
|
+
import "../context-f4Bcf4Hs.js";
|
|
8
|
+
import "../i18nInstance-D20fwFYr.js";
|
|
9
|
+
function x() {
|
|
10
|
+
const t = s(u), { ready: n, t: o, i18n: a } = m(), e = (r, i = {}) => o(c.str(r).toString(), { defaultValue: r, ...i });
|
|
11
|
+
if (!t)
|
|
78
12
|
throw new Error(
|
|
79
13
|
"useTranslation has to be used within <TranslationContext.Provider>"
|
|
80
14
|
);
|
|
81
15
|
return {
|
|
82
|
-
ready:
|
|
83
|
-
localize:
|
|
84
|
-
instance:
|
|
85
|
-
switchLanguage:
|
|
86
|
-
currentLang:
|
|
16
|
+
ready: n,
|
|
17
|
+
localize: e,
|
|
18
|
+
instance: a,
|
|
19
|
+
switchLanguage: t.switchLanguage,
|
|
20
|
+
currentLang: t.currentLang
|
|
87
21
|
};
|
|
88
22
|
}
|
|
89
23
|
export {
|
|
90
|
-
|
|
24
|
+
x as default
|
|
91
25
|
};
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import "./i18nInstance-D20fwFYr.js";
|
|
|
10
10
|
import "./constants-C3Rdpvgf.js";
|
|
11
11
|
import "react/jsx-runtime";
|
|
12
12
|
import "react";
|
|
13
|
-
import "./
|
|
13
|
+
import "./useTranslation-DWHGHs02.js";
|
|
14
14
|
import "./context-f4Bcf4Hs.js";
|
|
15
15
|
export {
|
|
16
16
|
z as Localize,
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { useContext as P, useState as $, useRef as w, useEffect as x } from "react";
|
|
2
|
+
import { I as k, R as A } from "./context-f4Bcf4Hs.js";
|
|
3
|
+
import { g as E, b as F } from "./i18nInstance-D20fwFYr.js";
|
|
4
|
+
function j() {
|
|
5
|
+
if (console && console.warn) {
|
|
6
|
+
for (var n = arguments.length, e = new Array(n), a = 0; a < n; a++)
|
|
7
|
+
e[a] = arguments[a];
|
|
8
|
+
typeof e[0] == "string" && (e[0] = `react-i18next:: ${e[0]}`), console.warn(...e);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const T = {};
|
|
12
|
+
function I() {
|
|
13
|
+
for (var n = arguments.length, e = new Array(n), a = 0; a < n; a++)
|
|
14
|
+
e[a] = arguments[a];
|
|
15
|
+
typeof e[0] == "string" && T[e[0]] || (typeof e[0] == "string" && (T[e[0]] = /* @__PURE__ */ new Date()), j(...e));
|
|
16
|
+
}
|
|
17
|
+
const z = (n, e) => () => {
|
|
18
|
+
if (n.isInitialized)
|
|
19
|
+
e();
|
|
20
|
+
else {
|
|
21
|
+
const a = () => {
|
|
22
|
+
setTimeout(() => {
|
|
23
|
+
n.off("initialized", a);
|
|
24
|
+
}, 0), e();
|
|
25
|
+
};
|
|
26
|
+
n.on("initialized", a);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function v(n, e, a) {
|
|
30
|
+
n.loadNamespaces(e, z(n, a));
|
|
31
|
+
}
|
|
32
|
+
function R(n, e, a, f) {
|
|
33
|
+
typeof a == "string" && (a = [a]), a.forEach((o) => {
|
|
34
|
+
n.options.ns.indexOf(o) < 0 && n.options.ns.push(o);
|
|
35
|
+
}), n.loadLanguages(e, z(n, f));
|
|
36
|
+
}
|
|
37
|
+
function U(n, e) {
|
|
38
|
+
let a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
39
|
+
const f = e.languages[0], o = e.options ? e.options.fallbackLng : !1, t = e.languages[e.languages.length - 1];
|
|
40
|
+
if (f.toLowerCase() === "cimode")
|
|
41
|
+
return !0;
|
|
42
|
+
const g = (y, b) => {
|
|
43
|
+
const r = e.services.backendConnector.state[`${y}|${b}`];
|
|
44
|
+
return r === -1 || r === 2;
|
|
45
|
+
};
|
|
46
|
+
return a.bindI18n && a.bindI18n.indexOf("languageChanging") > -1 && e.services.backendConnector.backend && e.isLanguageChangingTo && !g(e.isLanguageChangingTo, n) ? !1 : !!(e.hasResourceBundle(f, n) || !e.services.backendConnector.backend || e.options.resources && !e.options.partialBundledLanguages || g(f, n) && (!o || g(t, n)));
|
|
47
|
+
}
|
|
48
|
+
function B(n, e) {
|
|
49
|
+
let a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
50
|
+
return !e.languages || !e.languages.length ? (I("i18n.languages were undefined or empty", e.languages), !0) : e.options.ignoreJSONStructure !== void 0 ? e.hasLoadedNamespace(n, {
|
|
51
|
+
lng: a.lng,
|
|
52
|
+
precheck: (o, t) => {
|
|
53
|
+
if (a.bindI18n && a.bindI18n.indexOf("languageChanging") > -1 && o.services.backendConnector.backend && o.isLanguageChangingTo && !t(o.isLanguageChangingTo, n))
|
|
54
|
+
return !1;
|
|
55
|
+
}
|
|
56
|
+
}) : U(n, e, a);
|
|
57
|
+
}
|
|
58
|
+
function W(n) {
|
|
59
|
+
return n.displayName || n.name || (typeof n == "string" && n.length > 0 ? n : "Unknown");
|
|
60
|
+
}
|
|
61
|
+
const J = (n, e) => {
|
|
62
|
+
const a = w();
|
|
63
|
+
return x(() => {
|
|
64
|
+
a.current = n;
|
|
65
|
+
}, [n, e]), a.current;
|
|
66
|
+
};
|
|
67
|
+
function Y(n) {
|
|
68
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
69
|
+
const {
|
|
70
|
+
i18n: a
|
|
71
|
+
} = e, {
|
|
72
|
+
i18n: f,
|
|
73
|
+
defaultNS: o
|
|
74
|
+
} = P(k) || {}, t = a || f || F();
|
|
75
|
+
if (t && !t.reportNamespaces && (t.reportNamespaces = new A()), !t) {
|
|
76
|
+
I("You will need to pass in an i18next instance by using initReactI18next");
|
|
77
|
+
const s = (c, i) => typeof i == "string" ? i : i && typeof i == "object" && typeof i.defaultValue == "string" ? i.defaultValue : Array.isArray(c) ? c[c.length - 1] : c, u = [s, {}, !1];
|
|
78
|
+
return u.t = s, u.i18n = {}, u.ready = !1, u;
|
|
79
|
+
}
|
|
80
|
+
t.options.react && t.options.react.wait !== void 0 && I("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
|
|
81
|
+
const g = {
|
|
82
|
+
...E(),
|
|
83
|
+
...t.options.react,
|
|
84
|
+
...e
|
|
85
|
+
}, {
|
|
86
|
+
useSuspense: y,
|
|
87
|
+
keyPrefix: b
|
|
88
|
+
} = g;
|
|
89
|
+
let r = o || t.options && t.options.defaultNS;
|
|
90
|
+
r = typeof r == "string" ? [r] : r || ["translation"], t.reportNamespaces.addUsedNamespaces && t.reportNamespaces.addUsedNamespaces(r);
|
|
91
|
+
const l = (t.isInitialized || t.initializedStoreOnce) && r.every((s) => B(s, t, g));
|
|
92
|
+
function p() {
|
|
93
|
+
return t.getFixedT(e.lng || null, g.nsMode === "fallback" ? r : r[0], b);
|
|
94
|
+
}
|
|
95
|
+
const [L, m] = $(p);
|
|
96
|
+
let h = r.join();
|
|
97
|
+
e.lng && (h = `${e.lng}${h}`);
|
|
98
|
+
const S = J(h), d = w(!0);
|
|
99
|
+
x(() => {
|
|
100
|
+
const {
|
|
101
|
+
bindI18n: s,
|
|
102
|
+
bindI18nStore: u
|
|
103
|
+
} = g;
|
|
104
|
+
d.current = !0, !l && !y && (e.lng ? R(t, e.lng, r, () => {
|
|
105
|
+
d.current && m(p);
|
|
106
|
+
}) : v(t, r, () => {
|
|
107
|
+
d.current && m(p);
|
|
108
|
+
})), l && S && S !== h && d.current && m(p);
|
|
109
|
+
function c() {
|
|
110
|
+
d.current && m(p);
|
|
111
|
+
}
|
|
112
|
+
return s && t && t.on(s, c), u && t && t.store.on(u, c), () => {
|
|
113
|
+
d.current = !1, s && t && s.split(" ").forEach((i) => t.off(i, c)), u && t && u.split(" ").forEach((i) => t.store.off(i, c));
|
|
114
|
+
};
|
|
115
|
+
}, [t, h]);
|
|
116
|
+
const C = w(!0);
|
|
117
|
+
x(() => {
|
|
118
|
+
d.current && !C.current && m(p), C.current = !1;
|
|
119
|
+
}, [t, b]);
|
|
120
|
+
const N = [L, t, l];
|
|
121
|
+
if (N.t = L, N.i18n = t, N.ready = l, l || !l && !y)
|
|
122
|
+
return N;
|
|
123
|
+
throw new Promise((s) => {
|
|
124
|
+
e.lng ? R(t, e.lng, r, () => s()) : v(t, r, () => s());
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
j as a,
|
|
129
|
+
W as g,
|
|
130
|
+
Y as u,
|
|
131
|
+
I as w
|
|
132
|
+
};
|
package/dist/utils/localize.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
type TLocalizeProps = {
|
|
2
|
-
i18n_default_text: string;
|
|
3
|
-
values?: object;
|
|
4
|
-
components?: JSX.Element[];
|
|
5
|
-
options?: Record<string, unknown>;
|
|
6
|
-
shouldUnescape?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export default function Localize({ i18n_default_text, values, components, options, shouldUnescape, }: TLocalizeProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export {};
|
package/dist/utils-6G1tiZlP.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
function c() {
|
|
2
|
-
if (console && console.warn) {
|
|
3
|
-
for (var a = arguments.length, e = new Array(a), n = 0; n < a; n++)
|
|
4
|
-
e[n] = arguments[n];
|
|
5
|
-
typeof e[0] == "string" && (e[0] = `react-i18next:: ${e[0]}`), console.warn(...e);
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
const u = {};
|
|
9
|
-
function f() {
|
|
10
|
-
for (var a = arguments.length, e = new Array(a), n = 0; n < a; n++)
|
|
11
|
-
e[n] = arguments[n];
|
|
12
|
-
typeof e[0] == "string" && u[e[0]] || (typeof e[0] == "string" && (u[e[0]] = /* @__PURE__ */ new Date()), c(...e));
|
|
13
|
-
}
|
|
14
|
-
const i = (a, e) => () => {
|
|
15
|
-
if (a.isInitialized)
|
|
16
|
-
e();
|
|
17
|
-
else {
|
|
18
|
-
const n = () => {
|
|
19
|
-
setTimeout(() => {
|
|
20
|
-
a.off("initialized", n);
|
|
21
|
-
}, 0), e();
|
|
22
|
-
};
|
|
23
|
-
a.on("initialized", n);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
function h(a, e, n) {
|
|
27
|
-
a.loadNamespaces(e, i(a, n));
|
|
28
|
-
}
|
|
29
|
-
function m(a, e, n, o) {
|
|
30
|
-
typeof n == "string" && (n = [n]), n.forEach((t) => {
|
|
31
|
-
a.options.ns.indexOf(t) < 0 && a.options.ns.push(t);
|
|
32
|
-
}), a.loadLanguages(e, i(a, o));
|
|
33
|
-
}
|
|
34
|
-
function p(a, e) {
|
|
35
|
-
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
36
|
-
const o = e.languages[0], t = e.options ? e.options.fallbackLng : !1, r = e.languages[e.languages.length - 1];
|
|
37
|
-
if (o.toLowerCase() === "cimode")
|
|
38
|
-
return !0;
|
|
39
|
-
const s = (l, d) => {
|
|
40
|
-
const g = e.services.backendConnector.state[`${l}|${d}`];
|
|
41
|
-
return g === -1 || g === 2;
|
|
42
|
-
};
|
|
43
|
-
return n.bindI18n && n.bindI18n.indexOf("languageChanging") > -1 && e.services.backendConnector.backend && e.isLanguageChangingTo && !s(e.isLanguageChangingTo, a) ? !1 : !!(e.hasResourceBundle(o, a) || !e.services.backendConnector.backend || e.options.resources && !e.options.partialBundledLanguages || s(o, a) && (!t || s(r, a)));
|
|
44
|
-
}
|
|
45
|
-
function b(a, e) {
|
|
46
|
-
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
47
|
-
return !e.languages || !e.languages.length ? (f("i18n.languages were undefined or empty", e.languages), !0) : e.options.ignoreJSONStructure !== void 0 ? e.hasLoadedNamespace(a, {
|
|
48
|
-
lng: n.lng,
|
|
49
|
-
precheck: (t, r) => {
|
|
50
|
-
if (n.bindI18n && n.bindI18n.indexOf("languageChanging") > -1 && t.services.backendConnector.backend && t.isLanguageChangingTo && !r(t.isLanguageChangingTo, a))
|
|
51
|
-
return !1;
|
|
52
|
-
}
|
|
53
|
-
}) : p(a, e, n);
|
|
54
|
-
}
|
|
55
|
-
export {
|
|
56
|
-
h as a,
|
|
57
|
-
c as b,
|
|
58
|
-
b as h,
|
|
59
|
-
m as l,
|
|
60
|
-
f as w
|
|
61
|
-
};
|