@deriv-com/translations 1.3.1 → 1.3.2

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.
@@ -1,40 +1,37 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { useMemo as m, createElement as d, createContext as f, useState as u, useEffect as g } from "react";
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-C3Rdpvgf.js";
5
- import { I as p } from "../context-f4Bcf4Hs.js";
6
- function v(t) {
4
+ import { L } from "../constants-BZU6eCHC.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 = m(() => ({
11
+ const a = d(() => ({
13
12
  i18n: e,
14
13
  defaultNS: o
15
14
  }), [e, o]);
16
- return d(p.Provider, {
15
+ return f(m.Provider, {
17
16
  value: a
18
17
  }, n);
19
18
  }
20
- const x = f(null);
21
- function S({
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 || ""), [s, l] = u(!1), c = (r) => {
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 g(() => {
28
+ return x(() => {
30
29
  if (e) {
31
30
  const r = e.language || t || "";
32
- a(r), e.on("initialized", () => {
33
- l(!0);
34
- });
31
+ a(r), l(!0);
35
32
  }
36
- }, [e, t]), !e || !s ? null : /* @__PURE__ */ i(v, { i18n: e, children: /* @__PURE__ */ i(
37
- x.Provider,
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
- x as TranslationContext,
49
- S as default
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 "./context-f4Bcf4Hs.js";
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,24 @@
1
1
  export declare const ALL_LANGUAGES: Readonly<{
2
2
  ACH: "Translations";
3
3
  EN: "English";
4
- ES: "Español";
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: "한국어";
10
13
  PL: "Polish";
11
14
  PT: "Português";
12
15
  RU: "Русский";
16
+ SI: "සිංහල";
17
+ TH: "ไทย";
13
18
  TR: "Türkçe";
14
19
  VI: "Tiếng Việt";
15
20
  ZH_CN: "简体中文";
16
21
  ZH_TW: "繁體中文";
17
- TH: "ไทย";
18
22
  }>;
19
23
  export declare const LANGUAGE_KEY = "i18n_language";
20
24
  export declare const DEFAULT_LANGUAGE = "EN";
@@ -1,4 +1,4 @@
1
- import { A as G, D as E, L as U } from "../constants-C3Rdpvgf.js";
1
+ import { A as G, D as E, L as U } from "../constants-BZU6eCHC.js";
2
2
  export {
3
3
  G as ALL_LANGUAGES,
4
4
  E as DEFAULT_LANGUAGE,
@@ -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 p } from "../constants-C3Rdpvgf.js";
5
- import { getInitialLanguage as x, loadIncontextTranslation as d } from "./lang-utils.js";
4
+ import { c as m } from "../constants-BZU6eCHC.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
- p as constants,
11
- x as getInitialLanguage,
10
+ m as constants,
11
+ d as getAllowedLanguages,
12
+ g as getInitialLanguage,
12
13
  r as initializeI18n,
13
- d as loadIncontextTranslation,
14
+ x as loadIncontextTranslation,
14
15
  n as localize
15
16
  };
@@ -1,3 +1,9 @@
1
- export default function initializeI18n({ cdnUrl }: {
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 as e, c as i } from "../crc32-LCGpXEbE.js";
2
- import s from "./otasdk.js";
3
- import { getInitialLanguage as r } from "./lang-utils.js";
4
- import { s as o, a as u } from "../i18nInstance-D20fwFYr.js";
5
- import "../constants-C3Rdpvgf.js";
6
- const c = {
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-BZU6eCHC.js";
6
+ const m = {
7
7
  type: "3rdParty",
8
8
  init(t) {
9
- o(t.options.react), u(t);
9
+ u(t.options.react), f(t);
10
10
  }
11
- }, l = {
11
+ }, g = ({ useSuspense: t, enableDebug: e }) => ({
12
12
  react: {
13
- hashTransKey(t) {
14
- return i.str(t);
13
+ hashTransKey(n) {
14
+ return o.str(n);
15
15
  },
16
- useSuspense: !0
16
+ useSuspense: t
17
17
  },
18
- debug: !1,
18
+ debug: e,
19
19
  initImmediate: !0,
20
20
  fallbackLng: "EN",
21
21
  interpolation: {
22
22
  escapeValue: !1
23
23
  }
24
- };
25
- function d({ cdnUrl: t }) {
26
- const n = new s(t), a = r();
27
- return e.use(n).use(c).init({ ...l, lng: a }), e;
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
- d as default
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: keyof typeof constants.ALL_LANGUAGES) => void;
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 {};
@@ -1,14 +1,14 @@
1
1
  import "../crc32-LCGpXEbE.js";
2
- import { L as n, D as o } from "../constants-C3Rdpvgf.js";
3
- const i = () => {
4
- const e = new URLSearchParams(window.location.search).get("lang"), t = localStorage.getItem(n);
5
- if (e) {
6
- const r = e.toUpperCase();
7
- return localStorage.setItem(n, r), r;
2
+ import { L as c, D as s, A as o } from "../constants-BZU6eCHC.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 || o;
10
- }, p = (a) => {
11
- if (a.toUpperCase() === "ACH") {
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
- i as getInitialLanguage,
23
- p as loadIncontextTranslation
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.1",
13
+ "version": "1.3.2",
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",
@@ -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
- };