@deriv-com/translations 1.4.2 → 1.4.4
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/dist/chunk-CzZxQCTN.js +14 -0
- package/dist/components/index.js +1 -1
- package/dist/components/localize.js +18 -2
- package/dist/hooks/use-translations.js +9 -8
- package/dist/index.js +5 -5
- package/dist/{jsx-runtime-BJITdUlL.js → jsx-runtime-22qKqdB2.js} +7 -20
- package/dist/provider/index.js +1 -1
- package/dist/provider/translation-provider.js +27 -2
- package/dist/utils/constants.js +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/initialize-i18n.js +1 -1
- package/dist/utils/lang-utils.js +1 -1
- package/dist/utils/localize.js +2 -2
- package/dist/{utils-17GMfKvo.js → utils-CvIwp1ax.js} +15 -15
- package/package.json +5 -2
- package/dist/chunk-DeC0fbbY.js +0 -23
- package/dist/i18next-DzZwHOzH.js +0 -1202
- package/dist/initReactI18next-AIGy7ACI.js +0 -52
- package/dist/localize-CZ6EZTCG.js +0 -366
- package/dist/src/utils/__tests__/lang-utils.spec.d.ts +0 -1
- package/dist/translation-provider-DouO5SpQ.js +0 -34
- package/dist/useTranslation-Ws-GUPE_.js +0 -221
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.defineProperty, t = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), n = (t, n) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (var i in t) e(r, i, {
|
|
5
|
+
get: t[i],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
+
}, r = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
10
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
11
|
+
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
export { n, r, t };
|
package/dist/components/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from "./localize.js";
|
|
2
2
|
export { e as Localize };
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
import { t as e } from "../
|
|
2
|
-
|
|
1
|
+
import { t as e } from "../jsx-runtime-22qKqdB2.js";
|
|
2
|
+
import { Trans as t, withTranslation as n } from "react-i18next";
|
|
3
|
+
import "react";
|
|
4
|
+
//#region src/components/localize.tsx
|
|
5
|
+
var r = e();
|
|
6
|
+
function i({ i18n: e, i18n_default_text: n, values: i, components: a, options: o, shouldUnescape: s }) {
|
|
7
|
+
return /* @__PURE__ */ (0, r.jsx)(t, {
|
|
8
|
+
defaults: n,
|
|
9
|
+
i18n: e,
|
|
10
|
+
values: i,
|
|
11
|
+
components: a,
|
|
12
|
+
tOptions: o,
|
|
13
|
+
shouldUnescape: s
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
var a = n()(i);
|
|
17
|
+
//#endregion
|
|
18
|
+
export { a as default };
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
import { t } from "../
|
|
3
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as e } from "../utils/localize.js";
|
|
3
|
+
import { TranslationContext as t } from "../provider/translation-provider.js";
|
|
4
4
|
import "../provider/index.js";
|
|
5
|
+
import { useTranslation as n } from "react-i18next";
|
|
5
6
|
import { useContext as r } from "react";
|
|
6
7
|
//#region src/hooks/use-translations.ts
|
|
7
|
-
var i =
|
|
8
|
+
var i = e();
|
|
8
9
|
function a() {
|
|
9
|
-
let
|
|
10
|
+
let e = r(t), { ready: a, t: o, i18n: s } = n(), c = (e, t = {}) => o((0, i.str)(e).toString(), {
|
|
10
11
|
defaultValue: e,
|
|
11
12
|
...t
|
|
12
13
|
});
|
|
13
|
-
if (!
|
|
14
|
+
if (!e) throw Error("useTranslation has to be used within <TranslationContext.Provider>");
|
|
14
15
|
return {
|
|
15
16
|
ready: a,
|
|
16
17
|
localize: c,
|
|
17
18
|
instance: s,
|
|
18
|
-
switchLanguage:
|
|
19
|
-
currentLang:
|
|
19
|
+
switchLanguage: e.switchLanguage,
|
|
20
|
+
currentLang: e.currentLang
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
23
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import o from "./utils/localize.js";
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./utils-CvIwp1ax.js";
|
|
2
|
+
import i from "./utils/localize.js";
|
|
3
|
+
import a from "./components/localize.js";
|
|
5
4
|
import "./components/index.js";
|
|
5
|
+
import o from "./provider/translation-provider.js";
|
|
6
6
|
import "./provider/index.js";
|
|
7
7
|
import s from "./hooks/use-translations.js";
|
|
8
8
|
import "./hooks/index.js";
|
|
9
|
-
export {
|
|
9
|
+
export { a as Localize, o as TranslationProvider, r as getAllowedLanguages, t as getInitialLanguage, e as initializeI18n, n as loadIncontextTranslation, i as localize, s as useTranslations };
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import { r as e, t } from "./chunk-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var r = n(), i = class {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.usedNamespaces = {};
|
|
7
|
-
}
|
|
8
|
-
addUsedNamespaces(e) {
|
|
9
|
-
e.forEach((e) => {
|
|
10
|
-
this.usedNamespaces[e] || (this.usedNamespaces[e] = !0);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
getUsedNamespaces() {
|
|
14
|
-
return Object.keys(this.usedNamespaces);
|
|
15
|
-
}
|
|
16
|
-
}, a = /* @__PURE__ */ t(((e) => {
|
|
1
|
+
import { r as e, t } from "./chunk-CzZxQCTN.js";
|
|
2
|
+
//#region node_modules/react/cjs/react-jsx-runtime.production.js
|
|
3
|
+
var n = /* @__PURE__ */ t(((e) => {
|
|
17
4
|
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
18
5
|
function r(e, n, r) {
|
|
19
6
|
var i = null;
|
|
@@ -28,7 +15,7 @@ var r = n(), i = class {
|
|
|
28
15
|
};
|
|
29
16
|
}
|
|
30
17
|
e.Fragment = n, e.jsx = r, e.jsxs = r;
|
|
31
|
-
})),
|
|
18
|
+
})), r = /* @__PURE__ */ t(((t) => {
|
|
32
19
|
process.env.NODE_ENV !== "production" && (function() {
|
|
33
20
|
function n(e) {
|
|
34
21
|
if (e == null) return null;
|
|
@@ -186,8 +173,8 @@ var r = n(), i = class {
|
|
|
186
173
|
return f(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(a(e)) : L);
|
|
187
174
|
};
|
|
188
175
|
})();
|
|
189
|
-
})),
|
|
190
|
-
process.env.NODE_ENV === "production" ? t.exports =
|
|
176
|
+
})), i = /* @__PURE__ */ t(((e, t) => {
|
|
177
|
+
process.env.NODE_ENV === "production" ? t.exports = n() : t.exports = r();
|
|
191
178
|
}));
|
|
192
179
|
//#endregion
|
|
193
|
-
export {
|
|
180
|
+
export { i as t };
|
package/dist/provider/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import e, { TranslationContext as t } from "./translation-provider.js";
|
|
2
2
|
export { t as TranslationContext, e as TranslationProvider };
|
|
@@ -1,2 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import "../utils-CvIwp1ax.js";
|
|
3
|
+
import { LANGUAGE_KEY as e } from "../utils/constants.js";
|
|
4
|
+
import { t } from "../jsx-runtime-22qKqdB2.js";
|
|
5
|
+
import { I18nextProvider as n } from "react-i18next";
|
|
6
|
+
import { createContext as r, useEffect as i, useState as a } from "react";
|
|
7
|
+
//#region src/provider/translation-provider.tsx
|
|
8
|
+
var o = t(), s = r(null);
|
|
9
|
+
function c({ defaultLang: t, i18nInstance: r, children: c }) {
|
|
10
|
+
let [l, u] = a(t || ""), [d, f] = a(!1);
|
|
11
|
+
return i(() => {
|
|
12
|
+
r && (u(r.language || t || ""), f(!0));
|
|
13
|
+
}, [r, t]), !r || !d ? null : /* @__PURE__ */ (0, o.jsx)(n, {
|
|
14
|
+
i18n: r,
|
|
15
|
+
children: /* @__PURE__ */ (0, o.jsx)(s.Provider, {
|
|
16
|
+
value: {
|
|
17
|
+
currentLang: l,
|
|
18
|
+
switchLanguage: (t) => {
|
|
19
|
+
r.changeLanguage(t), u(t), localStorage.setItem(e, JSON.stringify(t));
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
children: c
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { s as TranslationContext, c as default };
|
package/dist/utils/constants.js
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as e } from "../utils-
|
|
1
|
+
import { i as e } from "../utils-CvIwp1ax.js";
|
|
2
2
|
export { e as default };
|
package/dist/utils/lang-utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "../utils-
|
|
1
|
+
import { n as e, r as t, t as n } from "../utils-CvIwp1ax.js";
|
|
2
2
|
export { n as getAllowedLanguages, e as getInitialLanguage, t as loadIncontextTranslation };
|
package/dist/utils/localize.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as e } from "./
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
import { t as e } from "./utils/localize.js";
|
|
2
|
+
import t from "./utils/otasdk.js";
|
|
3
|
+
import { ALL_LANGUAGES as n, LANGUAGE_KEY as r } from "./utils/constants.js";
|
|
4
|
+
import i from "i18next";
|
|
5
|
+
import { initReactI18next as a } from "react-i18next";
|
|
6
6
|
//#region src/utils/initialize-i18n.ts
|
|
7
|
-
var o =
|
|
7
|
+
var o = e(), s = ({ useSuspense: e, enableDebug: t }) => ({
|
|
8
8
|
react: {
|
|
9
9
|
hashTransKey(e) {
|
|
10
10
|
return (0, o.str)(e);
|
|
@@ -16,25 +16,25 @@ var o = n(), s = ({ useSuspense: e, enableDebug: t }) => ({
|
|
|
16
16
|
fallbackLng: "EN",
|
|
17
17
|
interpolation: { escapeValue: !1 }
|
|
18
18
|
});
|
|
19
|
-
function c({ cdnUrl:
|
|
20
|
-
let o = new
|
|
21
|
-
useSuspense:
|
|
22
|
-
enableDebug:
|
|
19
|
+
function c({ cdnUrl: e, useSuspense: n = !0, enableDebug: r = !1 }) {
|
|
20
|
+
let o = new t(e), c = l(), u = s({
|
|
21
|
+
useSuspense: n,
|
|
22
|
+
enableDebug: r
|
|
23
23
|
});
|
|
24
|
-
return
|
|
24
|
+
return i.use(o).use(a).init({
|
|
25
25
|
...u,
|
|
26
26
|
lng: c
|
|
27
|
-
}),
|
|
27
|
+
}), i;
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/utils/lang-utils.ts
|
|
31
31
|
var l = () => {
|
|
32
32
|
let e = new URLSearchParams(window.location.search).get("lang"), t = localStorage.getItem("i18n_language") ?? "\"EN\"";
|
|
33
|
-
/^".*"$/.test(t) || (localStorage.setItem(
|
|
33
|
+
/^".*"$/.test(t) || (localStorage.setItem(r, JSON.stringify(t)), t = localStorage.getItem(r));
|
|
34
34
|
let n = JSON.parse(t);
|
|
35
35
|
if (e) {
|
|
36
36
|
let t = e.toUpperCase();
|
|
37
|
-
return localStorage.setItem(
|
|
37
|
+
return localStorage.setItem(r, JSON.stringify(t)), t;
|
|
38
38
|
}
|
|
39
39
|
return n || "EN";
|
|
40
40
|
}, u = (e) => {
|
|
@@ -44,7 +44,7 @@ var l = () => {
|
|
|
44
44
|
}
|
|
45
45
|
}, d = (e = []) => {
|
|
46
46
|
let t = ["ACH", ...e];
|
|
47
|
-
return Object.keys(
|
|
47
|
+
return Object.keys(n).filter((e) => !t.includes(e)).reduce((e, t) => (e[t] = n[t], e), {});
|
|
48
48
|
};
|
|
49
49
|
//#endregion
|
|
50
50
|
export { c as i, l as n, u as r, d as t };
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"deriv-extract-translations": "./dist/deriv-extract-translations.cjs"
|
|
11
11
|
},
|
|
12
12
|
"private": false,
|
|
13
|
-
"version": "1.4.
|
|
13
|
+
"version": "1.4.4",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"dev": "vite",
|
|
16
16
|
"build": "tsc && vite build && cp ./src/scripts/deriv-extract-translations.cjs ./dist/deriv-extract-translations.cjs",
|
|
@@ -19,8 +19,10 @@
|
|
|
19
19
|
"prepublish": "npm run test && npm run build"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
+
"i18next": ">=23.0.0",
|
|
22
23
|
"react": "^17.x || ^18.x",
|
|
23
|
-
"react-dom": "^17.x || ^18.x"
|
|
24
|
+
"react-dom": "^17.x || ^18.x",
|
|
25
|
+
"react-i18next": ">=14.0.0"
|
|
24
26
|
},
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"@babel/core": "^7.29.0",
|
|
@@ -31,6 +33,7 @@
|
|
|
31
33
|
"@testing-library/jest-dom": "^6.9.1",
|
|
32
34
|
"@testing-library/react": "^16.3.2",
|
|
33
35
|
"@testing-library/user-event": "^14.6.1",
|
|
36
|
+
"@types/node": "^25.6.0",
|
|
34
37
|
"@types/react": "^19.2.14",
|
|
35
38
|
"@types/react-dom": "^19.2.3",
|
|
36
39
|
"@typescript-eslint/eslint-plugin": "^8.58.0",
|
package/dist/chunk-DeC0fbbY.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), s = (e, n) => {
|
|
3
|
-
let r = {};
|
|
4
|
-
for (var i in e) t(r, i, {
|
|
5
|
-
get: e[i],
|
|
6
|
-
enumerable: !0
|
|
7
|
-
});
|
|
8
|
-
return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
-
}, c = (e, i, o, s) => {
|
|
10
|
-
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
11
|
-
get: ((e) => i[e]).bind(null, d),
|
|
12
|
-
enumerable: !(s = n(i, d)) || s.enumerable
|
|
13
|
-
});
|
|
14
|
-
return e;
|
|
15
|
-
}, l = (n, r, a) => (a = n == null ? {} : e(i(n)), c(r || !n || !n.__esModule ? t(a, "default", {
|
|
16
|
-
value: n,
|
|
17
|
-
enumerable: !0
|
|
18
|
-
}) : a, n)), u = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
19
|
-
if (typeof require < "u") return require.apply(this, arguments);
|
|
20
|
-
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
21
|
-
});
|
|
22
|
-
//#endregion
|
|
23
|
-
export { l as i, s as n, u as r, o as t };
|