@deriv-com/translations 1.3.1 → 1.3.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/dist/components/index.js +4 -5
- package/dist/components/localize.js +44 -45
- package/dist/{constants-C3Rdpvgf.js → constants-IFi5pBQh.js} +13 -8
- package/dist/hooks/index.js +5 -6
- package/dist/hooks/use-translations.js +7 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -12
- package/dist/jsx-runtime-ClgrxkDP.js +639 -0
- package/dist/provider/index.js +4 -5
- package/dist/provider/translation-provider.js +15 -18
- package/dist/{useTranslation-DWHGHs02.js → useTranslation-De5US25M.js} +1 -1
- package/dist/utils/__tests__/lang-utils.spec.d.ts +1 -0
- package/dist/utils/constants.d.ts +7 -2
- package/dist/utils/constants.js +1 -1
- package/dist/utils/index.js +6 -5
- package/dist/utils/initialize-i18n.d.ts +8 -2
- package/dist/utils/initialize-i18n.js +21 -17
- package/dist/utils/lang-utils.d.ts +11 -1
- package/dist/utils/lang-utils.js +15 -11
- package/package.json +1 -7
- package/dist/context-f4Bcf4Hs.js +0 -19
|
@@ -1,40 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useMemo as
|
|
1
|
+
import { I as m, j as s } from "../jsx-runtime-ClgrxkDP.js";
|
|
2
|
+
import { useMemo as d, createElement as f, createContext as g, useState as u, useEffect as x } from "react";
|
|
3
3
|
import "../crc32-LCGpXEbE.js";
|
|
4
|
-
import { L } from "../constants-
|
|
5
|
-
|
|
6
|
-
function v(t) {
|
|
4
|
+
import { L } from "../constants-IFi5pBQh.js";
|
|
5
|
+
function p(t) {
|
|
7
6
|
let {
|
|
8
7
|
i18n: e,
|
|
9
8
|
defaultNS: o,
|
|
10
9
|
children: n
|
|
11
10
|
} = t;
|
|
12
|
-
const a =
|
|
11
|
+
const a = d(() => ({
|
|
13
12
|
i18n: e,
|
|
14
13
|
defaultNS: o
|
|
15
14
|
}), [e, o]);
|
|
16
|
-
return
|
|
15
|
+
return f(m.Provider, {
|
|
17
16
|
value: a
|
|
18
17
|
}, n);
|
|
19
18
|
}
|
|
20
|
-
const
|
|
21
|
-
function
|
|
19
|
+
const v = g(null);
|
|
20
|
+
function P({
|
|
22
21
|
defaultLang: t,
|
|
23
22
|
i18nInstance: e,
|
|
24
23
|
children: o
|
|
25
24
|
}) {
|
|
26
|
-
const [n, a] = u(t || ""), [
|
|
25
|
+
const [n, a] = u(t || ""), [i, l] = u(!1), c = (r) => {
|
|
27
26
|
e.changeLanguage(r), a(r), localStorage.setItem(L, r);
|
|
28
27
|
};
|
|
29
|
-
return
|
|
28
|
+
return x(() => {
|
|
30
29
|
if (e) {
|
|
31
30
|
const r = e.language || t || "";
|
|
32
|
-
a(r),
|
|
33
|
-
l(!0);
|
|
34
|
-
});
|
|
31
|
+
a(r), l(!0);
|
|
35
32
|
}
|
|
36
|
-
}, [e, t]), !e || !
|
|
37
|
-
|
|
33
|
+
}, [e, t]), !e || !i ? null : /* @__PURE__ */ s.jsx(p, { i18n: e, children: /* @__PURE__ */ s.jsx(
|
|
34
|
+
v.Provider,
|
|
38
35
|
{
|
|
39
36
|
value: {
|
|
40
37
|
currentLang: n,
|
|
@@ -45,6 +42,6 @@ function S({
|
|
|
45
42
|
) });
|
|
46
43
|
}
|
|
47
44
|
export {
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
v as TranslationContext,
|
|
46
|
+
P as default
|
|
50
47
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContext as P, useState as $, useRef as w, useEffect as x } from "react";
|
|
2
|
-
import { I as k, R as A } from "./
|
|
2
|
+
import { I as k, R as A } from "./jsx-runtime-ClgrxkDP.js";
|
|
3
3
|
import { g as E, b as F } from "./i18nInstance-D20fwFYr.js";
|
|
4
4
|
function j() {
|
|
5
5
|
if (console && console.warn) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
export declare const ALL_LANGUAGES: Readonly<{
|
|
2
2
|
ACH: "Translations";
|
|
3
3
|
EN: "English";
|
|
4
|
-
|
|
4
|
+
AR: "العربية";
|
|
5
|
+
BN: "বাংলা";
|
|
5
6
|
DE: "Deutsch";
|
|
7
|
+
ES: "Español";
|
|
6
8
|
FR: "Français";
|
|
7
9
|
ID: "Indonesian";
|
|
8
10
|
IT: "Italiano";
|
|
11
|
+
SW: "Kiswahili";
|
|
9
12
|
KO: "한국어";
|
|
13
|
+
MN: "Монгол";
|
|
10
14
|
PL: "Polish";
|
|
11
15
|
PT: "Português";
|
|
12
16
|
RU: "Русский";
|
|
17
|
+
SI: "සිංහල";
|
|
18
|
+
TH: "ไทย";
|
|
13
19
|
TR: "Türkçe";
|
|
14
20
|
VI: "Tiếng Việt";
|
|
15
21
|
ZH_CN: "简体中文";
|
|
16
22
|
ZH_TW: "繁體中文";
|
|
17
|
-
TH: "ไทย";
|
|
18
23
|
}>;
|
|
19
24
|
export declare const LANGUAGE_KEY = "i18n_language";
|
|
20
25
|
export declare const DEFAULT_LANGUAGE = "EN";
|
package/dist/utils/constants.js
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { default as r } from "./initialize-i18n.js";
|
|
2
2
|
import { default as n } from "./localize.js";
|
|
3
3
|
import { default as f } from "./otasdk.js";
|
|
4
|
-
import { c as
|
|
5
|
-
import { getInitialLanguage as
|
|
4
|
+
import { c as m } from "../constants-IFi5pBQh.js";
|
|
5
|
+
import { getAllowedLanguages as d, getInitialLanguage as g, loadIncontextTranslation as x } from "./lang-utils.js";
|
|
6
6
|
import "../crc32-LCGpXEbE.js";
|
|
7
7
|
import "../i18nInstance-D20fwFYr.js";
|
|
8
8
|
export {
|
|
9
9
|
f as OtaSdk,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
m as constants,
|
|
11
|
+
d as getAllowedLanguages,
|
|
12
|
+
g as getInitialLanguage,
|
|
12
13
|
r as initializeI18n,
|
|
13
|
-
|
|
14
|
+
x as loadIncontextTranslation,
|
|
14
15
|
n as localize
|
|
15
16
|
};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { InitOptions } from "i18next";
|
|
2
|
+
type TInstanceConfig = {
|
|
3
|
+
useSuspense?: Exclude<InitOptions["react"], undefined>["useSuspense"];
|
|
4
|
+
enableDebug?: InitOptions["debug"];
|
|
5
|
+
};
|
|
6
|
+
export default function initializeI18n({ cdnUrl, useSuspense, enableDebug, }: {
|
|
2
7
|
cdnUrl: string;
|
|
3
|
-
}): import("i18next").i18n;
|
|
8
|
+
} & TInstanceConfig): import("i18next").i18n;
|
|
9
|
+
export {};
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
import { i
|
|
2
|
-
import
|
|
3
|
-
import { getInitialLanguage as
|
|
4
|
-
import { s as
|
|
5
|
-
import "../constants-
|
|
6
|
-
const
|
|
1
|
+
import { i, c as o } from "../crc32-LCGpXEbE.js";
|
|
2
|
+
import c from "./otasdk.js";
|
|
3
|
+
import { getInitialLanguage as l } from "./lang-utils.js";
|
|
4
|
+
import { s as u, a as f } from "../i18nInstance-D20fwFYr.js";
|
|
5
|
+
import "../constants-IFi5pBQh.js";
|
|
6
|
+
const m = {
|
|
7
7
|
type: "3rdParty",
|
|
8
8
|
init(t) {
|
|
9
|
-
|
|
9
|
+
u(t.options.react), f(t);
|
|
10
10
|
}
|
|
11
|
-
},
|
|
11
|
+
}, g = ({ useSuspense: t, enableDebug: e }) => ({
|
|
12
12
|
react: {
|
|
13
|
-
hashTransKey(
|
|
14
|
-
return
|
|
13
|
+
hashTransKey(n) {
|
|
14
|
+
return o.str(n);
|
|
15
15
|
},
|
|
16
|
-
useSuspense:
|
|
16
|
+
useSuspense: t
|
|
17
17
|
},
|
|
18
|
-
debug:
|
|
18
|
+
debug: e,
|
|
19
19
|
initImmediate: !0,
|
|
20
20
|
fallbackLng: "EN",
|
|
21
21
|
interpolation: {
|
|
22
22
|
escapeValue: !1
|
|
23
23
|
}
|
|
24
|
-
};
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
});
|
|
25
|
+
function b({
|
|
26
|
+
cdnUrl: t,
|
|
27
|
+
useSuspense: e = !0,
|
|
28
|
+
enableDebug: n = !1
|
|
29
|
+
}) {
|
|
30
|
+
const a = new c(t), r = l(), s = g({ useSuspense: e, enableDebug: n });
|
|
31
|
+
return i.use(a).use(m).init({ ...s, lng: r }), i;
|
|
28
32
|
}
|
|
29
33
|
export {
|
|
30
|
-
|
|
34
|
+
b as default
|
|
31
35
|
};
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import { constants } from './index';
|
|
2
|
+
type LanguageCode = keyof typeof constants.ALL_LANGUAGES;
|
|
2
3
|
export declare const getInitialLanguage: () => string;
|
|
3
|
-
export declare const loadIncontextTranslation: (lang:
|
|
4
|
+
export declare const loadIncontextTranslation: (lang: LanguageCode) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Filter out unsupported languages and return an Object containing language code and language name
|
|
7
|
+
* @param excludedLanguages
|
|
8
|
+
* @returns Object containing language code and language name
|
|
9
|
+
*/
|
|
10
|
+
export declare const getAllowedLanguages: (excludedLanguages?: Omit<LanguageCode, "ACH">[]) => {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
package/dist/utils/lang-utils.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import "../crc32-LCGpXEbE.js";
|
|
2
|
-
import { L as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
if (
|
|
6
|
-
const
|
|
7
|
-
return localStorage.setItem(
|
|
2
|
+
import { L as c, D as s, A as o } from "../constants-IFi5pBQh.js";
|
|
3
|
+
const l = () => {
|
|
4
|
+
const a = new URLSearchParams(window.location.search).get("lang"), t = localStorage.getItem(c);
|
|
5
|
+
if (a) {
|
|
6
|
+
const e = a.toUpperCase();
|
|
7
|
+
return localStorage.setItem(c, e), e;
|
|
8
8
|
}
|
|
9
|
-
return t ||
|
|
10
|
-
},
|
|
11
|
-
if (
|
|
9
|
+
return t || s;
|
|
10
|
+
}, u = (n) => {
|
|
11
|
+
if (n.toUpperCase() === "ACH") {
|
|
12
12
|
const t = document.createElement("script");
|
|
13
13
|
t.type = "text/javascript", t.text = `
|
|
14
14
|
var _jipt = []; _jipt.push(['project', 'deriv-app']);
|
|
@@ -17,8 +17,12 @@ const i = () => {
|
|
|
17
17
|
document.head.appendChild(crowdin);
|
|
18
18
|
`, document.head.appendChild(t);
|
|
19
19
|
}
|
|
20
|
+
}, d = (n = []) => {
|
|
21
|
+
const a = ["ACH", ...n];
|
|
22
|
+
return Object.keys(o).filter((e) => !a.includes(e)).reduce((e, r) => (e[r] = o[r], e), {});
|
|
20
23
|
};
|
|
21
24
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
d as getAllowedLanguages,
|
|
26
|
+
l as getInitialLanguage,
|
|
27
|
+
u as loadIncontextTranslation
|
|
24
28
|
};
|
package/package.json
CHANGED
|
@@ -9,14 +9,8 @@
|
|
|
9
9
|
"bin": {
|
|
10
10
|
"deriv-extract-translations": "./dist/deriv-extract-translations.cjs"
|
|
11
11
|
},
|
|
12
|
-
"exports": {
|
|
13
|
-
".": {
|
|
14
|
-
"import": "./dist/index.js",
|
|
15
|
-
"types": "./dist/index.d.ts"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
12
|
"private": false,
|
|
19
|
-
"version": "1.3.
|
|
13
|
+
"version": "1.3.3",
|
|
20
14
|
"scripts": {
|
|
21
15
|
"dev": "vite",
|
|
22
16
|
"build": "tsc && vite build && cp ./src/scripts/deriv-extract-translations.cjs ./dist/deriv-extract-translations.cjs",
|
package/dist/context-f4Bcf4Hs.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createContext as a } from "react";
|
|
2
|
-
const r = a();
|
|
3
|
-
class o {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.usedNamespaces = {};
|
|
6
|
-
}
|
|
7
|
-
addUsedNamespaces(s) {
|
|
8
|
-
s.forEach((e) => {
|
|
9
|
-
this.usedNamespaces[e] || (this.usedNamespaces[e] = !0);
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
getUsedNamespaces() {
|
|
13
|
-
return Object.keys(this.usedNamespaces);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export {
|
|
17
|
-
r as I,
|
|
18
|
-
o as R
|
|
19
|
-
};
|