@deriv-com/translations 1.4.2 → 1.4.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.
@@ -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 };
@@ -1,2 +1,2 @@
1
- import { t as e } from "../localize-CZ6EZTCG.js";
1
+ import e from "./localize.js";
2
2
  export { e as Localize };
@@ -1,2 +1,18 @@
1
- import { t as e } from "../localize-CZ6EZTCG.js";
2
- export { e as default };
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
- import { t as e } from "../useTranslation-Ws-GUPE_.js";
2
- import { t } from "../translation-provider-DouO5SpQ.js";
3
- import { t as n } from "../utils/localize.js";
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 = n();
8
+ var i = e();
8
9
  function a() {
9
- let n = r(t), { ready: a, t: o, i18n: s } = e(), c = (e, t = {}) => o((0, i.str)(e).toString(), {
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 (!n) throw Error("useTranslation has to be used within <TranslationContext.Provider>");
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: n.switchLanguage,
19
- currentLang: n.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 { t as e } from "./localize-CZ6EZTCG.js";
2
- import { n as t } from "./translation-provider-DouO5SpQ.js";
3
- import { i as n, n as r, r as i, t as a } from "./utils-17GMfKvo.js";
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 { e as Localize, t as TranslationProvider, a as getAllowedLanguages, r as getInitialLanguage, n as initializeI18n, i as loadIncontextTranslation, o as localize, s as useTranslations };
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-DeC0fbbY.js";
2
- import { createContext as n } from "react";
3
- //#region node_modules/react-i18next/dist/es/context.js
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
- })), o = /* @__PURE__ */ t(((t) => {
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
- })), s = /* @__PURE__ */ t(((e, t) => {
190
- process.env.NODE_ENV === "production" ? t.exports = a() : t.exports = o();
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 { r as n, i as r, s as t };
180
+ export { i as t };
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "../translation-provider-DouO5SpQ.js";
1
+ import e, { TranslationContext as t } from "./translation-provider.js";
2
2
  export { t as TranslationContext, e as TranslationProvider };
@@ -1,2 +1,27 @@
1
- import { n as e, t } from "../translation-provider-DouO5SpQ.js";
2
- export { t as TranslationContext, e as default };
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 };
@@ -1,4 +1,4 @@
1
- import { n as e } from "../chunk-DeC0fbbY.js";
1
+ import { n as e } from "../chunk-CzZxQCTN.js";
2
2
  //#region src/utils/constants.ts
3
3
  var t = /* @__PURE__ */ e({
4
4
  ALL_LANGUAGES: () => n,
@@ -1,4 +1,4 @@
1
- import { i as e, n as t, r as n, t as r } from "../utils-17GMfKvo.js";
1
+ import { i as e, n as t, r as n, t as r } from "../utils-CvIwp1ax.js";
2
2
  import i from "./localize.js";
3
3
  import a from "./otasdk.js";
4
4
  import { t as o } from "./constants.js";
@@ -1,2 +1,2 @@
1
- import { i as e } from "../utils-17GMfKvo.js";
1
+ import { i as e } from "../utils-CvIwp1ax.js";
2
2
  export { e as default };
@@ -1,2 +1,2 @@
1
- import { n as e, r as t, t as n } from "../utils-17GMfKvo.js";
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 };
@@ -1,5 +1,5 @@
1
- import { t as e } from "../chunk-DeC0fbbY.js";
2
- import { t } from "../i18next-DzZwHOzH.js";
1
+ import { t as e } from "../chunk-CzZxQCTN.js";
2
+ import t from "i18next";
3
3
  //#region node_modules/crc-32/crc32.js
4
4
  var n = /* @__PURE__ */ e(((e) => {
5
5
  (function(t) {
@@ -1,10 +1,10 @@
1
- import { t as e } from "./i18next-DzZwHOzH.js";
2
- import { t } from "./initReactI18next-AIGy7ACI.js";
3
- import { t as n } from "./utils/localize.js";
4
- import r from "./utils/otasdk.js";
5
- import { ALL_LANGUAGES as i, LANGUAGE_KEY as a } from "./utils/constants.js";
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 = n(), s = ({ useSuspense: e, enableDebug: t }) => ({
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: n, useSuspense: i = !0, enableDebug: a = !1 }) {
20
- let o = new r(n), c = l(), u = s({
21
- useSuspense: i,
22
- enableDebug: a
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 e.use(o).use(t).init({
24
+ return i.use(o).use(a).init({
25
25
  ...u,
26
26
  lng: c
27
- }), e;
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(a, JSON.stringify(t)), t = localStorage.getItem(a));
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(a, JSON.stringify(t)), t;
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(i).filter((e) => !t.includes(e)).reduce((e, t) => (e[t] = i[t], e), {});
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.2",
13
+ "version": "1.4.3",
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",
@@ -31,6 +31,7 @@
31
31
  "@testing-library/jest-dom": "^6.9.1",
32
32
  "@testing-library/react": "^16.3.2",
33
33
  "@testing-library/user-event": "^14.6.1",
34
+ "@types/node": "^25.6.0",
34
35
  "@types/react": "^19.2.14",
35
36
  "@types/react-dom": "^19.2.3",
36
37
  "@typescript-eslint/eslint-plugin": "^8.58.0",
@@ -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 };