@orderly.network/i18n 3.0.0-beta.0 → 3.0.0-beta.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.
Files changed (57) hide show
  1. package/README.md +23 -469
  2. package/dist/{constant-BeXwHrGj.d.mts → constant-DkvDyddr.d.mts} +37 -40
  3. package/dist/{constant-BeXwHrGj.d.ts → constant-DkvDyddr.d.ts} +37 -40
  4. package/dist/constant.d.mts +1 -1
  5. package/dist/constant.d.ts +1 -1
  6. package/dist/constant.js.map +1 -1
  7. package/dist/constant.mjs.map +1 -1
  8. package/dist/index.d.mts +69 -30
  9. package/dist/index.d.ts +69 -30
  10. package/dist/index.js +140 -118
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +132 -115
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/locale.csv +33 -106
  15. package/dist/locales/de.json +33 -38
  16. package/dist/locales/en.json +33 -38
  17. package/dist/locales/es.json +33 -38
  18. package/dist/locales/fr.json +33 -38
  19. package/dist/locales/id.json +33 -38
  20. package/dist/locales/it.json +33 -38
  21. package/dist/locales/ja.json +33 -38
  22. package/dist/locales/ko.json +33 -38
  23. package/dist/locales/nl.json +33 -38
  24. package/dist/locales/pl.json +33 -38
  25. package/dist/locales/pt.json +33 -38
  26. package/dist/locales/ru.json +33 -38
  27. package/dist/locales/tc.json +33 -38
  28. package/dist/locales/tr.json +33 -38
  29. package/dist/locales/uk.json +33 -38
  30. package/dist/locales/vi.json +33 -38
  31. package/dist/locales/zh.json +33 -38
  32. package/dist/utils.d.mts +1 -1
  33. package/dist/utils.d.ts +1 -1
  34. package/dist/utils.js +40 -45
  35. package/dist/utils.js.map +1 -1
  36. package/dist/utils.mjs +40 -45
  37. package/dist/utils.mjs.map +1 -1
  38. package/docs/guide/AGENTS.md +109 -0
  39. package/docs/guide/cli.md +133 -0
  40. package/docs/guide/examples.md +455 -0
  41. package/docs/guide/exports.md +14 -0
  42. package/docs/guide/integration.md +223 -0
  43. package/docs/guide/utils.md +14 -0
  44. package/package.json +8 -6
  45. package/scripts/copyLocales.js +11 -0
  46. package/scripts/csv2json.js +28 -0
  47. package/scripts/diffCsv.js +175 -0
  48. package/scripts/fillJson.js +33 -0
  49. package/scripts/filterLocaleKeys.js +127 -0
  50. package/scripts/generateCsv.js +36 -0
  51. package/scripts/generateEnJson.js +11 -0
  52. package/scripts/generateMissingKeys.js +49 -0
  53. package/scripts/json-csv-converter.js +286 -0
  54. package/scripts/json2csv.js +38 -0
  55. package/scripts/mergeJson.js +67 -0
  56. package/scripts/separateJson.js +50 -0
  57. package/scripts/utils.js +94 -0
package/dist/index.mjs CHANGED
@@ -94,6 +94,10 @@ var affiliate = {
94
94
  "affiliate.referralCode.label": "Enter referral code",
95
95
  "affiliate.referralCode.bound": "Referral code bound",
96
96
  "affiliate.referralCode.notExist": "This referral code does not exist.",
97
+ "affiliate.referralCode.bind.modal.title": "Were you referred by someone?",
98
+ "affiliate.referralCode.bind.modal.description": "If an affiliate shared their referral code with you, enter it below to bind your account and receive affiliate benefits.",
99
+ "affiliate.referralCode.bind.input.placeholder": "Enter referrer's code",
100
+ "affiliate.referralCode.bind.skip": "No, I was not referred by anyone",
97
101
  "affiliate.process.title": "How It Works",
98
102
  "affiliate.process.step1.title": "Trade $10,000+ or apply",
99
103
  "affiliate.process.step1.description": "Unlock a referral code automatically ($0 of $10,000 completed - main account only), or apply for a higher rate via the form.",
@@ -125,7 +129,7 @@ var affiliate = {
125
129
  "affiliate.base": "Affiliate",
126
130
  "affiliate.directBonus": "Direct bonus",
127
131
  "affiliate.commission.30d": "30d commission",
128
- "affiliate.commission.column.activeUsers": "Referral active users",
132
+ "affiliate.commission.column.activeUsers": "New traders",
129
133
  "affiliate.myReferees": "My referees",
130
134
  "affiliate.referees": "Referees",
131
135
  "affiliate.referees.column.refereeAddress": "Referee address",
@@ -155,6 +159,7 @@ var affiliate = {
155
159
  "affiliate.direct": "Direct",
156
160
  "affiliate.directInclBonus": "Incl. {{amount}} bonus",
157
161
  "affiliate.indirect": "Indirect",
162
+ "affiliate.referredBy": "Referred by {{name}}",
158
163
  "affiliate.referrals": "Referrals",
159
164
  "affiliate.referralCode.edit.modal.title": "Configure your referral settings",
160
165
  "affiliate.referralCode.create": "Create referral code",
@@ -460,6 +465,7 @@ var markets = {
460
465
  "markets.favorites": "Favorites",
461
466
  "markets.recent": "Recent",
462
467
  "markets.newListings": "New listings",
468
+ "markets.community": "Community",
463
469
  "markets.allMarkets": "All markets",
464
470
  "markets.openInterest": "Open interest",
465
471
  "markets.openInterest.tooltip": "Total size of positions per side.",
@@ -509,7 +515,13 @@ var markets = {
509
515
  "markets.symbolInfoBar.24hVolume": "24h volume",
510
516
  "markets.symbolInfoBar.24hVolume.tooltip": "24 hour total trading volume on the Orderly Network.",
511
517
  "markets.symbolInfoBar.predFundingRate": "Est. funding rate",
512
- "markets.symbolInfoBar.predFundingRate.tooltip": "Funding rates are payments between traders who are long and short. When positive, long positions pay short positions funding. When negative, short positions pay long positions."
518
+ "markets.symbolInfoBar.predFundingRate.tooltip": "Funding rates are payments between traders who are long and short. When positive, long positions pay short positions funding. When negative, short positions pay long positions.",
519
+ "markets.symbolInfoBar.riskNotice.content": "{{symbolWithBroker}} is a permissionless listing supported on Isolated Margin only, deployed and operated independently by {{brokerName}}. Please be aware of elevated risks, including low liquidity, high volatility, and increased liquidation risk."
520
+ };
521
+
522
+ // src/locale/module/navigation.ts
523
+ var navigation = {
524
+ "tradingPoints.points": "Points"
513
525
  };
514
526
 
515
527
  // src/locale/module/notification.ts
@@ -554,6 +566,7 @@ var orderEntry = {
554
566
  "orderEntry.orderType.ioc.tooltip": "Executes immediately; any unfilled amount is canceled.",
555
567
  "orderEntry.orderType.fok": "FOK",
556
568
  "orderEntry.orderType.fok.tooltip": "Executes immediately in full, or is canceled entirely.",
569
+ "orderEntry.orderType.symbolPostOnly.tooltip": "This symbol is in POST_ONLY mode. Only limit orders are accepted until the order book is ready.",
557
570
  "orderEntry.orderType.scaledOrder": "Scaled",
558
571
  "orderEntry.orderType.trailingStop": "Trailing stop",
559
572
  "orderEntry.orderSize": "Order size",
@@ -626,10 +639,13 @@ var orderEntry = {
626
639
  "marginMode.current": "Current",
627
640
  "marginMode.marginModeSettings": "Margin mode settings",
628
641
  "marginMode.updatedSuccessfully": "Updated successfully",
642
+ "marginMode.noEditableSymbolsSelected": "No editable symbols selected",
643
+ "marginMode.failedToUpdateMarginMode": "Failed to update margin mode",
629
644
  "marginMode.perpetualFutures": "Perpetual futures",
630
645
  "marginMode.searchPlaceholder": "Search",
631
646
  "marginMode.selectAll": "Select all",
632
647
  "marginMode.setAs": "Set as",
648
+ "marginMode.disabledSymbolTooltip": "This symbol is independently operated by a third party. Isolated Margin is enforced to prevent risk from affecting your other positions.",
633
649
  "orderEntry.startPrice.error.required": "Start price is required",
634
650
  "orderEntry.startPrice.error.min": "Start price must be greater than {{value}}",
635
651
  "orderEntry.startPrice.error.max": "Start price must be less than {{value}}",
@@ -658,7 +674,12 @@ var orderEntry = {
658
674
  "orderEntry.reduceOnly.reminder": "Reduce-only reminder",
659
675
  "orderEntry.reduceOnly.reminder.content": "Your account is in reduce-only and cannot open new positions. Would you like to turn off reduce-only mode and proceed with the\xA0order?",
660
676
  "orderEntry.placeOrderNow": "Place order now",
661
- "orderEntry.maxQty.reminder.content": "Order qty reduced to max available: {{maxQty}}"
677
+ "orderEntry.maxQty.reminder.content": "Order qty reduced to max available: {{maxQty}}",
678
+ "orderEntry.permissionlessNotice.title": "Community-Listed Market Notice",
679
+ "orderEntry.permissionlessNotice.content1": "This market was listed by a third-party deployer through the permissionless listing system.",
680
+ "orderEntry.permissionlessNotice.content2": "It is not created, reviewed, or endorsed by Orderly. Such markets may involve low liquidity, high volatility, incomplete information, or increased liquidation risk.",
681
+ "orderEntry.permissionlessNotice.content3": "Please review the deployer's documentation and trade at your own risk.",
682
+ "orderEntry.permissionlessNotice.checkbox": "I understand this is a community-listed market and accept the risks."
662
683
  };
663
684
 
664
685
  // src/locale/module/orders.ts
@@ -725,6 +746,8 @@ var portfolio = {
725
746
  "portfolio.overview.performance.cumulativePnl": "Cumulative PnL",
726
747
  "portfolio.overview.performance.dailyVolume": "Daily Volume",
727
748
  "portfolio.overview.performance.cumulativeVolume": "Cumulative Volume",
749
+ "portfolio.overview.todaysPnl": "Today's PnL",
750
+ "portfolio.overview.todaysVol": "Today's Vol",
728
751
  "portfolio.overview.distribution": "Distribution",
729
752
  "portfolio.overview.transferHistory": "Transfer history",
730
753
  "portfolio.overview.vaults": "Vaults",
@@ -1058,6 +1081,7 @@ var trading = {
1058
1081
  "trading.rwa.tooltip.openIn": "Regular trading hours will open in <0>{{timeFormat}}</0>",
1059
1082
  "trading.rwa.tooltip.checkDetailRules": "Check detail rules",
1060
1083
  "trading.rwa.countdown.title": "US markets are closing soon, volatility may be lower.",
1084
+ "trading.symbolDelisting": "{{symbol}} has entered forced deleveraging mode (insufficient liquidity depth / insufficient IF balance). Your position on this symbol only allows closing operations.",
1061
1085
  "trading.rwa.outsideMarketHours.notify": "This market is currently outside regular trading hours. You can still place a trade, but please be aware of reduced liquidity and potential risks.",
1062
1086
  "trading.rwa.mWeb.outsideMarketHours.desc": "Regular trading hours are about to close - 24/7 trading continues; price may slow and liquidity may be lower.",
1063
1087
  "trading.rwa.mWeb.insideMarketHours.desc": "Regular trading hours are about to open - get ready."
@@ -1101,46 +1125,6 @@ var tradingLeaderboard = {
1101
1125
  "tradingLeaderboard.tradingVolume.tooltip": "Total trading volume generated during the campaign period. Updated every 30 seconds."
1102
1126
  };
1103
1127
 
1104
- // src/locale/module/tradingPoints.ts
1105
- var tradingPoints = {
1106
- "tradingPoints.points": "Points",
1107
- "tradingPoints.startsIn": "Starts in",
1108
- "tradingPoints.days": "Days",
1109
- "tradingPoints.hours": "Hours",
1110
- "tradingPoints.minutes": "Minutes",
1111
- "tradingPoints.seconds": "Seconds",
1112
- "tradingPoints.learnMore": "Learn more",
1113
- "tradingPoints.stagePoints": "Stage points",
1114
- "tradingPoints.stageRanking": "Stage ranking",
1115
- "tradingPoints.referralCode": "Referral code",
1116
- "tradingPoints.referralLink": "Referral link",
1117
- "tradingPoints.currentPoints": "Current points",
1118
- "tradingPoints.ranking": "Ranking",
1119
- "tradingPoints.myPoints": "My points",
1120
- "tradingPoints.thisWeek": "This week",
1121
- "tradingPoints.lastWeek": "Last week",
1122
- "tradingPoints.all": "All",
1123
- "tradingPoints.tradePoints": "Trade points",
1124
- "tradingPoints.tradePointsTooltip": "Trade Points are calculated based on your perps trading volume.Updated daily.",
1125
- "tradingPoints.tradeNow": "Trade now",
1126
- "tradingPoints.pnlPoints": "PNL points",
1127
- "tradingPoints.pnlPointsTooltip": "Both profit or loss of each trade will be recorded. Updated daily.",
1128
- "tradingPoints.referralPoints": "Referral points",
1129
- "tradingPoints.referralPointsTooltip": "First-level invitee's rebates: {{l1}}%, Second-level invitee's rebates: {{l2}}%, Update daily.",
1130
- "tradingPoints.copyLink": "Copy Link",
1131
- "tradingPoints.faq.title": "FAQ",
1132
- "tradingPoints.faq.whatArePoints.question": "What are Points?",
1133
- "tradingPoints.faq.whatArePoints.answer": "The Points program is designed to encourage genuine user engagement with products and to reward loyal users who actively contribute to the growth of the {{brokerName}} ecosystem. Rewards will be airdropped in the future based on users' point accumulation.",
1134
- "tradingPoints.faq.allocation.question": "What is the points allocation criteria?",
1135
- "tradingPoints.faq.allocation.answer": "Points = Trade points + PNL points + Referral points.\n\nThe page will update your points daily, calculating the points you are expected to receive based on your contribution.\n\nNote: Wash trading (e.g., self-trades) will not receive any points",
1136
- "tradingPoints.faq.distribution.question": "When will points be distributed?",
1137
- "tradingPoints.faq.distribution.answer": "Points are distributed at 08:00 UTC everyday.",
1138
- "tradingPoints.faq.pnl.question": "How are PNL points calculated?",
1139
- "tradingPoints.faq.pnl.answer": "Points are based on your net profit or loss each trading.",
1140
- "tradingPoints.faq.referral.question": "How does the referral work?",
1141
- "tradingPoints.faq.referral.answer": "Based on the total points of your invitees and their invitees. Points earned from first-level invitees are higher than those from second-level invitees. Updated daily."
1142
- };
1143
-
1144
1128
  // src/locale/module/tradingRewards.ts
1145
1129
  var tradingRewards = {
1146
1130
  "tradingRewards.rewards": "Rewards",
@@ -1194,6 +1178,7 @@ var tradingView = {
1194
1178
  "tradingView.displayControl.buySell": "Buy/Sell",
1195
1179
  "tradingView.displayControl.limitOrders": "Limit orders",
1196
1180
  "tradingView.displayControl.stopOrders": "Stop orders",
1181
+ "tradingView.displayControl.liquidationPrice": "Liquidation Price",
1197
1182
  "tradingView.noScriptSrc": "Due to TradingView's policy, you will need to apply for your own license.",
1198
1183
  "tradingView.noScriptSrc.1": "1. Please apply for your TradingView Advanced Chart license <0>here</0>",
1199
1184
  "tradingView.noScriptSrc.2": "2. Follow the instructions on <0>orderly.network</0> to set up."
@@ -1216,10 +1201,20 @@ var transfer = {
1216
1201
  "transfer.deposit.requested": "Deposit requested",
1217
1202
  "transfer.deposit.completed": "Deposit completed",
1218
1203
  "transfer.deposit.failed": "Deposit failed",
1204
+ "transfer.exclusiveDeposit.warning": "Only send {{token}} on {{network}} to this address. Sending other tokens, using other chains, or amounts below the minimum deposit will result in permanent loss of funds.",
1205
+ "transfer.exclusiveDeposit.selectFirst": "Select your network and token first",
1206
+ "transfer.exclusiveDeposit.selectNetwork": "Select network",
1207
+ "transfer.exclusiveDeposit.selectToken": "Select token",
1208
+ "transfer.exclusiveDeposit.minDeposit": "Min. deposit",
1209
+ "transfer.exclusiveDeposit.estimatedTime": "Estimated time",
1210
+ "transfer.exclusiveDeposit.estimatedTime.default": "~ 5 min",
1211
+ "transfer.exclusiveDeposit.depositPending": "Deposit pending: {{amount}} {{symbol}}",
1219
1212
  "transfer.deposit.feeUnavailable": "Fee data is currently unavailable. Please try again later.",
1220
1213
  "transfer.deposit.notEnoughGas": "Not enough gas. Add some {{token}} to your wallet to continue.",
1221
1214
  "transfer.deposit.exceedCap": "Amount exceeds user deposit cap",
1222
1215
  "transfer.deposit.closeToMaxLimit": "Deposit amount too close to maximum limit. To ensure your transaction succeeds, please reduce the amount",
1216
+ "transfer.deposit.tab.connectedWallet": "From connected wallet",
1217
+ "transfer.deposit.tab.exchangeOrOtherWallet": "From exchange / other wallet",
1223
1218
  "transfer.deposit.estGasFee": "Est. gas fee",
1224
1219
  "transfer.deposit.estGasFee.tooltip": "Estimated gas fee includes: transaction execution cost on this chain, and destination chain operation fee for Orderly deposit. Please prepare extra to ensure sufficient coverage.",
1225
1220
  "transfer.deposit.destinationGasFee": "Destination gas fee",
@@ -1474,10 +1469,10 @@ var en = {
1474
1469
  ...affiliate,
1475
1470
  ...ui,
1476
1471
  ...tradingLeaderboard,
1477
- ...tradingPoints,
1478
1472
  ...widget,
1479
1473
  ...vaults,
1480
- ...notification
1474
+ ...notification,
1475
+ ...navigation
1481
1476
  };
1482
1477
 
1483
1478
  // src/i18n.ts
@@ -1505,8 +1500,30 @@ var i18n = createI18nInstance({
1505
1500
  });
1506
1501
  i18n.init();
1507
1502
  var i18n_default = i18n;
1503
+ var LanguageContext = createContext({
1504
+ languages: [],
1505
+ onLanguageBeforeChanged: () => Promise.resolve(),
1506
+ onLanguageChanged: () => Promise.resolve()
1507
+ });
1508
+ var useLanguageContext = () => {
1509
+ return useContext(LanguageContext);
1510
+ };
1511
+
1512
+ // src/resourceBundles/registerResources.ts
1513
+ async function registerResources(resources2, localeCode) {
1514
+ if (typeof resources2 === "function") {
1515
+ const resource = await resources2(localeCode, defaultNS);
1516
+ i18n_default.addResourceBundle(localeCode, defaultNS, resource, true, true);
1517
+ return;
1518
+ }
1519
+ if (resources2) {
1520
+ Object.entries(resources2).forEach(([locale, messages]) => {
1521
+ i18n_default.addResourceBundle(locale, defaultNS, messages, true, true);
1522
+ });
1523
+ }
1524
+ }
1508
1525
 
1509
- // src/backend.ts
1526
+ // src/resourceBundles/httpBackend.ts
1510
1527
  var Backend = class {
1511
1528
  constructor(options) {
1512
1529
  this.options = options;
@@ -1550,15 +1567,38 @@ var Backend = class {
1550
1567
  await Promise.all(promises);
1551
1568
  }
1552
1569
  };
1553
- var LocaleContext = createContext({
1554
- languages: [],
1555
- onLanguageBeforeChanged: () => Promise.resolve(),
1556
- onLanguageChanged: () => Promise.resolve()
1557
- });
1558
- var useLocaleContext = () => {
1559
- return useContext(LocaleContext);
1570
+
1571
+ // src/resourceBundles/registerDefaultResource.ts
1572
+ var registerDefaultResource = (messages) => {
1573
+ i18n_default.addResourceBundle(defaultLng, defaultNS, messages, true, true);
1560
1574
  };
1561
1575
 
1576
+ // src/resourceBundles/importLocaleJsonModule.ts
1577
+ function asMessageRecord(value) {
1578
+ if (!value) {
1579
+ return {};
1580
+ }
1581
+ if (typeof value !== "string") {
1582
+ return value;
1583
+ }
1584
+ try {
1585
+ return JSON.parse(value);
1586
+ } catch {
1587
+ return {};
1588
+ }
1589
+ }
1590
+ async function importLocaleJsonModule(loader) {
1591
+ if (!loader) {
1592
+ return asMessageRecord(void 0);
1593
+ }
1594
+ try {
1595
+ const mod = await loader();
1596
+ return asMessageRecord(mod.default);
1597
+ } catch {
1598
+ return {};
1599
+ }
1600
+ }
1601
+
1562
1602
  // src/utils.ts
1563
1603
  function parseI18nLang(lang, localeCodes, defaultLang) {
1564
1604
  localeCodes = localeCodes || Object.values(LocaleEnum);
@@ -1596,19 +1636,9 @@ function generatePath(params) {
1596
1636
  localePath = locale || parseI18nLang(i18n_default.language);
1597
1637
  return `/${localePath}${path}${searchUrl}`;
1598
1638
  }
1599
- var I18nProvider = (props) => {
1600
- const { children, ...rest } = props;
1601
- return (
1602
- // @ts-ignore
1603
- /* @__PURE__ */ jsx(I18nextProvider, { ...rest, children })
1604
- );
1605
- };
1606
- var LocaleProvider = (props) => {
1639
+ var LanguageProvider = (props) => {
1607
1640
  const {
1608
1641
  children,
1609
- locale,
1610
- resource,
1611
- resources: resources2,
1612
1642
  backend,
1613
1643
  popup,
1614
1644
  supportedLanguages,
@@ -1618,22 +1648,6 @@ var LocaleProvider = (props) => {
1618
1648
  } = props;
1619
1649
  const [languages, setLanguages] = useState(defaultLanguages);
1620
1650
  const backendRef = useRef(new Backend(backend));
1621
- useEffect(() => {
1622
- if (resources2) {
1623
- Object.entries(resources2).forEach(([locale2, messages]) => {
1624
- i18n_default.addResourceBundle(locale2, defaultNS, messages, true, true);
1625
- });
1626
- return;
1627
- }
1628
- if (resource && locale) {
1629
- i18n_default.addResourceBundle(locale, defaultNS, resource, true, true);
1630
- }
1631
- }, [locale, resource, resources2]);
1632
- useEffect(() => {
1633
- if (locale && locale !== i18n_default.language) {
1634
- i18n_default.changeLanguage(locale);
1635
- }
1636
- }, [locale]);
1637
1651
  useEffect(() => {
1638
1652
  if (Array.isArray(props.languages)) {
1639
1653
  setLanguages(props.languages);
@@ -1644,7 +1658,7 @@ var LocaleProvider = (props) => {
1644
1658
  ).filter((item) => !!item)
1645
1659
  );
1646
1660
  }
1647
- }, [supportedLanguages, props.languages]);
1661
+ }, [props.languages, supportedLanguages]);
1648
1662
  useEffect(() => {
1649
1663
  const initLanguage = async () => {
1650
1664
  const lang = typeof convertDetectedLanguage === "function" ? convertDetectedLanguage(i18n_default.language) : parseI18nLang(i18n_default.language);
@@ -1676,60 +1690,63 @@ var LocaleProvider = (props) => {
1676
1690
  onLanguageChanged: languageChangedHandle
1677
1691
  };
1678
1692
  }, [popup, languages, languageBeforeChangedHandle, languageChangedHandle]);
1679
- return /* @__PURE__ */ jsx(LocaleContext.Provider, { value: memoizedValue, children: /* @__PURE__ */ jsx(I18nextProvider, { i18n: i18n_default, defaultNS, children }) });
1693
+ return /* @__PURE__ */ jsx(LanguageContext.Provider, { value: memoizedValue, children });
1680
1694
  };
1681
- function useTranslation(ns, options) {
1682
- const context = useContext(I18nContext);
1683
- return useTranslation$1(ns, {
1684
- i18n: context?.i18n || i18n_default,
1685
- // @ts-ignore
1686
- // when the language resource is loaded, notify the translation component to re-render
1687
- bindI18nStore: "added",
1688
- ...options
1689
- });
1690
- }
1691
1695
  function useLocaleCode() {
1692
- const [loacaleCode, setLoacaleCode] = useState(
1696
+ const [localeCode, setLocaleCode] = useState(
1693
1697
  parseI18nLang(i18n_default.language)
1694
1698
  );
1695
1699
  useEffect(() => {
1696
1700
  const handleLanguageChange = (lng) => {
1697
- setLoacaleCode(lng);
1701
+ setLocaleCode(lng);
1698
1702
  };
1699
1703
  i18n_default.on("languageChanged", handleLanguageChange);
1700
1704
  return () => {
1701
1705
  i18n_default.off("languageChanged", handleLanguageChange);
1702
1706
  };
1703
1707
  }, [i18n_default]);
1704
- return loacaleCode;
1708
+ return localeCode;
1705
1709
  }
1706
-
1707
- // src/external/utils.ts
1708
- var preloadDefaultResource = (messages) => {
1709
- i18n_default.addResourceBundle(defaultLng, defaultNS, messages, true, true);
1710
- };
1711
- var asyncAddResource = async (localeCode, resources2) => {
1712
- const resource = await resources2(localeCode, defaultNS);
1713
- i18n_default.addResourceBundle(localeCode, defaultNS, resource, true, true);
1714
- };
1715
- var ExternalLocaleProvider = (props) => {
1716
- const { resources: resources2 } = props;
1717
- const localeCode = useLocaleCode();
1710
+ var LocaleProvider = (props) => {
1711
+ const { children, locale, resource, resources: resources2, ...languageProviderProps } = props;
1712
+ const localeCodeFromI18n = useLocaleCode();
1718
1713
  useEffect(() => {
1719
- if (typeof resources2 === "function") {
1720
- asyncAddResource(localeCode, resources2);
1721
- return;
1722
- }
1723
1714
  if (resources2) {
1724
- Object.entries(resources2).forEach(([locale, messages]) => {
1725
- i18n_default.addResourceBundle(locale, defaultNS, messages, true, true);
1726
- });
1715
+ registerResources(resources2, locale ?? localeCodeFromI18n);
1727
1716
  return;
1728
1717
  }
1718
+ if (resource && locale) {
1719
+ i18n_default.addResourceBundle(locale, defaultNS, resource, true, true);
1720
+ }
1721
+ }, [locale, localeCodeFromI18n, resource, resources2]);
1722
+ useEffect(() => {
1723
+ if (locale && locale !== i18n_default.language) {
1724
+ i18n_default.changeLanguage(locale);
1725
+ }
1726
+ }, [locale]);
1727
+ return /* @__PURE__ */ jsx(LanguageProvider, { ...languageProviderProps, children: /* @__PURE__ */ jsx(I18nextProvider, { i18n: i18n_default, defaultNS, children }) });
1728
+ };
1729
+ function useRegisterExternalResources(resources2) {
1730
+ const localeCode = useLocaleCode();
1731
+ useEffect(() => {
1732
+ registerResources(resources2, localeCode);
1729
1733
  }, [localeCode, resources2]);
1734
+ }
1735
+ var ExternalLocaleProvider = (props) => {
1736
+ useRegisterExternalResources(props.resources);
1730
1737
  return /* @__PURE__ */ jsx(Fragment, { children: props.children });
1731
1738
  };
1739
+ function useTranslation(ns, options) {
1740
+ const context = useContext(I18nContext);
1741
+ return useTranslation$1(ns, {
1742
+ i18n: context?.i18n || i18n_default,
1743
+ // @ts-ignore
1744
+ // when the language resource is loaded, notify the translation component to re-render
1745
+ bindI18nStore: "added",
1746
+ ...options
1747
+ });
1748
+ }
1732
1749
 
1733
- export { ExternalLocaleProvider, I18nProvider, LocaleContext, LocaleEnum, LocaleProvider, createI18nInstance, defaultLanguages, defaultLng, defaultNS, en, generatePath, getLocalePathFromPathname, i18n_default as i18n, i18nCookieKey, i18nLocalStorageKey, parseI18nLang, preloadDefaultResource, removeLangPrefix, useLocaleCode, useLocaleContext, useTranslation };
1750
+ export { Backend, ExternalLocaleProvider, LanguageContext, LanguageProvider, LocaleEnum, LocaleProvider, asMessageRecord, createI18nInstance, defaultLanguages, defaultLng, defaultNS, en, generatePath, getLocalePathFromPathname, i18n_default as i18n, i18nCookieKey, i18nLocalStorageKey, importLocaleJsonModule, parseI18nLang, registerDefaultResource, registerResources, removeLangPrefix, useLanguageContext, useLocaleCode, useRegisterExternalResources, useTranslation };
1734
1751
  //# sourceMappingURL=index.mjs.map
1735
1752
  //# sourceMappingURL=index.mjs.map