@deriv-com/translations 1.3.5 → 1.3.7

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,40 @@
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";
1
+ import { I as f, j as s } from "../jsx-runtime-ClgrxkDP.js";
2
+ import { useMemo as g, createElement as m, createContext as d, useState as i, useEffect as x } from "react";
3
3
  import "../crc32-LCGpXEbE.js";
4
4
  import { L } from "../constants-D-_KboaS.js";
5
5
  function p(t) {
6
6
  let {
7
7
  i18n: e,
8
8
  defaultNS: o,
9
- children: n
9
+ children: a
10
10
  } = t;
11
- const a = d(() => ({
11
+ const n = g(() => ({
12
12
  i18n: e,
13
13
  defaultNS: o
14
14
  }), [e, o]);
15
- return f(m.Provider, {
16
- value: a
17
- }, n);
15
+ return m(f.Provider, {
16
+ value: n
17
+ }, a);
18
18
  }
19
- const v = g(null);
19
+ const v = d(null);
20
20
  function P({
21
21
  defaultLang: t,
22
22
  i18nInstance: e,
23
23
  children: o
24
24
  }) {
25
- const [n, a] = u(t || ""), [i, l] = u(!1), c = (r) => {
26
- e.changeLanguage(r), a(r), localStorage.setItem(L, r);
25
+ const [a, n] = i(t || ""), [u, l] = i(!1), c = (r) => {
26
+ e.changeLanguage(r), n(r), localStorage.setItem(L, JSON.stringify(r));
27
27
  };
28
28
  return x(() => {
29
29
  if (e) {
30
30
  const r = e.language || t || "";
31
- a(r), l(!0);
31
+ n(r), l(!0);
32
32
  }
33
- }, [e, t]), !e || !i ? null : /* @__PURE__ */ s.jsx(p, { i18n: e, children: /* @__PURE__ */ s.jsx(
33
+ }, [e, t]), !e || !u ? null : /* @__PURE__ */ s.jsx(p, { i18n: e, children: /* @__PURE__ */ s.jsx(
34
34
  v.Provider,
35
35
  {
36
36
  value: {
37
- currentLang: n,
37
+ currentLang: a,
38
38
  switchLanguage: c
39
39
  },
40
40
  children: o
@@ -1,6 +1,6 @@
1
1
  import { constants } from './index';
2
2
  type LanguageCode = keyof typeof constants.ALL_LANGUAGES;
3
- export declare const getInitialLanguage: () => string;
3
+ export declare const getInitialLanguage: () => any;
4
4
  export declare const loadIncontextTranslation: (lang: LanguageCode) => void;
5
5
  /**
6
6
  * Filter out unsupported languages and return an Object containing language code and language name
@@ -1,13 +1,16 @@
1
1
  import "../crc32-LCGpXEbE.js";
2
- import { L as c, D as s, A as o } from "../constants-D-_KboaS.js";
3
- const l = () => {
4
- const a = new URLSearchParams(window.location.search).get("lang"), t = localStorage.getItem(c);
2
+ import { L as s, D as c, A as o } from "../constants-D-_KboaS.js";
3
+ const p = () => {
4
+ const a = new URLSearchParams(window.location.search).get("lang");
5
+ let t = localStorage.getItem(s) ?? '"EN"';
6
+ /^".*"$/.test(t) || (localStorage.setItem(s, JSON.stringify(t)), t = localStorage.getItem(s));
7
+ const e = JSON.parse(t);
5
8
  if (a) {
6
- const e = a.toUpperCase();
7
- return localStorage.setItem(c, e), e;
9
+ const r = a.toUpperCase();
10
+ return localStorage.setItem(s, JSON.stringify(r)), r;
8
11
  }
9
- return t || s;
10
- }, u = (n) => {
12
+ return e || c;
13
+ }, g = (n) => {
11
14
  if (n.toUpperCase() === "ACH") {
12
15
  const t = document.createElement("script");
13
16
  t.type = "text/javascript", t.text = `
@@ -17,12 +20,12 @@ const l = () => {
17
20
  document.head.appendChild(crowdin);
18
21
  `, document.head.appendChild(t);
19
22
  }
20
- }, d = (n = []) => {
23
+ }, u = (n = []) => {
21
24
  const a = ["ACH", ...n];
22
25
  return Object.keys(o).filter((e) => !a.includes(e)).reduce((e, r) => (e[r] = o[r], e), {});
23
26
  };
24
27
  export {
25
- d as getAllowedLanguages,
26
- l as getInitialLanguage,
27
- u as loadIncontextTranslation
28
+ u as getAllowedLanguages,
29
+ p as getInitialLanguage,
30
+ g as loadIncontextTranslation
28
31
  };
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.3.5",
13
+ "version": "1.3.7",
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",