@ledgerhq/lumen-ui-rnative 0.1.65 → 0.1.66

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.
Files changed (174) hide show
  1. package/dist/module/index.js +1 -1
  2. package/dist/module/index.js.map +1 -1
  3. package/dist/module/lib/Components/core/AddressInput/AddressInput.js +1 -1
  4. package/dist/module/lib/Components/core/AddressInput/AddressInput.js.map +1 -1
  5. package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.js +1 -1
  6. package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.js.map +1 -1
  7. package/dist/module/lib/Components/core/AmountInput/AmountInput.js +1 -1
  8. package/dist/module/lib/Components/core/AmountInput/AmountInput.js.map +1 -1
  9. package/dist/module/lib/Components/core/Avatar/Avatar.js +1 -1
  10. package/dist/module/lib/Components/core/Avatar/Avatar.js.map +1 -1
  11. package/dist/module/lib/Components/core/Banner/Banner.js +1 -1
  12. package/dist/module/lib/Components/core/Banner/Banner.js.map +1 -1
  13. package/dist/module/lib/Components/core/BottomSheet/BottomSheetHeader.js +1 -1
  14. package/dist/module/lib/Components/core/BottomSheet/BottomSheetHeader.js.map +1 -1
  15. package/dist/module/lib/Components/core/ContentBanner/ContentBanner.js +1 -1
  16. package/dist/module/lib/Components/core/ContentBanner/ContentBanner.js.map +1 -1
  17. package/dist/module/lib/Components/core/MediaBanner/MediaBanner.js +1 -1
  18. package/dist/module/lib/Components/core/MediaBanner/MediaBanner.js.map +1 -1
  19. package/dist/module/lib/Components/core/MediaCard/MediaCard.js +1 -1
  20. package/dist/module/lib/Components/core/MediaCard/MediaCard.js.map +1 -1
  21. package/dist/module/lib/Components/core/NavBar/NavBar.js +1 -1
  22. package/dist/module/lib/Components/core/NavBar/NavBar.js.map +1 -1
  23. package/dist/module/lib/Components/core/Spinner/Spinner.js +1 -1
  24. package/dist/module/lib/Components/core/Spinner/Spinner.js.map +1 -1
  25. package/dist/module/lib/Components/core/Stepper/Stepper.js +1 -1
  26. package/dist/module/lib/Components/core/Stepper/Stepper.js.map +1 -1
  27. package/dist/module/lib/Components/core/Subheader/Subheader.js +5 -1
  28. package/dist/module/lib/Components/core/Subheader/Subheader.js.map +1 -1
  29. package/dist/module/lib/Components/core/ThemeProvider/ThemeProvider.js +2 -2
  30. package/dist/module/lib/Components/core/ThemeProvider/ThemeProvider.js.map +1 -1
  31. package/dist/module/lib/Components/core/ThemeProvider/ThemeProvider.test.js +9 -0
  32. package/dist/module/lib/Components/core/ThemeProvider/ThemeProvider.test.js.map +1 -1
  33. package/dist/module/lib/Components/core/Toast/hooks/useToastAccessibility.js +1 -1
  34. package/dist/module/lib/Components/core/Toast/hooks/useToastAccessibility.js.map +1 -1
  35. package/dist/module/lib/Components/core/Trend/Trend.js +1 -1
  36. package/dist/module/lib/Components/core/Trend/Trend.js.map +1 -1
  37. package/dist/module/lib/Components/internal/BaseInput/BaseInput.js +1 -1
  38. package/dist/module/lib/Components/internal/BaseInput/BaseInput.js.map +1 -1
  39. package/dist/module/lib/Components/visualization/CartesianChart/CartesianChart.js +6 -2
  40. package/dist/module/lib/Components/visualization/CartesianChart/CartesianChart.js.map +1 -1
  41. package/dist/module/lib/Components/visualization/DonutChart/DonutChart.js +8 -4
  42. package/dist/module/lib/Components/visualization/DonutChart/DonutChart.js.map +1 -1
  43. package/dist/module/lib/Components/visualization/DonutChart/DonutChart.test.js +1 -1
  44. package/dist/module/lib/Components/visualization/DonutChart/DonutChart.test.js.map +1 -1
  45. package/dist/module/lib/Components/visualization/DonutChart/DonutRing.js +12 -3
  46. package/dist/module/lib/Components/visualization/DonutChart/DonutRing.js.map +1 -1
  47. package/dist/module/lib/Components/visualization/Legend/Legend.js +1 -1
  48. package/dist/module/lib/Components/visualization/Legend/Legend.js.map +1 -1
  49. package/dist/module/lib/Components/visualization/Legend/Legend.test.js +12 -8
  50. package/dist/module/lib/Components/visualization/Legend/Legend.test.js.map +1 -1
  51. package/dist/module/lib/Components/visualization/LineChart/LineChart.js +8 -2
  52. package/dist/module/lib/Components/visualization/LineChart/LineChart.js.map +1 -1
  53. package/dist/module/lib/Components/visualization/LineChart/utils.js +3 -2
  54. package/dist/module/lib/Components/visualization/LineChart/utils.js.map +1 -1
  55. package/dist/module/lib/Components/visualization/LineChart/utils.test.js +8 -4
  56. package/dist/module/lib/Components/visualization/LineChart/utils.test.js.map +1 -1
  57. package/dist/module/lib/Components/visualization/config.js +1 -4
  58. package/dist/module/lib/Components/visualization/config.js.map +1 -1
  59. package/dist/module/translations/index.js +5 -0
  60. package/dist/module/translations/index.js.map +1 -0
  61. package/dist/module/{i18n → translations}/languages.js +0 -6
  62. package/dist/module/translations/languages.js.map +1 -0
  63. package/dist/module/{i18n → translations}/locales/de.json +0 -3
  64. package/{src/i18n → dist/module/translations}/locales/en.json +9 -3
  65. package/{src/i18n → dist/module/translations}/locales/es.json +0 -3
  66. package/dist/module/{i18n → translations}/locales/fr.json +0 -3
  67. package/{src/i18n → dist/module/translations}/locales/ja.json +0 -3
  68. package/dist/module/{i18n → translations}/locales/ko.json +0 -3
  69. package/dist/module/{i18n → translations}/locales/pt.json +0 -3
  70. package/dist/module/{i18n → translations}/locales/ru.json +0 -3
  71. package/dist/module/{i18n → translations}/locales/th.json +0 -3
  72. package/dist/module/{i18n → translations}/locales/tr.json +0 -3
  73. package/{src/i18n → dist/module/translations}/locales/zh.json +0 -3
  74. package/dist/module/translations/translations.js +36 -0
  75. package/dist/module/translations/translations.js.map +1 -0
  76. package/dist/module/translations/translations.test.js +34 -0
  77. package/dist/module/translations/translations.test.js.map +1 -0
  78. package/dist/typescript/src/index.d.ts +1 -1
  79. package/dist/typescript/src/index.d.ts.map +1 -1
  80. package/dist/typescript/src/lib/Components/core/Subheader/Subheader.d.ts.map +1 -1
  81. package/dist/typescript/src/lib/Components/core/ThemeProvider/types.d.ts +1 -1
  82. package/dist/typescript/src/lib/Components/core/ThemeProvider/types.d.ts.map +1 -1
  83. package/dist/typescript/src/lib/Components/visualization/CartesianChart/CartesianChart.d.ts.map +1 -1
  84. package/dist/typescript/src/lib/Components/visualization/CartesianChart/types.d.ts +1 -1
  85. package/dist/typescript/src/lib/Components/visualization/DonutChart/DonutChart.d.ts.map +1 -1
  86. package/dist/typescript/src/lib/Components/visualization/DonutChart/DonutRing.d.ts.map +1 -1
  87. package/dist/typescript/src/lib/Components/visualization/DonutChart/types.d.ts +1 -1
  88. package/dist/typescript/src/lib/Components/visualization/Legend/Legend.d.ts.map +1 -1
  89. package/dist/typescript/src/lib/Components/visualization/Legend/types.d.ts +2 -2
  90. package/dist/typescript/src/lib/Components/visualization/LineChart/LineChart.d.ts +1 -1
  91. package/dist/typescript/src/lib/Components/visualization/LineChart/LineChart.d.ts.map +1 -1
  92. package/dist/typescript/src/lib/Components/visualization/LineChart/types.d.ts +1 -1
  93. package/dist/typescript/src/lib/Components/visualization/LineChart/utils.d.ts +2 -1
  94. package/dist/typescript/src/lib/Components/visualization/LineChart/utils.d.ts.map +1 -1
  95. package/dist/typescript/src/lib/Components/visualization/config.d.ts +0 -3
  96. package/dist/typescript/src/lib/Components/visualization/config.d.ts.map +1 -1
  97. package/dist/typescript/src/translations/index.d.ts +3 -0
  98. package/dist/typescript/src/translations/index.d.ts.map +1 -0
  99. package/dist/typescript/src/{i18n → translations}/languages.d.ts +0 -5
  100. package/dist/typescript/src/translations/languages.d.ts.map +1 -0
  101. package/dist/typescript/src/translations/translations.d.ts +421 -0
  102. package/dist/typescript/src/translations/translations.d.ts.map +1 -0
  103. package/package.json +3 -5
  104. package/src/index.ts +1 -1
  105. package/src/lib/Components/core/AddressInput/AddressInput.tsx +1 -1
  106. package/src/lib/Components/core/AmountDisplay/AmountDisplay.tsx +1 -1
  107. package/src/lib/Components/core/AmountInput/AmountInput.tsx +1 -1
  108. package/src/lib/Components/core/Avatar/Avatar.tsx +1 -1
  109. package/src/lib/Components/core/Banner/Banner.tsx +1 -1
  110. package/src/lib/Components/core/BottomSheet/BottomSheetHeader.tsx +1 -1
  111. package/src/lib/Components/core/ContentBanner/ContentBanner.tsx +1 -1
  112. package/src/lib/Components/core/MediaBanner/MediaBanner.tsx +1 -1
  113. package/src/lib/Components/core/MediaCard/MediaCard.tsx +1 -1
  114. package/src/lib/Components/core/NavBar/NavBar.tsx +1 -1
  115. package/src/lib/Components/core/Spinner/Spinner.tsx +1 -1
  116. package/src/lib/Components/core/Stepper/Stepper.tsx +1 -1
  117. package/src/lib/Components/core/Subheader/Subheader.tsx +3 -1
  118. package/src/lib/Components/core/ThemeProvider/ThemeProvider.test.tsx +11 -0
  119. package/src/lib/Components/core/ThemeProvider/ThemeProvider.tsx +3 -3
  120. package/src/lib/Components/core/ThemeProvider/types.ts +1 -1
  121. package/src/lib/Components/core/Toast/hooks/useToastAccessibility.ts +1 -1
  122. package/src/lib/Components/core/Trend/Trend.tsx +1 -1
  123. package/src/lib/Components/internal/BaseInput/BaseInput.tsx +1 -1
  124. package/src/lib/Components/visualization/CartesianChart/CartesianChart.tsx +4 -2
  125. package/src/lib/Components/visualization/CartesianChart/types.ts +1 -1
  126. package/src/lib/Components/visualization/DonutChart/DonutChart.test.tsx +1 -3
  127. package/src/lib/Components/visualization/DonutChart/DonutChart.tsx +7 -3
  128. package/src/lib/Components/visualization/DonutChart/DonutRing.tsx +11 -1
  129. package/src/lib/Components/visualization/DonutChart/types.ts +1 -1
  130. package/src/lib/Components/visualization/Legend/Legend.test.tsx +9 -8
  131. package/src/lib/Components/visualization/Legend/Legend.tsx +1 -1
  132. package/src/lib/Components/visualization/Legend/types.ts +2 -2
  133. package/src/lib/Components/visualization/LineChart/LineChart.tsx +10 -2
  134. package/src/lib/Components/visualization/LineChart/types.ts +1 -1
  135. package/src/lib/Components/visualization/LineChart/utils.test.ts +4 -0
  136. package/src/lib/Components/visualization/LineChart/utils.ts +6 -2
  137. package/src/lib/Components/visualization/config.ts +0 -3
  138. package/src/translations/index.ts +2 -0
  139. package/src/{i18n → translations}/languages.ts +0 -6
  140. package/src/{i18n → translations}/locales/de.json +0 -3
  141. package/{dist/module/i18n → src/translations}/locales/en.json +9 -3
  142. package/{dist/module/i18n → src/translations}/locales/es.json +0 -3
  143. package/src/{i18n → translations}/locales/fr.json +0 -3
  144. package/{dist/module/i18n → src/translations}/locales/ja.json +0 -3
  145. package/src/{i18n → translations}/locales/ko.json +0 -3
  146. package/src/{i18n → translations}/locales/pt.json +0 -3
  147. package/src/{i18n → translations}/locales/ru.json +0 -3
  148. package/src/{i18n → translations}/locales/th.json +0 -3
  149. package/src/{i18n → translations}/locales/tr.json +0 -3
  150. package/{dist/module/i18n → src/translations}/locales/zh.json +0 -3
  151. package/src/translations/translations.test.ts +56 -0
  152. package/src/translations/translations.ts +21 -0
  153. package/dist/module/i18n/I18nProvider.js +0 -20
  154. package/dist/module/i18n/I18nProvider.js.map +0 -1
  155. package/dist/module/i18n/i18n.js +0 -82
  156. package/dist/module/i18n/i18n.js.map +0 -1
  157. package/dist/module/i18n/index.js +0 -6
  158. package/dist/module/i18n/index.js.map +0 -1
  159. package/dist/module/i18n/languages.js.map +0 -1
  160. package/dist/module/i18n/useCommonTranslation.js +0 -8
  161. package/dist/module/i18n/useCommonTranslation.js.map +0 -1
  162. package/dist/typescript/src/i18n/I18nProvider.d.ts +0 -8
  163. package/dist/typescript/src/i18n/I18nProvider.d.ts.map +0 -1
  164. package/dist/typescript/src/i18n/i18n.d.ts +0 -13
  165. package/dist/typescript/src/i18n/i18n.d.ts.map +0 -1
  166. package/dist/typescript/src/i18n/index.d.ts +0 -4
  167. package/dist/typescript/src/i18n/index.d.ts.map +0 -1
  168. package/dist/typescript/src/i18n/languages.d.ts.map +0 -1
  169. package/dist/typescript/src/i18n/useCommonTranslation.d.ts +0 -2
  170. package/dist/typescript/src/i18n/useCommonTranslation.d.ts.map +0 -1
  171. package/src/i18n/I18nProvider.tsx +0 -20
  172. package/src/i18n/i18n.ts +0 -107
  173. package/src/i18n/index.ts +0 -3
  174. package/src/i18n/useCommonTranslation.ts +0 -6
@@ -25,9 +25,6 @@
25
25
  "banner": {
26
26
  "closeAriaLabel": "Fermer"
27
27
  },
28
- "link": {
29
- "opensInNewTabAriaLabel": "(s'ouvre dans un nouvel onglet)"
30
- },
31
28
  "stepper": {
32
29
  "progressAriaLabel": "Étape {{currentStep}} sur {{totalSteps}}"
33
30
  }
@@ -25,9 +25,6 @@
25
25
  "banner": {
26
26
  "closeAriaLabel": "閉じる"
27
27
  },
28
- "link": {
29
- "opensInNewTabAriaLabel": "(新しいタブで開く)"
30
- },
31
28
  "stepper": {
32
29
  "progressAriaLabel": "ステップ{{currentStep}}/{{totalSteps}}"
33
30
  }
@@ -25,9 +25,6 @@
25
25
  "banner": {
26
26
  "closeAriaLabel": "닫기"
27
27
  },
28
- "link": {
29
- "opensInNewTabAriaLabel": "(새 탭에서 열기)"
30
- },
31
28
  "stepper": {
32
29
  "progressAriaLabel": "{{totalSteps}} 중 {{currentStep}} 단계"
33
30
  }
@@ -25,9 +25,6 @@
25
25
  "banner": {
26
26
  "closeAriaLabel": "Fechar"
27
27
  },
28
- "link": {
29
- "opensInNewTabAriaLabel": "(abre em uma nova aba)"
30
- },
31
28
  "stepper": {
32
29
  "progressAriaLabel": "Passo {{currentStep}} de {{totalSteps}}"
33
30
  }
@@ -25,9 +25,6 @@
25
25
  "banner": {
26
26
  "closeAriaLabel": "Закрыть"
27
27
  },
28
- "link": {
29
- "opensInNewTabAriaLabel": "(открывается в новой вкладке)"
30
- },
31
28
  "stepper": {
32
29
  "progressAriaLabel": "Шаг {{currentStep}} из {{totalSteps}}"
33
30
  }
@@ -25,9 +25,6 @@
25
25
  "banner": {
26
26
  "closeAriaLabel": "ปิด"
27
27
  },
28
- "link": {
29
- "opensInNewTabAriaLabel": "(เปิดในแท็บใหม่)"
30
- },
31
28
  "stepper": {
32
29
  "progressAriaLabel": "ขั้นตอนที่ {{currentStep}} จาก {{totalSteps}}"
33
30
  }
@@ -25,9 +25,6 @@
25
25
  "banner": {
26
26
  "closeAriaLabel": "Kapat"
27
27
  },
28
- "link": {
29
- "opensInNewTabAriaLabel": "(yeni sekmede açılır)"
30
- },
31
28
  "stepper": {
32
29
  "progressAriaLabel": "Adım {{totalSteps}} / {{currentStep}}"
33
30
  }
@@ -25,9 +25,6 @@
25
25
  "banner": {
26
26
  "closeAriaLabel": "关闭"
27
27
  },
28
- "link": {
29
- "opensInNewTabAriaLabel": "(在新选项卡中打开)"
30
- },
31
28
  "stepper": {
32
29
  "progressAriaLabel": "第 {{currentStep}} / {{totalSteps}} 步"
33
30
  }
@@ -0,0 +1,56 @@
1
+ import { describe, expect, it } from '@jest/globals';
2
+ import { dictionaries } from './translations';
3
+
4
+ type Dictionary = { [key: string]: string | Dictionary };
5
+
6
+ const flatten = (dictionary: Dictionary, prefix = ''): Record<string, string> =>
7
+ Object.entries(dictionary).reduce<Record<string, string>>(
8
+ (entries, [key, value]) => {
9
+ const path = prefix ? `${prefix}.${key}` : key;
10
+ return typeof value === 'string'
11
+ ? { ...entries, [path]: value }
12
+ : { ...entries, ...flatten(value, path) };
13
+ },
14
+ {},
15
+ );
16
+
17
+ const placeholdersOf = (value: string): string[] =>
18
+ [...value.matchAll(/\{\{\s*(\w+)\s*\}\}/g)].map(([, name]) => name).sort();
19
+
20
+ // Keys that are allowed to fall back to en until they are translated.
21
+ const UNTRANSLATED_KEYS = [
22
+ 'components.trend.positiveAriaLabel',
23
+ 'components.trend.negativeAriaLabel',
24
+ 'components.trend.neutralAriaLabel',
25
+ 'components.chart.emptyLabel',
26
+ 'components.chart.loadingAriaLabel',
27
+ 'components.chart.defaultAriaLabel',
28
+ 'components.chart.selectedSegmentAriaLabel',
29
+ 'components.subheader.moreInfoAriaLabel',
30
+ ];
31
+ const source = flatten(dictionaries.en);
32
+ const locales = Object.entries(dictionaries)
33
+ .filter(([locale]) => locale !== 'en')
34
+ .map(([locale, dictionary]) => [locale, flatten(dictionary)] as const);
35
+
36
+ describe('translation dictionaries', () => {
37
+ it.each(locales)('%s has no key that en lacks', (_, entries) => {
38
+ expect(Object.keys(entries).filter((key) => !(key in source))).toEqual([]);
39
+ });
40
+
41
+ it.each(locales)('%s translates every en key', (_, entries) => {
42
+ const missing = Object.keys(source).filter(
43
+ (key) => !(key in entries) && !UNTRANSLATED_KEYS.includes(key),
44
+ );
45
+ expect(missing).toEqual([]);
46
+ });
47
+
48
+ it.each(locales)('%s uses the same placeholders as en', (_, entries) => {
49
+ const mismatches = Object.entries(entries).filter(
50
+ ([key, value]) =>
51
+ placeholdersOf(value).join() !==
52
+ placeholdersOf(source[key] ?? '').join(),
53
+ );
54
+ expect(mismatches).toEqual([]);
55
+ });
56
+ });
@@ -0,0 +1,21 @@
1
+ import { createTranslations } from '@ledgerhq/lumen-utils-shared';
2
+ import { DEFAULT_LANGUAGE, type SupportedLocale } from './languages';
3
+ import de from './locales/de.json';
4
+ import en from './locales/en.json';
5
+ import es from './locales/es.json';
6
+ import fr from './locales/fr.json';
7
+ import ja from './locales/ja.json';
8
+ import ko from './locales/ko.json';
9
+ import pt from './locales/pt.json';
10
+ import ru from './locales/ru.json';
11
+ import th from './locales/th.json';
12
+ import tr from './locales/tr.json';
13
+ import zh from './locales/zh.json';
14
+
15
+ export const dictionaries = { de, en, es, fr, ja, ko, pt, ru, th, tr, zh };
16
+
17
+ export const { TranslationsProvider, useTranslations: useCommonTranslation } =
18
+ createTranslations<SupportedLocale, typeof en>({
19
+ dictionaries,
20
+ defaultLocale: DEFAULT_LANGUAGE,
21
+ });
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- import { useEffect } from 'react';
4
- import { I18nextProvider } from 'react-i18next';
5
- import { i18n, switchLanguage } from "./i18n.js";
6
- import { DEFAULT_LANGUAGE } from "./languages.js";
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- export const I18nProvider = ({
9
- locale = DEFAULT_LANGUAGE,
10
- children
11
- }) => {
12
- useEffect(() => {
13
- switchLanguage(locale);
14
- }, [locale]);
15
- return /*#__PURE__*/_jsx(I18nextProvider, {
16
- i18n: i18n,
17
- children: children
18
- });
19
- };
20
- //# sourceMappingURL=I18nProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useEffect","I18nextProvider","i18n","switchLanguage","DEFAULT_LANGUAGE","jsx","_jsx","I18nProvider","locale","children"],"sourceRoot":"../../../src","sources":["i18n/I18nProvider.tsx"],"mappings":";;AACA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,IAAI,EAAEC,cAAc,QAAQ,WAAQ;AAC7C,SAASC,gBAAgB,QAA8B,gBAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAMrE,OAAO,MAAMC,YAAY,GAAGA,CAAC;EAC3BC,MAAM,GAAGJ,gBAAgB;EACzBK;AACiB,CAAC,KAAK;EACvBT,SAAS,CAAC,MAAM;IACdG,cAAc,CAACK,MAAM,CAAC;EACxB,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EAEZ,oBAAOF,IAAA,CAACL,eAAe;IAACC,IAAI,EAAEA,IAAK;IAAAO,QAAA,EAAEA;EAAQ,CAAkB,CAAC;AAClE,CAAC","ignoreList":[]}
@@ -1,82 +0,0 @@
1
- "use strict";
2
-
3
- import i18next from 'i18next';
4
- import { initReactI18next } from 'react-i18next';
5
- import { DEFAULT_LANGUAGE, I18N_DEFAULT_NAMESPACE } from "./languages.js";
6
- import de from './locales/de.json';
7
- import en from './locales/en.json';
8
- import es from './locales/es.json';
9
- import fr from './locales/fr.json';
10
- import ja from './locales/ja.json';
11
- import ko from './locales/ko.json';
12
- import pt from './locales/pt.json';
13
- import ru from './locales/ru.json';
14
- import th from './locales/th.json';
15
- import tr from './locales/tr.json';
16
- import zh from './locales/zh.json';
17
- const localeResources = {
18
- de,
19
- en,
20
- es,
21
- fr,
22
- ja,
23
- ko,
24
- pt,
25
- ru,
26
- th,
27
- tr,
28
- zh
29
- };
30
- const loadedLocales = new Set();
31
- const initializeI18n = () => {
32
- const instance = i18next.createInstance();
33
- const resources = Object.fromEntries(Object.entries(localeResources).map(([locale, translations]) => [locale, {
34
- [I18N_DEFAULT_NAMESPACE]: translations
35
- }]));
36
- Object.keys(localeResources).forEach(locale => loadedLocales.add(locale));
37
- instance.use(initReactI18next).init({
38
- resources,
39
- lng: DEFAULT_LANGUAGE,
40
- defaultNS: I18N_DEFAULT_NAMESPACE,
41
- fallbackLng: DEFAULT_LANGUAGE,
42
- interpolation: {
43
- escapeValue: false
44
- },
45
- react: {
46
- useSuspense: false
47
- }
48
- }).catch(error => {
49
- // eslint-disable-next-line no-console
50
- console.error('Failed to initialize i18next:', error);
51
- });
52
- return instance;
53
- };
54
- export const i18n = initializeI18n();
55
-
56
- /**
57
- * Loads the translations for a given locale.
58
- * In React Native, we bundle all locales, so this just adds the resource bundle.
59
- */
60
- export const loadLocale = async locale => {
61
- if (loadedLocales.has(locale)) {
62
- return;
63
- }
64
- try {
65
- const translations = localeResources[locale];
66
- i18n.addResourceBundle(locale, I18N_DEFAULT_NAMESPACE, translations, true, true);
67
- loadedLocales.add(locale);
68
- } catch (error) {
69
- // eslint-disable-next-line no-console
70
- console.error(`Failed to load locale ${locale}`, error);
71
- throw error;
72
- }
73
- };
74
-
75
- /**
76
- * Switches the language to the given locale.
77
- */
78
- export const switchLanguage = async locale => {
79
- await loadLocale(locale);
80
- await i18n.changeLanguage(locale);
81
- };
82
- //# sourceMappingURL=i18n.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["i18next","initReactI18next","DEFAULT_LANGUAGE","I18N_DEFAULT_NAMESPACE","de","en","es","fr","ja","ko","pt","ru","th","tr","zh","localeResources","loadedLocales","Set","initializeI18n","instance","createInstance","resources","Object","fromEntries","entries","map","locale","translations","keys","forEach","add","use","init","lng","defaultNS","fallbackLng","interpolation","escapeValue","react","useSuspense","catch","error","console","i18n","loadLocale","has","addResourceBundle","switchLanguage","changeLanguage"],"sourceRoot":"../../../src","sources":["i18n/i18n.ts"],"mappings":";;AAAA,OAAOA,OAAO,MAAqC,SAAS;AAC5D,SAASC,gBAAgB,QAAQ,eAAe;AAEhD,SAASC,gBAAgB,EAAEC,sBAAsB,QAAQ,gBAAa;AAEtE,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,EAAE,MAAM,mBAAmB;AAElC,MAAMC,eAAe,GAAG;EACtBX,EAAE;EACFC,EAAE;EACFC,EAAE;EACFC,EAAE;EACFC,EAAE;EACFC,EAAE;EACFC,EAAE;EACFC,EAAE;EACFC,EAAE;EACFC,EAAE;EACFC;AACF,CAAC;AAED,MAAME,aAAa,GAAG,IAAIC,GAAG,CAAkB,CAAC;AAEhD,MAAMC,cAAc,GAAGA,CAAA,KAAoB;EACzC,MAAMC,QAAQ,GAAGnB,OAAO,CAACoB,cAAc,CAAC,CAAC;EAEzC,MAAMC,SAAS,GAAGC,MAAM,CAACC,WAAW,CAClCD,MAAM,CAACE,OAAO,CAACT,eAAe,CAAC,CAACU,GAAG,CAAC,CAAC,CAACC,MAAM,EAAEC,YAAY,CAAC,KAAK,CAC9DD,MAAM,EACN;IAAE,CAACvB,sBAAsB,GAAGwB;EAAa,CAAC,CAC3C,CACH,CAAC;EAEDL,MAAM,CAACM,IAAI,CAACb,eAAe,CAAC,CAACc,OAAO,CAAEH,MAAM,IAC1CV,aAAa,CAACc,GAAG,CAACJ,MAAyB,CAC7C,CAAC;EAEDP,QAAQ,CACLY,GAAG,CAAC9B,gBAAgB,CAAC,CACrB+B,IAAI,CAAC;IACJX,SAAS;IACTY,GAAG,EAAE/B,gBAAgB;IACrBgC,SAAS,EAAE/B,sBAAsB;IACjCgC,WAAW,EAAEjC,gBAAgB;IAC7BkC,aAAa,EAAE;MACbC,WAAW,EAAE;IACf,CAAC;IACDC,KAAK,EAAE;MACLC,WAAW,EAAE;IACf;EACF,CAAC,CAAC,CACDC,KAAK,CAAEC,KAAc,IAAK;IACzB;IACAC,OAAO,CAACD,KAAK,CAAC,+BAA+B,EAAEA,KAAK,CAAC;EACvD,CAAC,CAAC;EAEJ,OAAOtB,QAAQ;AACjB,CAAC;AAED,OAAO,MAAMwB,IAAI,GAAGzB,cAAc,CAAC,CAAC;;AAEpC;AACA;AACA;AACA;AACA,OAAO,MAAM0B,UAAU,GAAG,MAAOlB,MAAuB,IAAoB;EAC1E,IAAIV,aAAa,CAAC6B,GAAG,CAACnB,MAAM,CAAC,EAAE;IAC7B;EACF;EAEA,IAAI;IACF,MAAMC,YAAY,GAAGZ,eAAe,CAACW,MAAM,CAAC;IAC5CiB,IAAI,CAACG,iBAAiB,CACpBpB,MAAM,EACNvB,sBAAsB,EACtBwB,YAAY,EACZ,IAAI,EACJ,IACF,CAAC;IAEDX,aAAa,CAACc,GAAG,CAACJ,MAAM,CAAC;EAC3B,CAAC,CAAC,OAAOe,KAAK,EAAE;IACd;IACAC,OAAO,CAACD,KAAK,CAAC,yBAAyBf,MAAM,EAAE,EAAEe,KAAK,CAAC;IACvD,MAAMA,KAAK;EACb;AACF,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMM,cAAc,GAAG,MAC5BrB,MAAuB,IACL;EAClB,MAAMkB,UAAU,CAAClB,MAAM,CAAC;EACxB,MAAMiB,IAAI,CAACK,cAAc,CAACtB,MAAM,CAAC;AACnC,CAAC","ignoreList":[]}
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- export { I18nProvider } from "./I18nProvider.js";
4
- export { Languages } from "./languages.js";
5
- export { useCommonTranslation } from "./useCommonTranslation.js";
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["I18nProvider","Languages","useCommonTranslation"],"sourceRoot":"../../../src","sources":["i18n/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,mBAAgB;AAC7C,SAA+BC,SAAS,QAAQ,gBAAa;AAC7D,SAASC,oBAAoB,QAAQ,2BAAwB","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["Languages","de","id","en","es","fr","ja","ko","pt","ru","th","tr","zh","DEFAULT_LANGUAGE","I18N_DEFAULT_NAMESPACE"],"sourceRoot":"../../../src","sources":["i18n/languages.ts"],"mappings":";;AAAA;AACA;AACA;AACA,OAAO,MAAMA,SAAS,GAAG;EACvBC,EAAE,EAAE;IACFC,EAAE,EAAE;EACN,CAAC;EACDC,EAAE,EAAE;IACFD,EAAE,EAAE;EACN,CAAC;EACDE,EAAE,EAAE;IACFF,EAAE,EAAE;EACN,CAAC;EACDG,EAAE,EAAE;IACFH,EAAE,EAAE;EACN,CAAC;EACDI,EAAE,EAAE;IACFJ,EAAE,EAAE;EACN,CAAC;EACDK,EAAE,EAAE;IACFL,EAAE,EAAE;EACN,CAAC;EACDM,EAAE,EAAE;IACFN,EAAE,EAAE;EACN,CAAC;EACDO,EAAE,EAAE;IACFP,EAAE,EAAE;EACN,CAAC;EACDQ,EAAE,EAAE;IACFR,EAAE,EAAE;EACN,CAAC;EACDS,EAAE,EAAE;IACFT,EAAE,EAAE;EACN,CAAC;EACDU,EAAE,EAAE;IACFV,EAAE,EAAE;EACN;AACF,CAAmD;;AAEnD;AACA;AACA;AACA,OAAO,MAAMW,gBAAgB,GAAGb,SAAS,CAACG,EAAE,CAACD,EAAE;;AAE/C;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA,OAAO,MAAMY,sBAAsB,GAAG,QAAQ","ignoreList":[]}
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- import { useTranslation as useI18nextTranslation } from 'react-i18next';
4
- import { I18N_DEFAULT_NAMESPACE } from "./languages.js";
5
- export const useCommonTranslation = () => {
6
- return useI18nextTranslation(I18N_DEFAULT_NAMESPACE);
7
- };
8
- //# sourceMappingURL=useCommonTranslation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useTranslation","useI18nextTranslation","I18N_DEFAULT_NAMESPACE","useCommonTranslation"],"sourceRoot":"../../../src","sources":["i18n/useCommonTranslation.ts"],"mappings":";;AAAA,SAASA,cAAc,IAAIC,qBAAqB,QAAQ,eAAe;AACvE,SAASC,sBAAsB,QAAQ,gBAAa;AAEpD,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAM;EACxC,OAAOF,qBAAqB,CAACC,sBAAsB,CAAC;AACtD,CAAC","ignoreList":[]}
@@ -1,8 +0,0 @@
1
- import type { PropsWithChildren } from 'react';
2
- import { type SupportedLocale } from './languages';
3
- type I18nProviderProps = PropsWithChildren & {
4
- locale?: SupportedLocale;
5
- };
6
- export declare const I18nProvider: ({ locale, children, }: I18nProviderProps) => import("react/jsx-runtime").JSX.Element;
7
- export {};
8
- //# sourceMappingURL=I18nProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../../../src/i18n/I18nProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI/C,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAErE,KAAK,iBAAiB,GAAG,iBAAiB,GAAG;IAC3C,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,uBAG1B,iBAAiB,4CAMnB,CAAC"}
@@ -1,13 +0,0 @@
1
- import { type i18n as I18nInstance } from 'i18next';
2
- import type { SupportedLocale } from './languages';
3
- export declare const i18n: I18nInstance;
4
- /**
5
- * Loads the translations for a given locale.
6
- * In React Native, we bundle all locales, so this just adds the resource bundle.
7
- */
8
- export declare const loadLocale: (locale: SupportedLocale) => Promise<void>;
9
- /**
10
- * Switches the language to the given locale.
11
- */
12
- export declare const switchLanguage: (locale: SupportedLocale) => Promise<void>;
13
- //# sourceMappingURL=i18n.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../../src/i18n/i18n.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,KAAK,IAAI,IAAI,YAAY,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAmEnD,eAAO,MAAM,IAAI,cAAmB,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAU,QAAQ,eAAe,KAAG,OAAO,CAAC,IAAI,CAqBtE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,eAAe,KACtB,OAAO,CAAC,IAAI,CAGd,CAAC"}
@@ -1,4 +0,0 @@
1
- export { I18nProvider } from './I18nProvider';
2
- export { type SupportedLocale, Languages } from './languages';
3
- export { useCommonTranslation } from './useCommonTranslation';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,KAAK,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../../../src/i18n/languages.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkC6B,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,gBAAgB,MAAkB,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,SAAS,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,WAAW,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const useCommonTranslation: () => import("react-i18next").UseTranslationResponse<"common", undefined>;
2
- //# sourceMappingURL=useCommonTranslation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCommonTranslation.d.ts","sourceRoot":"","sources":["../../../../src/i18n/useCommonTranslation.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,2EAEhC,CAAC"}
@@ -1,20 +0,0 @@
1
- import type { PropsWithChildren } from 'react';
2
- import { useEffect } from 'react';
3
- import { I18nextProvider } from 'react-i18next';
4
- import { i18n, switchLanguage } from './i18n';
5
- import { DEFAULT_LANGUAGE, type SupportedLocale } from './languages';
6
-
7
- type I18nProviderProps = PropsWithChildren & {
8
- locale?: SupportedLocale;
9
- };
10
-
11
- export const I18nProvider = ({
12
- locale = DEFAULT_LANGUAGE,
13
- children,
14
- }: I18nProviderProps) => {
15
- useEffect(() => {
16
- switchLanguage(locale);
17
- }, [locale]);
18
-
19
- return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>;
20
- };
package/src/i18n/i18n.ts DELETED
@@ -1,107 +0,0 @@
1
- import i18next, { type i18n as I18nInstance } from 'i18next';
2
- import { initReactI18next } from 'react-i18next';
3
- import type { SupportedLocale } from './languages';
4
- import { DEFAULT_LANGUAGE, I18N_DEFAULT_NAMESPACE } from './languages';
5
-
6
- import de from './locales/de.json';
7
- import en from './locales/en.json';
8
- import es from './locales/es.json';
9
- import fr from './locales/fr.json';
10
- import ja from './locales/ja.json';
11
- import ko from './locales/ko.json';
12
- import pt from './locales/pt.json';
13
- import ru from './locales/ru.json';
14
- import th from './locales/th.json';
15
- import tr from './locales/tr.json';
16
- import zh from './locales/zh.json';
17
-
18
- const localeResources = {
19
- de,
20
- en,
21
- es,
22
- fr,
23
- ja,
24
- ko,
25
- pt,
26
- ru,
27
- th,
28
- tr,
29
- zh,
30
- };
31
-
32
- const loadedLocales = new Set<SupportedLocale>();
33
-
34
- const initializeI18n = (): I18nInstance => {
35
- const instance = i18next.createInstance();
36
-
37
- const resources = Object.fromEntries(
38
- Object.entries(localeResources).map(([locale, translations]) => [
39
- locale,
40
- { [I18N_DEFAULT_NAMESPACE]: translations },
41
- ]),
42
- );
43
-
44
- Object.keys(localeResources).forEach((locale) =>
45
- loadedLocales.add(locale as SupportedLocale),
46
- );
47
-
48
- instance
49
- .use(initReactI18next)
50
- .init({
51
- resources,
52
- lng: DEFAULT_LANGUAGE,
53
- defaultNS: I18N_DEFAULT_NAMESPACE,
54
- fallbackLng: DEFAULT_LANGUAGE,
55
- interpolation: {
56
- escapeValue: false,
57
- },
58
- react: {
59
- useSuspense: false,
60
- },
61
- })
62
- .catch((error: unknown) => {
63
- // eslint-disable-next-line no-console
64
- console.error('Failed to initialize i18next:', error);
65
- });
66
-
67
- return instance;
68
- };
69
-
70
- export const i18n = initializeI18n();
71
-
72
- /**
73
- * Loads the translations for a given locale.
74
- * In React Native, we bundle all locales, so this just adds the resource bundle.
75
- */
76
- export const loadLocale = async (locale: SupportedLocale): Promise<void> => {
77
- if (loadedLocales.has(locale)) {
78
- return;
79
- }
80
-
81
- try {
82
- const translations = localeResources[locale];
83
- i18n.addResourceBundle(
84
- locale,
85
- I18N_DEFAULT_NAMESPACE,
86
- translations,
87
- true,
88
- true,
89
- );
90
-
91
- loadedLocales.add(locale);
92
- } catch (error) {
93
- // eslint-disable-next-line no-console
94
- console.error(`Failed to load locale ${locale}`, error);
95
- throw error;
96
- }
97
- };
98
-
99
- /**
100
- * Switches the language to the given locale.
101
- */
102
- export const switchLanguage = async (
103
- locale: SupportedLocale,
104
- ): Promise<void> => {
105
- await loadLocale(locale);
106
- await i18n.changeLanguage(locale);
107
- };
package/src/i18n/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export { I18nProvider } from './I18nProvider';
2
- export { type SupportedLocale, Languages } from './languages';
3
- export { useCommonTranslation } from './useCommonTranslation';
@@ -1,6 +0,0 @@
1
- import { useTranslation as useI18nextTranslation } from 'react-i18next';
2
- import { I18N_DEFAULT_NAMESPACE } from './languages';
3
-
4
- export const useCommonTranslation = () => {
5
- return useI18nextTranslation(I18N_DEFAULT_NAMESPACE);
6
- };