@orderly.network/i18n 2.12.0 → 2.12.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.
Files changed (58) hide show
  1. package/README.md +27 -314
  2. package/bin/cli.js +92 -37
  3. package/dist/{constant-D_rlt5w0.d.mts → constant-DkvDyddr.d.mts} +12 -40
  4. package/dist/{constant-D_rlt5w0.d.ts → constant-DkvDyddr.d.ts} +12 -40
  5. package/dist/constant.d.mts +1 -1
  6. package/dist/constant.d.ts +1 -1
  7. package/dist/constant.js.map +1 -1
  8. package/dist/constant.mjs.map +1 -1
  9. package/dist/index.d.mts +84 -20
  10. package/dist/index.d.ts +84 -20
  11. package/dist/index.js +138 -107
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +129 -106
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/locale.csv +7 -105
  16. package/dist/locales/de.json +7 -37
  17. package/dist/locales/en.json +7 -37
  18. package/dist/locales/es.json +7 -37
  19. package/dist/locales/fr.json +7 -37
  20. package/dist/locales/id.json +7 -37
  21. package/dist/locales/it.json +7 -37
  22. package/dist/locales/ja.json +7 -37
  23. package/dist/locales/ko.json +7 -37
  24. package/dist/locales/nl.json +7 -37
  25. package/dist/locales/pl.json +7 -37
  26. package/dist/locales/pt.json +7 -37
  27. package/dist/locales/ru.json +7 -37
  28. package/dist/locales/tc.json +7 -37
  29. package/dist/locales/tr.json +7 -37
  30. package/dist/locales/uk.json +7 -37
  31. package/dist/locales/vi.json +7 -37
  32. package/dist/locales/zh.json +7 -37
  33. package/dist/utils.d.mts +1 -1
  34. package/dist/utils.d.ts +1 -1
  35. package/dist/utils.js +25 -50
  36. package/dist/utils.js.map +1 -1
  37. package/dist/utils.mjs +25 -50
  38. package/dist/utils.mjs.map +1 -1
  39. package/docs/guide/AGENTS.md +109 -0
  40. package/docs/guide/cli.md +133 -0
  41. package/docs/guide/examples.md +455 -0
  42. package/docs/guide/exports.md +14 -0
  43. package/docs/guide/integration.md +223 -0
  44. package/docs/guide/utils.md +14 -0
  45. package/package.json +13 -11
  46. package/{script → scripts}/copyLocales.js +1 -1
  47. package/scripts/filterLocaleKeys.js +127 -0
  48. package/{script → scripts}/generateCsv.js +3 -3
  49. package/{script → scripts}/utils.js +20 -14
  50. /package/{script → scripts}/csv2json.js +0 -0
  51. /package/{script → scripts}/diffCsv.js +0 -0
  52. /package/{script → scripts}/fillJson.js +0 -0
  53. /package/{script → scripts}/generateEnJson.js +0 -0
  54. /package/{script → scripts}/generateMissingKeys.js +0 -0
  55. /package/{script → scripts}/json-csv-converter.js +0 -0
  56. /package/{script → scripts}/json2csv.js +0 -0
  57. /package/{script → scripts}/mergeJson.js +0 -0
  58. /package/{script → scripts}/separateJson.js +0 -0
@@ -1,6 +1,7 @@
1
1
  import * as react from 'react';
2
2
 
3
3
  declare const en: {
4
+ "tradingPoints.points": string;
4
5
  "notification.campaign": string;
5
6
  "notification.delisting": string;
6
7
  "notification.general": string;
@@ -130,42 +131,6 @@ declare const en: {
130
131
  "errorBoundary.refresh": string;
131
132
  "dmm.maker": string;
132
133
  "dmm.taker": string;
133
- "tradingPoints.points": string;
134
- "tradingPoints.startsIn": string;
135
- "tradingPoints.days": string;
136
- "tradingPoints.hours": string;
137
- "tradingPoints.minutes": string;
138
- "tradingPoints.seconds": string;
139
- "tradingPoints.learnMore": string;
140
- "tradingPoints.stagePoints": string;
141
- "tradingPoints.stageRanking": string;
142
- "tradingPoints.referralCode": string;
143
- "tradingPoints.referralLink": string;
144
- "tradingPoints.currentPoints": string;
145
- "tradingPoints.ranking": string;
146
- "tradingPoints.myPoints": string;
147
- "tradingPoints.thisWeek": string;
148
- "tradingPoints.lastWeek": string;
149
- "tradingPoints.all": string;
150
- "tradingPoints.tradePoints": string;
151
- "tradingPoints.tradePointsTooltip": string;
152
- "tradingPoints.tradeNow": string;
153
- "tradingPoints.pnlPoints": string;
154
- "tradingPoints.pnlPointsTooltip": string;
155
- "tradingPoints.referralPoints": string;
156
- "tradingPoints.referralPointsTooltip": string;
157
- "tradingPoints.copyLink": string;
158
- "tradingPoints.faq.title": string;
159
- "tradingPoints.faq.whatArePoints.question": string;
160
- "tradingPoints.faq.whatArePoints.answer": string;
161
- "tradingPoints.faq.allocation.question": string;
162
- "tradingPoints.faq.allocation.answer": string;
163
- "tradingPoints.faq.distribution.question": string;
164
- "tradingPoints.faq.distribution.answer": string;
165
- "tradingPoints.faq.pnl.question": string;
166
- "tradingPoints.faq.pnl.answer": string;
167
- "tradingPoints.faq.referral.question": string;
168
- "tradingPoints.faq.referral.answer": string;
169
134
  "tradingLeaderboard.leaderboard": string;
170
135
  "tradingLeaderboard.campaigns": string;
171
136
  "tradingLeaderboard.ongoing": string;
@@ -226,6 +191,10 @@ declare const en: {
226
191
  "affiliate.referralCode.label": string;
227
192
  "affiliate.referralCode.bound": string;
228
193
  "affiliate.referralCode.notExist": string;
194
+ "affiliate.referralCode.bind.modal.title": string;
195
+ "affiliate.referralCode.bind.modal.description": string;
196
+ "affiliate.referralCode.bind.input.placeholder": string;
197
+ "affiliate.referralCode.bind.skip": string;
229
198
  "affiliate.process.title": string;
230
199
  "affiliate.process.step1.title": string;
231
200
  "affiliate.process.step1.description": string;
@@ -287,6 +256,7 @@ declare const en: {
287
256
  "affiliate.direct": string;
288
257
  "affiliate.directInclBonus": string;
289
258
  "affiliate.indirect": string;
259
+ "affiliate.referredBy": string;
290
260
  "affiliate.referrals": string;
291
261
  "affiliate.referralCode.edit.modal.title": string;
292
262
  "affiliate.referralCode.create": string;
@@ -1300,6 +1270,8 @@ interface LocaleMessages extends EnType, ExtendLocaleMessages {
1300
1270
  type Resources<T extends {} = {}> = {
1301
1271
  [key in LocaleCode]?: Partial<LocaleMessages & T>;
1302
1272
  };
1273
+ /** Async loader for a single locale/namespace message table (see `useRegisterExternalResources`, ExternalLocaleProvider, LocaleProvider `resources`). */
1274
+ type AsyncResources = (lang: LocaleCode, ns: string) => Promise<Record<string, string>>;
1303
1275
  declare module "i18next" {
1304
1276
  interface CustomTypeOptions {
1305
1277
  resources: {
@@ -1327,7 +1299,7 @@ type PopupProps = {
1327
1299
  /** popup style */
1328
1300
  style?: React.CSSProperties;
1329
1301
  };
1330
- type LocaleContextState = {
1302
+ type LanguageContextState = {
1331
1303
  /**
1332
1304
  * custom languages
1333
1305
  */
@@ -1345,8 +1317,8 @@ type LocaleContextState = {
1345
1317
  */
1346
1318
  popup?: PopupProps;
1347
1319
  };
1348
- declare const LocaleContext: react.Context<LocaleContextState>;
1349
- declare const useLocaleContext: () => LocaleContextState;
1320
+ declare const LanguageContext: react.Context<LanguageContextState>;
1321
+ declare const useLanguageContext: () => LanguageContextState;
1350
1322
 
1351
1323
  declare enum LocaleEnum {
1352
1324
  /** English */
@@ -1390,4 +1362,4 @@ declare const defaultNS = "translation";
1390
1362
  declare const i18nLocalStorageKey = "orderly_i18nLng";
1391
1363
  declare const i18nCookieKey = "orderly_i18nLng";
1392
1364
 
1393
- export { type LocaleCode as L, type PopupMode as P, type Resources as R, type LocaleContextState as a, type Language as b, type PopupProps as c, LocaleContext as d, type LocaleMessages as e, LocaleEnum as f, defaultLanguages as g, defaultLng as h, defaultNS as i, i18nLocalStorageKey as j, i18nCookieKey as k, en as l, useLocaleContext as u };
1365
+ export { type AsyncResources as A, type LocaleCode as L, type PopupMode as P, type Resources as R, type LanguageContextState as a, type Language as b, type PopupProps as c, LanguageContext as d, type LocaleMessages as e, LocaleEnum as f, defaultLanguages as g, defaultLng as h, defaultNS as i, i18nLocalStorageKey as j, i18nCookieKey as k, en as l, useLanguageContext as u };
@@ -1,2 +1,2 @@
1
- export { f as LocaleEnum, g as defaultLanguages, h as defaultLng, i as defaultNS, k as i18nCookieKey, j as i18nLocalStorageKey } from './constant-D_rlt5w0.mjs';
1
+ export { f as LocaleEnum, g as defaultLanguages, h as defaultLng, i as defaultNS, k as i18nCookieKey, j as i18nLocalStorageKey } from './constant-DkvDyddr.mjs';
2
2
  import 'react';
@@ -1,2 +1,2 @@
1
- export { f as LocaleEnum, g as defaultLanguages, h as defaultLng, i as defaultNS, k as i18nCookieKey, j as i18nLocalStorageKey } from './constant-D_rlt5w0.js';
1
+ export { f as LocaleEnum, g as defaultLanguages, h as defaultLng, i as defaultNS, k as i18nCookieKey, j as i18nLocalStorageKey } from './constant-DkvDyddr.js';
2
2
  import 'react';
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/constant.ts"],"names":["LocaleEnum"],"mappings":";;;AAEO,IAAK,UAAA,qBAAAA,WAAAA,KAAL;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAlCK,EAAA,OAAAA,WAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA;AAqCL,IAAM,gBAAA,GAA+B;AAAA,EAC1C,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,SAAA,EAAU;AAAA;AAAA,EACnD,E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sB;AAG5B,IAAM,aAAA,GAAgB","file":"constant.js","sourcesContent":["import { Language } from \"./context\";\n\nexport enum LocaleEnum {\n /** English */\n en = \"en\",\n /** Chinese */\n zh = \"zh\",\n /** Japanese */\n ja = \"ja\",\n /** Spanish */\n es = \"es\",\n /** Korean */\n ko = \"ko\",\n /** Vietnamese */\n vi = \"vi\",\n /** German */\n de = \"de\",\n /** French */\n fr = \"fr\",\n /** Russian */\n ru = \"ru\",\n /** Indonesian */\n id = \"id\",\n /** Turkish */\n tr = \"tr\",\n /** Italian */\n it = \"it\",\n /** Portuguese */\n pt = \"pt\",\n /** Ukrainian */\n uk = \"uk\",\n /** Polish */\n pl = \"pl\",\n /** Dutch */\n nl = \"nl\",\n /** Traditional Chinese */\n tc = \"tc\",\n}\n\nexport const defaultLanguages: Language[] = [\n { localCode: LocaleEnum.en, displayName: \"English\" }, // English\n { localCode: LocaleEnum.zh, displayName: \"中文\" }, // Chinese\n { localCode: LocaleEnum.ja, displayName: \"日本語\" }, // Japanese\n { localCode: LocaleEnum.es, displayName: \"Español\" }, // Spanish\n { localCode: LocaleEnum.ko, displayName: \"한국어\" }, // Korean\n { localCode: LocaleEnum.vi, displayName: \"Tiếng Việt\" }, // Vietnamese\n { localCode: LocaleEnum.de, displayName: \"Deutsch\" }, // German\n { localCode: LocaleEnum.fr, displayName: \"Français\" }, // French\n { localCode: LocaleEnum.ru, displayName: \"Русский\" }, // Russian\n { localCode: LocaleEnum.id, displayName: \"Bahasa Indonesia\" }, // Indonesian\n { localCode: LocaleEnum.tr, displayName: \"Türkçe\" }, // Turkish\n { localCode: LocaleEnum.it, displayName: \"Italiano\" }, // Italian\n { localCode: LocaleEnum.pt, displayName: \"Português\" }, // Portuguese\n { localCode: LocaleEnum.uk, displayName: \"Українська\" }, // Ukrainian\n { localCode: LocaleEnum.pl, displayName: \"Polski\" }, // Polish\n { localCode: LocaleEnum.nl, displayName: \"Nederlands\" }, // Dutch\n { localCode: LocaleEnum.tc, displayName: \"繁體中文\" }, // Traditional Chinese\n];\nexport const defaultLng = LocaleEnum.en;\nexport const defaultNS = \"translation\";\n\nexport const i18nLocalStorageKey = \"orderly_i18nLng\";\n\n// preferred-language\nexport const i18nCookieKey = \"orderly_i18nLng\";\n"]}
1
+ {"version":3,"sources":["../src/constant.ts"],"names":["LocaleEnum"],"mappings":";;;AAEO,IAAK,UAAA,qBAAAA,WAAAA,KAAL;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAlCK,EAAA,OAAAA,WAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA;AAqCL,IAAM,gBAAA,GAA+B;AAAA,EAC1C,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,SAAA,EAAU;AAAA;AAAA,EACnD,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,cAAA,EAAK;AAAA;AAAA,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ageContext\";\n\nexport enum LocaleEnum {\n /** English */\n en = \"en\",\n /** Chinese */\n zh = \"zh\",\n /** Japanese */\n ja = \"ja\",\n /** Spanish */\n es = \"es\",\n /** Korean */\n ko = \"ko\",\n /** Vietnamese */\n vi = \"vi\",\n /** German */\n de = \"de\",\n /** French */\n fr = \"fr\",\n /** Russian */\n ru = \"ru\",\n /** Indonesian */\n id = \"id\",\n /** Turkish */\n tr = \"tr\",\n /** Italian */\n it = \"it\",\n /** Portuguese */\n pt = \"pt\",\n /** Ukrainian */\n uk = \"uk\",\n /** Polish */\n pl = \"pl\",\n /** Dutch */\n nl = \"nl\",\n /** Traditional Chinese */\n tc = \"tc\",\n}\n\nexport const defaultLanguages: Language[] = [\n { localCode: LocaleEnum.en, displayName: \"English\" }, // English\n { localCode: LocaleEnum.zh, displayName: \"中文\" }, // Chinese\n { localCode: LocaleEnum.ja, displayName: \"日本語\" }, // Japanese\n { localCode: LocaleEnum.es, displayName: \"Español\" }, // Spanish\n { localCode: LocaleEnum.ko, displayName: \"한국어\" }, // Korean\n { localCode: LocaleEnum.vi, displayName: \"Tiếng Việt\" }, // Vietnamese\n { localCode: LocaleEnum.de, displayName: \"Deutsch\" }, // German\n { localCode: LocaleEnum.fr, displayName: \"Français\" }, // French\n { localCode: LocaleEnum.ru, displayName: \"Русский\" }, // Russian\n { localCode: LocaleEnum.id, displayName: \"Bahasa Indonesia\" }, // Indonesian\n { localCode: LocaleEnum.tr, displayName: \"Türkçe\" }, // Turkish\n { localCode: LocaleEnum.it, displayName: \"Italiano\" }, // Italian\n { localCode: LocaleEnum.pt, displayName: \"Português\" }, // Portuguese\n { localCode: LocaleEnum.uk, displayName: \"Українська\" }, // Ukrainian\n { localCode: LocaleEnum.pl, displayName: \"Polski\" }, // Polish\n { localCode: LocaleEnum.nl, displayName: \"Nederlands\" }, // Dutch\n { localCode: LocaleEnum.tc, displayName: \"繁體中文\" }, // Traditional Chinese\n];\nexport const defaultLng = LocaleEnum.en;\nexport const defaultNS = \"translation\";\n\nexport const i18nLocalStorageKey = \"orderly_i18nLng\";\n\n// preferred-language\nexport const i18nCookieKey = \"orderly_i18nLng\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/constant.ts"],"names":["LocaleEnum"],"mappings":";AAEO,IAAK,UAAA,qBAAAA,WAAAA,KAAL;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAEL,EAAAA,YAAA,IAAA,CAAA,GAAK,IAAA;AAlCK,EAAA,OAAAA,WAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA;AAqCL,IAAM,gBAAA,GAA+B;AAAA,EAC1C,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,SAAA,EAAU;AAAA;AAAA,EACnD,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,cAAA,EAAK;AAAA;AAAA,EAC9C,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAA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ese */\n zh = \"zh\",\n /** Japanese */\n ja = \"ja\",\n /** Spanish */\n es = \"es\",\n /** Korean */\n ko = \"ko\",\n /** Vietnamese */\n vi = \"vi\",\n /** German */\n de = \"de\",\n /** French */\n fr = \"fr\",\n /** Russian */\n ru = \"ru\",\n /** Indonesian */\n id = \"id\",\n /** Turkish */\n tr = \"tr\",\n /** Italian */\n it = \"it\",\n /** Portuguese */\n pt = \"pt\",\n /** Ukrainian */\n uk = \"uk\",\n /** Polish */\n pl = \"pl\",\n /** Dutch */\n nl = \"nl\",\n /** Traditional Chinese */\n tc = \"tc\",\n}\n\nexport const defaultLanguages: Language[] = [\n { localCode: LocaleEnum.en, displayName: \"English\" }, // English\n { localCode: LocaleEnum.zh, displayName: \"中文\" }, // Chinese\n { localCode: LocaleEnum.ja, displayName: \"日本語\" }, // Japanese\n { localCode: LocaleEnum.es, displayName: \"Español\" }, // Spanish\n { localCode: LocaleEnum.ko, displayName: \"한국어\" }, // Korean\n { localCode: LocaleEnum.vi, displayName: \"Tiếng Việt\" }, // Vietnamese\n { localCode: LocaleEnum.de, displayName: \"Deutsch\" }, // German\n { localCode: LocaleEnum.fr, displayName: \"Français\" }, // French\n { localCode: LocaleEnum.ru, displayName: \"Русский\" }, // Russian\n { localCode: LocaleEnum.id, displayName: \"Bahasa Indonesia\" }, // Indonesian\n { localCode: LocaleEnum.tr, displayName: \"Türkçe\" }, // Turkish\n { localCode: LocaleEnum.it, displayName: \"Italiano\" }, // Italian\n { localCode: LocaleEnum.pt, displayName: \"Português\" }, // Portuguese\n { localCode: LocaleEnum.uk, displayName: \"Українська\" }, // Ukrainian\n { localCode: LocaleEnum.pl, displayName: \"Polski\" }, // Polish\n { localCode: LocaleEnum.nl, displayName: \"Nederlands\" }, // Dutch\n { localCode: LocaleEnum.tc, displayName: \"繁體中文\" }, // Traditional Chinese\n];\nexport const defaultLng = LocaleEnum.en;\nexport const defaultNS = \"translation\";\n\nexport const i18nLocalStorageKey = \"orderly_i18nLng\";\n\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WAAA,EAAa,YAAA,EAAU;AAAA;AAAA,EACnD,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,oBAAA,EAAM;AAAA;AAAA,EAC/C,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,sBAAA,EAAa;AAAA;AAAA,EACtD,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,SAAA,EAAU;AAAA;AAAA,EACnD,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,aAAA,EAAW;AAAA;AAAA,EACpD,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,4CAAA,EAAU;AAAA;AAAA,EACnD,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,kBAAA,EAAmB;AAAA;AAAA,EAC5D,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,cAAA,EAAS;AAAA;AAAA,EAClD,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,UAAA,EAAW;AAAA;AAAA,EACpD,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,cAAA,EAAY;AAAA;AAAA,EACrD,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,8DAAA,EAAa;AAAA;AAAA,EACtD,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,QAAA,EAAS;AAAA;AAAA,EAClD,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,YAAA,EAAa;AAAA;AAAA,EACtD,EAAE,SAAA,EAAW,IAAA,WAAe,WAAA,EAAa,0BAAA;AAAO;AAClD;AACO,IAAM,UAAA,GAAa,IAAA;AACnB,IAAM,SAAA,GAAY;AAElB,IAAM,mBAAA,GAAsB;AAG5B,IAAM,aAAA,GAAgB","file":"constant.mjs","sourcesContent":["import { Language } from \"./provider/languageContext\";\n\nexport enum LocaleEnum {\n /** English */\n en = \"en\",\n /** Chinese */\n zh = \"zh\",\n /** Japanese */\n ja = \"ja\",\n /** Spanish */\n es = \"es\",\n /** Korean */\n ko = \"ko\",\n /** Vietnamese */\n vi = \"vi\",\n /** German */\n de = \"de\",\n /** French */\n fr = \"fr\",\n /** Russian */\n ru = \"ru\",\n /** Indonesian */\n id = \"id\",\n /** Turkish */\n tr = \"tr\",\n /** Italian */\n it = \"it\",\n /** Portuguese */\n pt = \"pt\",\n /** Ukrainian */\n uk = \"uk\",\n /** Polish */\n pl = \"pl\",\n /** Dutch */\n nl = \"nl\",\n /** Traditional Chinese */\n tc = \"tc\",\n}\n\nexport const defaultLanguages: Language[] = [\n { localCode: LocaleEnum.en, displayName: \"English\" }, // English\n { localCode: LocaleEnum.zh, displayName: \"中文\" }, // Chinese\n { localCode: LocaleEnum.ja, displayName: \"日本語\" }, // Japanese\n { localCode: LocaleEnum.es, displayName: \"Español\" }, // Spanish\n { localCode: LocaleEnum.ko, displayName: \"한국어\" }, // Korean\n { localCode: LocaleEnum.vi, displayName: \"Tiếng Việt\" }, // Vietnamese\n { localCode: LocaleEnum.de, displayName: \"Deutsch\" }, // German\n { localCode: LocaleEnum.fr, displayName: \"Français\" }, // French\n { localCode: LocaleEnum.ru, displayName: \"Русский\" }, // Russian\n { localCode: LocaleEnum.id, displayName: \"Bahasa Indonesia\" }, // Indonesian\n { localCode: LocaleEnum.tr, displayName: \"Türkçe\" }, // Turkish\n { localCode: LocaleEnum.it, displayName: \"Italiano\" }, // Italian\n { localCode: LocaleEnum.pt, displayName: \"Português\" }, // Portuguese\n { localCode: LocaleEnum.uk, displayName: \"Українська\" }, // Ukrainian\n { localCode: LocaleEnum.pl, displayName: \"Polski\" }, // Polish\n { localCode: LocaleEnum.nl, displayName: \"Nederlands\" }, // Dutch\n { localCode: LocaleEnum.tc, displayName: \"繁體中文\" }, // Traditional Chinese\n];\nexport const defaultLng = LocaleEnum.en;\nexport const defaultNS = \"translation\";\n\nexport const i18nLocalStorageKey = \"orderly_i18nLng\";\n\n// preferred-language\nexport const i18nCookieKey = \"orderly_i18nLng\";\n"]}
package/dist/index.d.mts CHANGED
@@ -1,44 +1,108 @@
1
- import { L as LocaleCode, R as Resources, a as LocaleContextState } from './constant-D_rlt5w0.mjs';
2
- export { b as Language, d as LocaleContext, f as LocaleEnum, e as LocaleMessages, P as PopupMode, c as PopupProps, g as defaultLanguages, h as defaultLng, i as defaultNS, l as en, k as i18nCookieKey, j as i18nLocalStorageKey, u as useLocaleContext } from './constant-D_rlt5w0.mjs';
1
+ import { R as Resources, A as AsyncResources, L as LocaleCode, a as LanguageContextState } from './constant-DkvDyddr.mjs';
2
+ export { b as Language, d as LanguageContext, f as LocaleEnum, e as LocaleMessages, P as PopupMode, c as PopupProps, g as defaultLanguages, h as defaultLng, i as defaultNS, l as en, k as i18nCookieKey, j as i18nLocalStorageKey, u as useLanguageContext } from './constant-DkvDyddr.mjs';
3
3
  import * as react_i18next from 'react-i18next';
4
- import { I18nextProviderProps, FallbackNs, UseTranslationOptions } from 'react-i18next';
4
+ import { FallbackNs, UseTranslationOptions } from 'react-i18next';
5
5
  export * from 'react-i18next';
6
6
  import * as i18next from 'i18next';
7
- import { FlatNamespace, KeyPrefix } from 'i18next';
7
+ import { InitOptions, FlatNamespace, KeyPrefix } from 'i18next';
8
8
  export { createInstance, default as i18next } from 'i18next';
9
- import { ReactNode } from 'react';
9
+ import { PropsWithChildren, FC } from 'react';
10
10
  import { $Tuple } from 'react-i18next/helpers';
11
11
  export { generatePath, getLocalePathFromPathname, parseI18nLang, removeLangPrefix } from './utils.mjs';
12
12
 
13
+ declare function createI18nInstance(options?: InitOptions): i18next.i18n;
13
14
  declare const i18n: i18next.i18n;
14
15
 
16
+ declare function registerResources(resources: Resources | AsyncResources | undefined, localeCode: LocaleCode): Promise<void>;
17
+
15
18
  type BackendOptions = {
16
19
  loadPath: (lang: LocaleCode, ns: string) => string | string[] | undefined;
17
20
  };
21
+ declare class Backend {
22
+ options: BackendOptions;
23
+ cache: Set<string>;
24
+ constructor(options: BackendOptions);
25
+ fetchData(url: string): Promise<any>;
26
+ loadLanguage(lang: LocaleCode, ns: string): Promise<void>;
27
+ }
18
28
 
19
- type I18nProviderProps = Partial<I18nextProviderProps>;
20
- declare const I18nProvider: React.FC<I18nProviderProps>;
21
- type LocaleProviderProps = {
22
- children: ReactNode;
23
- locale?: LocaleCode;
24
- resource?: Record<string, string>;
25
- resources?: Resources;
29
+ /**
30
+ * Register the default language bundle before your React tree renders to reduce
31
+ * flicker of raw translation keys.
32
+ */
33
+ declare const registerDefaultResource: (messages: Record<string, string>) => void;
34
+
35
+ /**
36
+ * Shape of a locale JSON file loaded via dynamic import / Vite `import.meta.glob`.
37
+ */
38
+ type LocaleJsonModule = {
39
+ default?: Record<string, string> | string | null;
40
+ };
41
+ declare function asMessageRecord(value: Record<string, string> | string | null | undefined): Record<string, string>;
42
+ /**
43
+ * Loads a locale JSON module via a Vite `import.meta.glob` loader or a dynamic `import()` thunk,
44
+ * and normalizes `default` to a flat message record.
45
+ * Missing `loader`, rejected `loader()`, or missing/invalid `default` yields `{}` (see {@link asMessageRecord}).
46
+ */
47
+ declare function importLocaleJsonModule(loader: (() => Promise<LocaleJsonModule>) | undefined): Promise<Record<string, string>>;
48
+
49
+ type LanguageProviderProps = PropsWithChildren<{
50
+ backend?: BackendOptions;
26
51
  /**
27
52
  * supported languages, you can select supported languages from default languages
28
53
  */
29
54
  supportedLanguages?: LocaleCode[];
30
- /**
31
- * @deprecated use onLanguageChanged instead, will be removed in next patch version
32
- */
33
- onLocaleChange?: (locale: LocaleCode) => void;
34
55
  /** optional conversion function to use to modify the detected language code */
35
56
  convertDetectedLanguage?: (lang: string) => LocaleCode;
36
- backend?: BackendOptions;
37
- } & Partial<LocaleContextState>;
38
- declare const LocaleProvider: React.FC<LocaleProviderProps>;
57
+ } & Partial<LanguageContextState>>;
58
+ declare const LanguageProvider: FC<LanguageProviderProps>;
59
+
60
+ type LocaleProviderProps = LanguageProviderProps & {
61
+ /** Active locale; when set and bundles exist, syncs i18n language via `changeLanguage`. */
62
+ locale?: LocaleCode;
63
+ /** Flat key-value messages for `defaultNS`; used together with `locale` when `resources` is not provided. */
64
+ resource?: Record<string, string>;
65
+ /**
66
+ * Preload locale bundles: static `Resources` map, or an async loader (same contract as
67
+ * `ExternalLocaleProvider`). When set, takes precedence over `locale` + `resource`.
68
+ */
69
+ resources?: Resources | AsyncResources;
70
+ };
71
+ declare const LocaleProvider: FC<LocaleProviderProps>;
72
+
73
+ type ExternalLocaleProviderProps = PropsWithChildren<{
74
+ resources?: Resources | AsyncResources;
75
+ }>;
76
+ /**
77
+ * ExternalLocaleProvider lets host applications inject i18n resources that live
78
+ * outside of this package (e.g. from another bundle, backend, or runtime loader).
79
+ *
80
+ * - When `resources` is a function, it will be invoked whenever the locale changes
81
+ * to lazily fetch the latest bundle for that locale.
82
+ * - When `resources` is a static map, all provided locale bundles are registered
83
+ * synchronously on mount.
84
+ *
85
+ * This component renders no UI; it only manages i18n side effects and simply
86
+ * returns its children. Same behavior as calling `useRegisterExternalResources(resources)`
87
+ * in your own component under `LocaleProvider`.
88
+ */
89
+ declare const ExternalLocaleProvider: FC<ExternalLocaleProviderProps>;
39
90
 
40
91
  declare function useTranslation<Ns extends FlatNamespace | $Tuple<FlatNamespace> | undefined, KPrefix extends KeyPrefix<FallbackNs<Ns>> = undefined>(ns?: Ns, options?: UseTranslationOptions<KPrefix>): react_i18next.UseTranslationResponse<FallbackNs<Ns>, KPrefix>;
41
92
 
42
93
  declare function useLocaleCode(): LocaleCode;
43
94
 
44
- export { I18nProvider, type I18nProviderProps, LocaleCode, LocaleContextState, LocaleProvider, type LocaleProviderProps, Resources, i18n, useLocaleCode, useTranslation };
95
+ /**
96
+ * Registers host-provided i18n resources into the shared i18n instance whenever
97
+ * the active locale or `resources` reference changes.
98
+ *
99
+ * - When `resources` is a function, it is invoked for the current locale to
100
+ * load the bundle (e.g. from another bundle, backend, or runtime loader).
101
+ * - When `resources` is a static map, all provided locale bundles are registered.
102
+ *
103
+ * Prefer a stable `resources` reference (e.g. `useCallback` for loaders, module
104
+ * scope or `useMemo` for static maps) to avoid unnecessary re-registration.
105
+ */
106
+ declare function useRegisterExternalResources(resources?: Resources | AsyncResources): void;
107
+
108
+ export { AsyncResources, Backend, type BackendOptions, ExternalLocaleProvider, type ExternalLocaleProviderProps, LanguageContextState, LanguageProvider, type LanguageProviderProps, LocaleCode, type LocaleJsonModule, LocaleProvider, type LocaleProviderProps, Resources, asMessageRecord, createI18nInstance, i18n, importLocaleJsonModule, registerDefaultResource, registerResources, useLocaleCode, useRegisterExternalResources, useTranslation };
package/dist/index.d.ts CHANGED
@@ -1,44 +1,108 @@
1
- import { L as LocaleCode, R as Resources, a as LocaleContextState } from './constant-D_rlt5w0.js';
2
- export { b as Language, d as LocaleContext, f as LocaleEnum, e as LocaleMessages, P as PopupMode, c as PopupProps, g as defaultLanguages, h as defaultLng, i as defaultNS, l as en, k as i18nCookieKey, j as i18nLocalStorageKey, u as useLocaleContext } from './constant-D_rlt5w0.js';
1
+ import { R as Resources, A as AsyncResources, L as LocaleCode, a as LanguageContextState } from './constant-DkvDyddr.js';
2
+ export { b as Language, d as LanguageContext, f as LocaleEnum, e as LocaleMessages, P as PopupMode, c as PopupProps, g as defaultLanguages, h as defaultLng, i as defaultNS, l as en, k as i18nCookieKey, j as i18nLocalStorageKey, u as useLanguageContext } from './constant-DkvDyddr.js';
3
3
  import * as react_i18next from 'react-i18next';
4
- import { I18nextProviderProps, FallbackNs, UseTranslationOptions } from 'react-i18next';
4
+ import { FallbackNs, UseTranslationOptions } from 'react-i18next';
5
5
  export * from 'react-i18next';
6
6
  import * as i18next from 'i18next';
7
- import { FlatNamespace, KeyPrefix } from 'i18next';
7
+ import { InitOptions, FlatNamespace, KeyPrefix } from 'i18next';
8
8
  export { createInstance, default as i18next } from 'i18next';
9
- import { ReactNode } from 'react';
9
+ import { PropsWithChildren, FC } from 'react';
10
10
  import { $Tuple } from 'react-i18next/helpers';
11
11
  export { generatePath, getLocalePathFromPathname, parseI18nLang, removeLangPrefix } from './utils.js';
12
12
 
13
+ declare function createI18nInstance(options?: InitOptions): i18next.i18n;
13
14
  declare const i18n: i18next.i18n;
14
15
 
16
+ declare function registerResources(resources: Resources | AsyncResources | undefined, localeCode: LocaleCode): Promise<void>;
17
+
15
18
  type BackendOptions = {
16
19
  loadPath: (lang: LocaleCode, ns: string) => string | string[] | undefined;
17
20
  };
21
+ declare class Backend {
22
+ options: BackendOptions;
23
+ cache: Set<string>;
24
+ constructor(options: BackendOptions);
25
+ fetchData(url: string): Promise<any>;
26
+ loadLanguage(lang: LocaleCode, ns: string): Promise<void>;
27
+ }
18
28
 
19
- type I18nProviderProps = Partial<I18nextProviderProps>;
20
- declare const I18nProvider: React.FC<I18nProviderProps>;
21
- type LocaleProviderProps = {
22
- children: ReactNode;
23
- locale?: LocaleCode;
24
- resource?: Record<string, string>;
25
- resources?: Resources;
29
+ /**
30
+ * Register the default language bundle before your React tree renders to reduce
31
+ * flicker of raw translation keys.
32
+ */
33
+ declare const registerDefaultResource: (messages: Record<string, string>) => void;
34
+
35
+ /**
36
+ * Shape of a locale JSON file loaded via dynamic import / Vite `import.meta.glob`.
37
+ */
38
+ type LocaleJsonModule = {
39
+ default?: Record<string, string> | string | null;
40
+ };
41
+ declare function asMessageRecord(value: Record<string, string> | string | null | undefined): Record<string, string>;
42
+ /**
43
+ * Loads a locale JSON module via a Vite `import.meta.glob` loader or a dynamic `import()` thunk,
44
+ * and normalizes `default` to a flat message record.
45
+ * Missing `loader`, rejected `loader()`, or missing/invalid `default` yields `{}` (see {@link asMessageRecord}).
46
+ */
47
+ declare function importLocaleJsonModule(loader: (() => Promise<LocaleJsonModule>) | undefined): Promise<Record<string, string>>;
48
+
49
+ type LanguageProviderProps = PropsWithChildren<{
50
+ backend?: BackendOptions;
26
51
  /**
27
52
  * supported languages, you can select supported languages from default languages
28
53
  */
29
54
  supportedLanguages?: LocaleCode[];
30
- /**
31
- * @deprecated use onLanguageChanged instead, will be removed in next patch version
32
- */
33
- onLocaleChange?: (locale: LocaleCode) => void;
34
55
  /** optional conversion function to use to modify the detected language code */
35
56
  convertDetectedLanguage?: (lang: string) => LocaleCode;
36
- backend?: BackendOptions;
37
- } & Partial<LocaleContextState>;
38
- declare const LocaleProvider: React.FC<LocaleProviderProps>;
57
+ } & Partial<LanguageContextState>>;
58
+ declare const LanguageProvider: FC<LanguageProviderProps>;
59
+
60
+ type LocaleProviderProps = LanguageProviderProps & {
61
+ /** Active locale; when set and bundles exist, syncs i18n language via `changeLanguage`. */
62
+ locale?: LocaleCode;
63
+ /** Flat key-value messages for `defaultNS`; used together with `locale` when `resources` is not provided. */
64
+ resource?: Record<string, string>;
65
+ /**
66
+ * Preload locale bundles: static `Resources` map, or an async loader (same contract as
67
+ * `ExternalLocaleProvider`). When set, takes precedence over `locale` + `resource`.
68
+ */
69
+ resources?: Resources | AsyncResources;
70
+ };
71
+ declare const LocaleProvider: FC<LocaleProviderProps>;
72
+
73
+ type ExternalLocaleProviderProps = PropsWithChildren<{
74
+ resources?: Resources | AsyncResources;
75
+ }>;
76
+ /**
77
+ * ExternalLocaleProvider lets host applications inject i18n resources that live
78
+ * outside of this package (e.g. from another bundle, backend, or runtime loader).
79
+ *
80
+ * - When `resources` is a function, it will be invoked whenever the locale changes
81
+ * to lazily fetch the latest bundle for that locale.
82
+ * - When `resources` is a static map, all provided locale bundles are registered
83
+ * synchronously on mount.
84
+ *
85
+ * This component renders no UI; it only manages i18n side effects and simply
86
+ * returns its children. Same behavior as calling `useRegisterExternalResources(resources)`
87
+ * in your own component under `LocaleProvider`.
88
+ */
89
+ declare const ExternalLocaleProvider: FC<ExternalLocaleProviderProps>;
39
90
 
40
91
  declare function useTranslation<Ns extends FlatNamespace | $Tuple<FlatNamespace> | undefined, KPrefix extends KeyPrefix<FallbackNs<Ns>> = undefined>(ns?: Ns, options?: UseTranslationOptions<KPrefix>): react_i18next.UseTranslationResponse<FallbackNs<Ns>, KPrefix>;
41
92
 
42
93
  declare function useLocaleCode(): LocaleCode;
43
94
 
44
- export { I18nProvider, type I18nProviderProps, LocaleCode, LocaleContextState, LocaleProvider, type LocaleProviderProps, Resources, i18n, useLocaleCode, useTranslation };
95
+ /**
96
+ * Registers host-provided i18n resources into the shared i18n instance whenever
97
+ * the active locale or `resources` reference changes.
98
+ *
99
+ * - When `resources` is a function, it is invoked for the current locale to
100
+ * load the bundle (e.g. from another bundle, backend, or runtime loader).
101
+ * - When `resources` is a static map, all provided locale bundles are registered.
102
+ *
103
+ * Prefer a stable `resources` reference (e.g. `useCallback` for loaders, module
104
+ * scope or `useMemo` for static maps) to avoid unnecessary re-registration.
105
+ */
106
+ declare function useRegisterExternalResources(resources?: Resources | AsyncResources): void;
107
+
108
+ export { AsyncResources, Backend, type BackendOptions, ExternalLocaleProvider, type ExternalLocaleProviderProps, LanguageContextState, LanguageProvider, type LanguageProviderProps, LocaleCode, type LocaleJsonModule, LocaleProvider, type LocaleProviderProps, Resources, asMessageRecord, createI18nInstance, i18n, importLocaleJsonModule, registerDefaultResource, registerResources, useLocaleCode, useRegisterExternalResources, useTranslation };