@deriv-com/translations 1.0.0 → 1.0.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,9 +1,9 @@
1
1
  import { default as e } from "./localize.js";
2
2
  import "react/jsx-runtime";
3
3
  import "react";
4
- import "../utils-L82GdMuf.js";
5
- import "../i18nInstance-I4t--qpO.js";
6
- import "../context-NlNsLXrG.js";
4
+ import "../utils-6G1tiZlP.js";
5
+ import "../i18nInstance-D20fwFYr.js";
6
+ import "../context-f4Bcf4Hs.js";
7
7
  export {
8
8
  e as Localize
9
9
  };
@@ -1,8 +1,8 @@
1
1
  import { jsx as z } from "react/jsx-runtime";
2
2
  import { createElement as T, isValidElement as K, Fragment as M, cloneElement as _, Children as J, useContext as U } from "react";
3
- import { w as X, b as H } from "../utils-L82GdMuf.js";
4
- import { g as Y, b as I } from "../i18nInstance-I4t--qpO.js";
5
- import { I as Z } from "../context-NlNsLXrG.js";
3
+ import { w as X, b as H } from "../utils-6G1tiZlP.js";
4
+ import { g as Y, b as I } from "../i18nInstance-D20fwFYr.js";
5
+ import { I as Z } from "../context-f4Bcf4Hs.js";
6
6
  function q(t) {
7
7
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
8
8
  }
@@ -130,7 +130,7 @@ function ge(i, e, t, n) {
130
130
  obj: s,
131
131
  k: r
132
132
  } = G(i, e, Object);
133
- s[r] = s[r] || [], n && (s[r] = s[r].concat(t)), n || s[r].push(t);
133
+ s[r] = s[r] || [], s[r].push(t);
134
134
  }
135
135
  function H(i, e) {
136
136
  const {
@@ -2,9 +2,9 @@
2
2
 
3
3
  /* eslint-disable */
4
4
  const path = require("path");
5
- const program = require("commander");
6
5
  const crc32 = require("crc-32").str;
7
6
  const fs = require("fs");
7
+ const program = require("commander");
8
8
  const glob = require("glob");
9
9
  const DOMParser = require("@xmldom/xmldom").DOMParser;
10
10
 
@@ -100,10 +100,6 @@ const getKeyHash = (string) => crc32(string);
100
100
  const file_path = file_paths[i];
101
101
 
102
102
  try {
103
- if (program.verbose) {
104
- console.log(file_path);
105
- }
106
-
107
103
  const file = fs.readFileSync(file_path, "utf8");
108
104
  messages.push(
109
105
  ...(file_path.endsWith("xml")
@@ -2,11 +2,11 @@ import { default as l } from "./use-translations.js";
2
2
  import "react";
3
3
  import "../provider/translation-provider.js";
4
4
  import "react/jsx-runtime";
5
- import "../crc32-bHbojQDz.js";
6
- import "../constants-XUr5oono.js";
7
- import "../context-NlNsLXrG.js";
8
- import "../utils-L82GdMuf.js";
9
- import "../i18nInstance-I4t--qpO.js";
5
+ import "../crc32-LCGpXEbE.js";
6
+ import "../constants-C3Rdpvgf.js";
7
+ import "../context-f4Bcf4Hs.js";
8
+ import "../utils-6G1tiZlP.js";
9
+ import "../i18nInstance-D20fwFYr.js";
10
10
  export {
11
11
  l as useTranslations
12
12
  };
@@ -1,25 +1,25 @@
1
1
  import { useContext as P, useState as E, useRef as N, useEffect as w } from "react";
2
2
  import { TranslationContext as F } from "../provider/translation-provider.js";
3
- import { c as j } from "../crc32-bHbojQDz.js";
4
- import { I as v, R as z } from "../context-NlNsLXrG.js";
5
- import { w as R, h as A, l as C, a as L } from "../utils-L82GdMuf.js";
6
- import { g as M, b as U } from "../i18nInstance-I4t--qpO.js";
3
+ import { c as j } from "../crc32-LCGpXEbE.js";
4
+ import { I as v, R as z } from "../context-f4Bcf4Hs.js";
5
+ import { w as R, h as A, l as C, a as L } from "../utils-6G1tiZlP.js";
6
+ import { g as M, b as U } from "../i18nInstance-D20fwFYr.js";
7
7
  import "react/jsx-runtime";
8
- import "../constants-XUr5oono.js";
8
+ import "../constants-C3Rdpvgf.js";
9
9
  const $ = (a, t) => {
10
- const c = N();
10
+ const u = N();
11
11
  return w(() => {
12
- c.current = t ? c.current : a;
13
- }, [a, t]), c.current;
12
+ u.current = a;
13
+ }, [a, t]), u.current;
14
14
  };
15
15
  function J(a) {
16
16
  let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
17
17
  const {
18
- i18n: c
18
+ i18n: u
19
19
  } = t, {
20
20
  i18n: y,
21
21
  defaultNS: h
22
- } = P(v) || {}, e = c || y || U();
22
+ } = P(v) || {}, e = u || y || U();
23
23
  if (e && !e.reportNamespaces && (e.reportNamespaces = new z()), !e) {
24
24
  R("You will need to pass in an i18next instance by using initReactI18next");
25
25
  const r = (i, s) => typeof s == "string" ? s : s && typeof s == "object" && typeof s.defaultValue == "string" ? s.defaultValue : Array.isArray(i) ? i[i.length - 1] : i, o = [r, {}, !1];
@@ -34,7 +34,7 @@ function J(a) {
34
34
  useSuspense: x,
35
35
  keyPrefix: S
36
36
  } = f;
37
- let n = a || h || e.options && e.options.defaultNS;
37
+ let n = h || e.options && e.options.defaultNS;
38
38
  n = typeof n == "string" ? [n] : n || ["translation"], e.reportNamespaces.addUsedNamespaces && e.reportNamespaces.addUsedNamespaces(n);
39
39
  const l = (e.isInitialized || e.initializedStoreOnce) && n.every((r) => A(r, e, f));
40
40
  function d() {
@@ -43,27 +43,27 @@ function J(a) {
43
43
  const [b, p] = E(d);
44
44
  let m = n.join();
45
45
  t.lng && (m = `${t.lng}${m}`);
46
- const I = $(m), u = N(!0);
46
+ const I = $(m), c = N(!0);
47
47
  w(() => {
48
48
  const {
49
49
  bindI18n: r,
50
50
  bindI18nStore: o
51
51
  } = f;
52
- u.current = !0, !l && !x && (t.lng ? C(e, t.lng, n, () => {
53
- u.current && p(d);
52
+ c.current = !0, !l && !x && (t.lng ? C(e, t.lng, n, () => {
53
+ c.current && p(d);
54
54
  }) : L(e, n, () => {
55
- u.current && p(d);
56
- })), l && I && I !== m && u.current && p(d);
55
+ c.current && p(d);
56
+ })), l && I && I !== m && c.current && p(d);
57
57
  function i() {
58
- u.current && p(d);
58
+ c.current && p(d);
59
59
  }
60
60
  return r && e && e.on(r, i), o && e && e.store.on(o, i), () => {
61
- u.current = !1, r && e && r.split(" ").forEach((s) => e.off(s, i)), o && e && o.split(" ").forEach((s) => e.store.off(s, i));
61
+ c.current = !1, r && e && r.split(" ").forEach((s) => e.off(s, i)), o && e && o.split(" ").forEach((s) => e.store.off(s, i));
62
62
  };
63
63
  }, [e, m]);
64
64
  const T = N(!0);
65
65
  w(() => {
66
- u.current && !T.current && p(d), T.current = !1;
66
+ c.current && !T.current && p(d), T.current = !1;
67
67
  }, [e, S]);
68
68
  const g = [b, e, l];
69
69
  if (g.t = b, g.i18n = e, g.ready = l, l || !l && !x)
@@ -73,7 +73,7 @@ function J(a) {
73
73
  });
74
74
  }
75
75
  function X() {
76
- const a = P(F), { ready: t, t: c, i18n: y } = J(), h = (e, f = {}) => c(j.str(e).toString(), { defaultValue: e, ...f });
76
+ const a = P(F), { ready: t, t: u, i18n: y } = J(), h = (e, f = {}) => u(j.str(e).toString(), { defaultValue: e, ...f });
77
77
  if (!a)
78
78
  throw new Error(
79
79
  "useTranslation has to be used within <TranslationContext.Provider>"
package/dist/index.js CHANGED
@@ -4,14 +4,14 @@ import { getInitialLanguage as x, loadIncontextTranslation as c } from "./utils/
4
4
  import { default as z } from "./components/localize.js";
5
5
  import { default as T } from "./hooks/use-translations.js";
6
6
  import { default as v } from "./provider/translation-provider.js";
7
- import "./crc32-bHbojQDz.js";
7
+ import "./crc32-LCGpXEbE.js";
8
8
  import "./utils/otasdk.js";
9
- import "./i18nInstance-I4t--qpO.js";
10
- import "./constants-XUr5oono.js";
9
+ import "./i18nInstance-D20fwFYr.js";
10
+ import "./constants-C3Rdpvgf.js";
11
11
  import "react/jsx-runtime";
12
12
  import "react";
13
- import "./utils-L82GdMuf.js";
14
- import "./context-NlNsLXrG.js";
13
+ import "./utils-6G1tiZlP.js";
14
+ import "./context-f4Bcf4Hs.js";
15
15
  export {
16
16
  z as Localize,
17
17
  v as TranslationProvider,
@@ -1,9 +1,9 @@
1
1
  import { TranslationContext as n, default as e } from "./translation-provider.js";
2
2
  import "react/jsx-runtime";
3
3
  import "react";
4
- import "../crc32-bHbojQDz.js";
5
- import "../constants-XUr5oono.js";
6
- import "../context-NlNsLXrG.js";
4
+ import "../crc32-LCGpXEbE.js";
5
+ import "../constants-C3Rdpvgf.js";
6
+ import "../context-f4Bcf4Hs.js";
7
7
  export {
8
8
  n as TranslationContext,
9
9
  e as TranslationProvider
@@ -1,8 +1,8 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
2
  import { useMemo as f, createElement as c, createContext as g, useState as u, useEffect as m } from "react";
3
- import "../crc32-bHbojQDz.js";
4
- import { L } from "../constants-XUr5oono.js";
5
- import { I as p } from "../context-NlNsLXrG.js";
3
+ import "../crc32-LCGpXEbE.js";
4
+ import { L } from "../constants-C3Rdpvgf.js";
5
+ import { I as p } from "../context-f4Bcf4Hs.js";
6
6
  function v(a) {
7
7
  let {
8
8
  i18n: e,
@@ -1,4 +1,4 @@
1
- import { A as G, D as E, L as U } from "../constants-XUr5oono.js";
1
+ import { A as G, D as E, L as U } from "../constants-C3Rdpvgf.js";
2
2
  export {
3
3
  G as ALL_LANGUAGES,
4
4
  E as DEFAULT_LANGUAGE,
@@ -1,10 +1,10 @@
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-XUr5oono.js";
4
+ import { c as p } from "../constants-C3Rdpvgf.js";
5
5
  import { getInitialLanguage as x, loadIncontextTranslation as d } from "./lang-utils.js";
6
- import "../crc32-bHbojQDz.js";
7
- import "../i18nInstance-I4t--qpO.js";
6
+ import "../crc32-LCGpXEbE.js";
7
+ import "../i18nInstance-D20fwFYr.js";
8
8
  export {
9
9
  f as OtaSdk,
10
10
  p as constants,
@@ -1,8 +1,8 @@
1
- import { i as e, c as i } from "../crc32-bHbojQDz.js";
1
+ import { i as e, c as i } from "../crc32-LCGpXEbE.js";
2
2
  import s from "./otasdk.js";
3
3
  import { getInitialLanguage as r } from "./lang-utils.js";
4
- import { s as o, a as u } from "../i18nInstance-I4t--qpO.js";
5
- import "../constants-XUr5oono.js";
4
+ import { s as o, a as u } from "../i18nInstance-D20fwFYr.js";
5
+ import "../constants-C3Rdpvgf.js";
6
6
  const c = {
7
7
  type: "3rdParty",
8
8
  init(t) {
@@ -1,5 +1,5 @@
1
- import "../crc32-bHbojQDz.js";
2
- import { L as n, D as o } from "../constants-XUr5oono.js";
1
+ import "../crc32-LCGpXEbE.js";
2
+ import { L as n, D as o } from "../constants-C3Rdpvgf.js";
3
3
  const i = () => {
4
4
  const e = new URLSearchParams(window.location.search).get("lang"), t = localStorage.getItem(n);
5
5
  if (e) {
@@ -1,4 +1,4 @@
1
- import { i as e, c as r } from "../crc32-bHbojQDz.js";
1
+ import { i as e, c as r } from "../crc32-LCGpXEbE.js";
2
2
  function o(t, a) {
3
3
  return t ? e.t(r.str(t).toString(), {
4
4
  defaultValue: t,
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "main": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
9
  "bin": {
10
- "extract-translations": "./scripts/extract-translations.js"
10
+ "extract-translations": "./dist/extract-translations.cjs"
11
11
  },
12
12
  "exports": {
13
13
  ".": {
@@ -16,10 +16,10 @@
16
16
  }
17
17
  },
18
18
  "private": false,
19
- "version": "1.0.0",
19
+ "version": "1.0.2",
20
20
  "scripts": {
21
21
  "dev": "vite",
22
- "build": "tsc && vite build",
22
+ "build": "tsc && vite build && cp ./src/scripts/extract-translations.cjs ./dist/extract-translations.cjs",
23
23
  "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
24
24
  "test": "vitest ./src/__tests__/*.test.tsx",
25
25
  "prepublish": "npm run test && npm run build"
@@ -42,13 +42,9 @@
42
42
  "@typescript-eslint/eslint-plugin": "^6.14.0",
43
43
  "@typescript-eslint/parser": "^6.14.0",
44
44
  "@vitejs/plugin-react": "^4.2.1",
45
- "@xmldom/xmldom": "^0.8.10",
46
- "commander": "^12.0.0",
47
- "crc-32": "^1.2.2",
48
45
  "eslint": "^8.55.0",
49
46
  "eslint-plugin-react-hooks": "^4.6.0",
50
47
  "eslint-plugin-react-refresh": "^0.4.5",
51
- "glob": "^10.3.10",
52
48
  "i18next": "^23.7.18",
53
49
  "jsdom": "^24.0.0",
54
50
  "react": "^18.2.0",
@@ -62,5 +58,11 @@
62
58
  },
63
59
  "optionalDependencies": {
64
60
  "@rollup/rollup-linux-x64-gnu": "^4.17.1"
61
+ },
62
+ "dependencies": {
63
+ "@xmldom/xmldom": "^0.8.10",
64
+ "commander": "^12.0.0",
65
+ "crc-32": "^1.2.2",
66
+ "glob": "^10.3.12"
65
67
  }
66
68
  }
File without changes