@deriv-com/translations 1.0.0 → 1.0.1

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,7 +2,6 @@
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");
8
7
  const glob = require("glob");
@@ -75,12 +74,6 @@ const getTranslatableFiles = () => {
75
74
  return file_paths;
76
75
  };
77
76
 
78
- program
79
- .version("0.1.0")
80
- .description("Build translation source.")
81
- .option("-v, --verbose", "Displays the list of paths to be compiled")
82
- .parse(process.argv);
83
-
84
77
  /** *********************************************
85
78
  * Common
86
79
  */
@@ -100,10 +93,6 @@ const getKeyHash = (string) => crc32(string);
100
93
  const file_path = file_paths[i];
101
94
 
102
95
  try {
103
- if (program.verbose) {
104
- console.log(file_path);
105
- }
106
-
107
96
  const file = fs.readFileSync(file_path, "utf8");
108
97
  messages.push(
109
98
  ...(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.1",
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"
@@ -48,7 +48,7 @@
48
48
  "eslint": "^8.55.0",
49
49
  "eslint-plugin-react-hooks": "^4.6.0",
50
50
  "eslint-plugin-react-refresh": "^0.4.5",
51
- "glob": "^10.3.10",
51
+ "glob": "^10.3.12",
52
52
  "i18next": "^23.7.18",
53
53
  "jsdom": "^24.0.0",
54
54
  "react": "^18.2.0",
File without changes