@orderly.network/i18n 3.0.0-beta.0 → 3.0.0-beta.10

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-BwPxVQ3H.d.mts} +45 -40
  3. package/dist/{constant-BeXwHrGj.d.ts → constant-BwPxVQ3H.d.ts} +45 -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 +74 -30
  9. package/dist/index.d.ts +74 -30
  10. package/dist/index.js +156 -120
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +148 -118
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/locale.csv +42 -107
  15. package/dist/locales/de.json +42 -39
  16. package/dist/locales/en.json +42 -39
  17. package/dist/locales/es.json +42 -39
  18. package/dist/locales/fr.json +42 -39
  19. package/dist/locales/id.json +42 -39
  20. package/dist/locales/it.json +42 -39
  21. package/dist/locales/ja.json +42 -39
  22. package/dist/locales/ko.json +42 -39
  23. package/dist/locales/nl.json +42 -39
  24. package/dist/locales/pl.json +42 -39
  25. package/dist/locales/pt.json +42 -39
  26. package/dist/locales/ru.json +42 -39
  27. package/dist/locales/tc.json +42 -39
  28. package/dist/locales/tr.json +42 -39
  29. package/dist/locales/uk.json +42 -39
  30. package/dist/locales/vi.json +42 -39
  31. package/dist/locales/zh.json +42 -39
  32. package/dist/utils.d.mts +1 -1
  33. package/dist/utils.d.ts +1 -1
  34. package/dist/utils.js +51 -48
  35. package/dist/utils.js.map +1 -1
  36. package/dist/utils.mjs +51 -48
  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",
@@ -183,6 +188,8 @@ var affiliate = {
183
188
  "affiliate.newReferralProgram.description": "Give your sub-affiliates the power to customize their earnings, while you unlock an endless stream of passive income from every trader in your growing network.",
184
189
  "affiliate.newReferralProgram.tradeUnlock": "Trade to unlock",
185
190
  "affiliate.newReferralProgram.tradeUnlock.description": "Trade {{volume}} USDC volume to unlock the ability to invite friends and earn commissions.",
191
+ "affiliate.newReferralProgram.wereYouReferred": "Were you referred by someone?",
192
+ "affiliate.newReferralProgram.referredBy": "You were referred by {{code}}.",
186
193
  "affiliate.commissionConfiguration": "Commission configuration",
187
194
  "affiliate.totalCommissionAvailable": "Total commission available",
188
195
  "affiliate.configure": "Configure",
@@ -460,6 +467,7 @@ var markets = {
460
467
  "markets.favorites": "Favorites",
461
468
  "markets.recent": "Recent",
462
469
  "markets.newListings": "New listings",
470
+ "markets.community": "Community",
463
471
  "markets.allMarkets": "All markets",
464
472
  "markets.openInterest": "Open interest",
465
473
  "markets.openInterest.tooltip": "Total size of positions per side.",
@@ -509,7 +517,13 @@ var markets = {
509
517
  "markets.symbolInfoBar.24hVolume": "24h volume",
510
518
  "markets.symbolInfoBar.24hVolume.tooltip": "24 hour total trading volume on the Orderly Network.",
511
519
  "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."
520
+ "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.",
521
+ "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."
522
+ };
523
+
524
+ // src/locale/module/navigation.ts
525
+ var navigation = {
526
+ "tradingPoints.points": "Points"
513
527
  };
514
528
 
515
529
  // src/locale/module/notification.ts
@@ -554,6 +568,7 @@ var orderEntry = {
554
568
  "orderEntry.orderType.ioc.tooltip": "Executes immediately; any unfilled amount is canceled.",
555
569
  "orderEntry.orderType.fok": "FOK",
556
570
  "orderEntry.orderType.fok.tooltip": "Executes immediately in full, or is canceled entirely.",
571
+ "orderEntry.orderType.symbolPostOnly.tooltip": "This symbol is in POST_ONLY mode. Only limit orders are accepted until the order book is ready.",
557
572
  "orderEntry.orderType.scaledOrder": "Scaled",
558
573
  "orderEntry.orderType.trailingStop": "Trailing stop",
559
574
  "orderEntry.orderSize": "Order size",
@@ -626,10 +641,13 @@ var orderEntry = {
626
641
  "marginMode.current": "Current",
627
642
  "marginMode.marginModeSettings": "Margin mode settings",
628
643
  "marginMode.updatedSuccessfully": "Updated successfully",
644
+ "marginMode.noEditableSymbolsSelected": "No editable symbols selected",
645
+ "marginMode.failedToUpdateMarginMode": "Failed to update margin mode",
629
646
  "marginMode.perpetualFutures": "Perpetual futures",
630
647
  "marginMode.searchPlaceholder": "Search",
631
648
  "marginMode.selectAll": "Select all",
632
649
  "marginMode.setAs": "Set as",
650
+ "marginMode.disabledSymbolTooltip": "This symbol is independently operated by a third party. Isolated Margin is enforced to prevent risk from affecting your other positions.",
633
651
  "orderEntry.startPrice.error.required": "Start price is required",
634
652
  "orderEntry.startPrice.error.min": "Start price must be greater than {{value}}",
635
653
  "orderEntry.startPrice.error.max": "Start price must be less than {{value}}",
@@ -658,7 +676,12 @@ var orderEntry = {
658
676
  "orderEntry.reduceOnly.reminder": "Reduce-only reminder",
659
677
  "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
678
  "orderEntry.placeOrderNow": "Place order now",
661
- "orderEntry.maxQty.reminder.content": "Order qty reduced to max available: {{maxQty}}"
679
+ "orderEntry.maxQty.reminder.content": "Order qty reduced to max available: {{maxQty}}",
680
+ "orderEntry.permissionlessNotice.title": "Community-Listed Market Notice",
681
+ "orderEntry.permissionlessNotice.content1": "This market was listed by a third-party deployer through the permissionless listing system.",
682
+ "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.",
683
+ "orderEntry.permissionlessNotice.content3": "Please review the deployer's documentation and trade at your own risk.",
684
+ "orderEntry.permissionlessNotice.checkbox": "I understand this is a community-listed market and accept the risks."
662
685
  };
663
686
 
664
687
  // src/locale/module/orders.ts
@@ -725,6 +748,8 @@ var portfolio = {
725
748
  "portfolio.overview.performance.cumulativePnl": "Cumulative PnL",
726
749
  "portfolio.overview.performance.dailyVolume": "Daily Volume",
727
750
  "portfolio.overview.performance.cumulativeVolume": "Cumulative Volume",
751
+ "portfolio.overview.todaysPnl": "Today's PnL",
752
+ "portfolio.overview.todaysVol": "Today's Vol",
728
753
  "portfolio.overview.distribution": "Distribution",
729
754
  "portfolio.overview.transferHistory": "Transfer history",
730
755
  "portfolio.overview.vaults": "Vaults",
@@ -932,7 +957,9 @@ var tpsl = {
932
957
  "tpsl.tpTrigger": "TP trigger",
933
958
  "tpsl.slTrigger": "SL trigger",
934
959
  "tpsl.pnl": "PnL",
935
- "tpsl.offset": "Offset",
960
+ "tpsl.offsetHolder": "Offset",
961
+ "tpsl.offset": "Offset (From entry)",
962
+ "tpsl.offsetPercent": "Offset% (From entry)",
936
963
  "tpsl.add": "Add",
937
964
  "tpsl.cancelAll": "Cancel all",
938
965
  "tpsl.dragToSet": "Drag to set TP/SL",
@@ -978,7 +1005,9 @@ var tpsl = {
978
1005
  "tpsl.tpslDetail.qty": "Qty.",
979
1006
  "tpsl.tpslDetail.estPnl": "Est. PnL",
980
1007
  "tpsl.tpslDetail.estPnl.tooltip": "The actual value may differ based on the actual trading price. This value is only for reference.",
981
- "tpsl.agreement": "You agree to edit your {{symbol}} order."
1008
+ "tpsl.agreement": "You agree to edit your {{symbol}} order.",
1009
+ "tpsl.offsetMark": "Offset (From mark)",
1010
+ "tpsl.offsetPercentMark": "Offset% (From mark)"
982
1011
  };
983
1012
 
984
1013
  // src/locale/module/trading.ts
@@ -1058,6 +1087,7 @@ var trading = {
1058
1087
  "trading.rwa.tooltip.openIn": "Regular trading hours will open in <0>{{timeFormat}}</0>",
1059
1088
  "trading.rwa.tooltip.checkDetailRules": "Check detail rules",
1060
1089
  "trading.rwa.countdown.title": "US markets are closing soon, volatility may be lower.",
1090
+ "trading.symbolDelisting": "{{symbol}} has entered forced deleveraging mode (insufficient liquidity depth / insufficient IF balance). Your position on this symbol only allows closing operations.",
1061
1091
  "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
1092
  "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
1093
  "trading.rwa.mWeb.insideMarketHours.desc": "Regular trading hours are about to open - get ready."
@@ -1101,46 +1131,6 @@ var tradingLeaderboard = {
1101
1131
  "tradingLeaderboard.tradingVolume.tooltip": "Total trading volume generated during the campaign period. Updated every 30 seconds."
1102
1132
  };
1103
1133
 
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
1134
  // src/locale/module/tradingRewards.ts
1145
1135
  var tradingRewards = {
1146
1136
  "tradingRewards.rewards": "Rewards",
@@ -1194,6 +1184,7 @@ var tradingView = {
1194
1184
  "tradingView.displayControl.buySell": "Buy/Sell",
1195
1185
  "tradingView.displayControl.limitOrders": "Limit orders",
1196
1186
  "tradingView.displayControl.stopOrders": "Stop orders",
1187
+ "tradingView.displayControl.liquidationPrice": "Liquidation Price",
1197
1188
  "tradingView.noScriptSrc": "Due to TradingView's policy, you will need to apply for your own license.",
1198
1189
  "tradingView.noScriptSrc.1": "1. Please apply for your TradingView Advanced Chart license <0>here</0>",
1199
1190
  "tradingView.noScriptSrc.2": "2. Follow the instructions on <0>orderly.network</0> to set up."
@@ -1216,10 +1207,20 @@ var transfer = {
1216
1207
  "transfer.deposit.requested": "Deposit requested",
1217
1208
  "transfer.deposit.completed": "Deposit completed",
1218
1209
  "transfer.deposit.failed": "Deposit failed",
1210
+ "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.",
1211
+ "transfer.exclusiveDeposit.selectFirst": "Select your network and token first",
1212
+ "transfer.exclusiveDeposit.selectNetwork": "Select network",
1213
+ "transfer.exclusiveDeposit.selectToken": "Select token",
1214
+ "transfer.exclusiveDeposit.minDeposit": "Min. deposit",
1215
+ "transfer.exclusiveDeposit.estimatedTime": "Estimated time",
1216
+ "transfer.exclusiveDeposit.estimatedTime.default": "~ 5 min",
1217
+ "transfer.exclusiveDeposit.depositPending": "Deposit pending: {{amount}} {{symbol}}",
1219
1218
  "transfer.deposit.feeUnavailable": "Fee data is currently unavailable. Please try again later.",
1220
1219
  "transfer.deposit.notEnoughGas": "Not enough gas. Add some {{token}} to your wallet to continue.",
1221
1220
  "transfer.deposit.exceedCap": "Amount exceeds user deposit cap",
1222
1221
  "transfer.deposit.closeToMaxLimit": "Deposit amount too close to maximum limit. To ensure your transaction succeeds, please reduce the amount",
1222
+ "transfer.deposit.tab.connectedWallet": "From connected wallet",
1223
+ "transfer.deposit.tab.exchangeOrOtherWallet": "From exchange / other wallet",
1223
1224
  "transfer.deposit.estGasFee": "Est. gas fee",
1224
1225
  "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
1226
  "transfer.deposit.destinationGasFee": "Destination gas fee",
@@ -1328,7 +1329,9 @@ var ui = {
1328
1329
  "ui.messageCenter.tooltip": "Check recent announcements",
1329
1330
  "ui.pagination.morePages": "More pages",
1330
1331
  "ui.pagination.rowsPerPage": "Rows per page",
1331
- "ui.picker.selectDate": "Select Date"
1332
+ "ui.picker.selectDate": "Select Date",
1333
+ "ui.dialog.srOnly.title": "Dialog",
1334
+ "ui.sheet.srOnly.title": "Sheet"
1332
1335
  };
1333
1336
 
1334
1337
  // src/locale/module/vaults.ts
@@ -1474,10 +1477,10 @@ var en = {
1474
1477
  ...affiliate,
1475
1478
  ...ui,
1476
1479
  ...tradingLeaderboard,
1477
- ...tradingPoints,
1478
1480
  ...widget,
1479
1481
  ...vaults,
1480
- ...notification
1482
+ ...notification,
1483
+ ...navigation
1481
1484
  };
1482
1485
 
1483
1486
  // src/i18n.ts
@@ -1505,8 +1508,30 @@ var i18n = createI18nInstance({
1505
1508
  });
1506
1509
  i18n.init();
1507
1510
  var i18n_default = i18n;
1511
+ var LanguageContext = createContext({
1512
+ languages: [],
1513
+ onLanguageBeforeChanged: () => Promise.resolve(),
1514
+ onLanguageChanged: () => Promise.resolve()
1515
+ });
1516
+ var useLanguageContext = () => {
1517
+ return useContext(LanguageContext);
1518
+ };
1519
+
1520
+ // src/resourceBundles/registerResources.ts
1521
+ async function registerResources(resources2, localeCode) {
1522
+ if (typeof resources2 === "function") {
1523
+ const resource = await resources2(localeCode, defaultNS);
1524
+ i18n_default.addResourceBundle(localeCode, defaultNS, resource, true, true);
1525
+ return;
1526
+ }
1527
+ if (resources2) {
1528
+ Object.entries(resources2).forEach(([locale, messages]) => {
1529
+ i18n_default.addResourceBundle(locale, defaultNS, messages, true, true);
1530
+ });
1531
+ }
1532
+ }
1508
1533
 
1509
- // src/backend.ts
1534
+ // src/resourceBundles/httpBackend.ts
1510
1535
  var Backend = class {
1511
1536
  constructor(options) {
1512
1537
  this.options = options;
@@ -1550,15 +1575,38 @@ var Backend = class {
1550
1575
  await Promise.all(promises);
1551
1576
  }
1552
1577
  };
1553
- var LocaleContext = createContext({
1554
- languages: [],
1555
- onLanguageBeforeChanged: () => Promise.resolve(),
1556
- onLanguageChanged: () => Promise.resolve()
1557
- });
1558
- var useLocaleContext = () => {
1559
- return useContext(LocaleContext);
1578
+
1579
+ // src/resourceBundles/registerDefaultResource.ts
1580
+ var registerDefaultResource = (messages) => {
1581
+ i18n_default.addResourceBundle(defaultLng, defaultNS, messages, true, true);
1560
1582
  };
1561
1583
 
1584
+ // src/resourceBundles/importLocaleJsonModule.ts
1585
+ function asMessageRecord(value) {
1586
+ if (!value) {
1587
+ return {};
1588
+ }
1589
+ if (typeof value !== "string") {
1590
+ return value;
1591
+ }
1592
+ try {
1593
+ return JSON.parse(value);
1594
+ } catch {
1595
+ return {};
1596
+ }
1597
+ }
1598
+ async function importLocaleJsonModule(loader) {
1599
+ if (!loader) {
1600
+ return asMessageRecord(void 0);
1601
+ }
1602
+ try {
1603
+ const mod = await loader();
1604
+ return asMessageRecord(mod.default);
1605
+ } catch {
1606
+ return {};
1607
+ }
1608
+ }
1609
+
1562
1610
  // src/utils.ts
1563
1611
  function parseI18nLang(lang, localeCodes, defaultLang) {
1564
1612
  localeCodes = localeCodes || Object.values(LocaleEnum);
@@ -1596,19 +1644,9 @@ function generatePath(params) {
1596
1644
  localePath = locale || parseI18nLang(i18n_default.language);
1597
1645
  return `/${localePath}${path}${searchUrl}`;
1598
1646
  }
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) => {
1647
+ var LanguageProvider = (props) => {
1607
1648
  const {
1608
1649
  children,
1609
- locale,
1610
- resource,
1611
- resources: resources2,
1612
1650
  backend,
1613
1651
  popup,
1614
1652
  supportedLanguages,
@@ -1618,22 +1656,6 @@ var LocaleProvider = (props) => {
1618
1656
  } = props;
1619
1657
  const [languages, setLanguages] = useState(defaultLanguages);
1620
1658
  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
1659
  useEffect(() => {
1638
1660
  if (Array.isArray(props.languages)) {
1639
1661
  setLanguages(props.languages);
@@ -1644,7 +1666,7 @@ var LocaleProvider = (props) => {
1644
1666
  ).filter((item) => !!item)
1645
1667
  );
1646
1668
  }
1647
- }, [supportedLanguages, props.languages]);
1669
+ }, [props.languages, supportedLanguages]);
1648
1670
  useEffect(() => {
1649
1671
  const initLanguage = async () => {
1650
1672
  const lang = typeof convertDetectedLanguage === "function" ? convertDetectedLanguage(i18n_default.language) : parseI18nLang(i18n_default.language);
@@ -1676,60 +1698,68 @@ var LocaleProvider = (props) => {
1676
1698
  onLanguageChanged: languageChangedHandle
1677
1699
  };
1678
1700
  }, [popup, languages, languageBeforeChangedHandle, languageChangedHandle]);
1679
- return /* @__PURE__ */ jsx(LocaleContext.Provider, { value: memoizedValue, children: /* @__PURE__ */ jsx(I18nextProvider, { i18n: i18n_default, defaultNS, children }) });
1701
+ return /* @__PURE__ */ jsx(LanguageContext.Provider, { value: memoizedValue, children });
1680
1702
  };
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
1703
  function useLocaleCode() {
1692
- const [loacaleCode, setLoacaleCode] = useState(
1704
+ const [localeCode, setLocaleCode] = useState(
1693
1705
  parseI18nLang(i18n_default.language)
1694
1706
  );
1695
1707
  useEffect(() => {
1696
1708
  const handleLanguageChange = (lng) => {
1697
- setLoacaleCode(lng);
1709
+ setLocaleCode(lng);
1698
1710
  };
1699
1711
  i18n_default.on("languageChanged", handleLanguageChange);
1700
1712
  return () => {
1701
1713
  i18n_default.off("languageChanged", handleLanguageChange);
1702
1714
  };
1703
1715
  }, [i18n_default]);
1704
- return loacaleCode;
1716
+ return localeCode;
1705
1717
  }
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();
1718
+ var LocaleProvider = (props) => {
1719
+ const { children, locale, resource, resources: resources2, ...languageProviderProps } = props;
1720
+ const localeCodeFromI18n = useLocaleCode();
1718
1721
  useEffect(() => {
1719
- if (typeof resources2 === "function") {
1720
- asyncAddResource(localeCode, resources2);
1721
- return;
1722
- }
1723
1722
  if (resources2) {
1724
- Object.entries(resources2).forEach(([locale, messages]) => {
1725
- i18n_default.addResourceBundle(locale, defaultNS, messages, true, true);
1726
- });
1723
+ registerResources(resources2, locale ?? localeCodeFromI18n);
1727
1724
  return;
1728
1725
  }
1726
+ if (resource && locale) {
1727
+ i18n_default.addResourceBundle(locale, defaultNS, resource, true, true);
1728
+ }
1729
+ }, [locale, localeCodeFromI18n, resource, resources2]);
1730
+ useEffect(() => {
1731
+ if (locale && locale !== i18n_default.language) {
1732
+ i18n_default.changeLanguage(locale);
1733
+ }
1734
+ }, [locale]);
1735
+ return /* @__PURE__ */ jsx(LanguageProvider, { ...languageProviderProps, children: /* @__PURE__ */ jsx(I18nextProvider, { i18n: i18n_default, defaultNS, children }) });
1736
+ };
1737
+ function useRegisterExternalResources(resources2) {
1738
+ const localeCode = useLocaleCode();
1739
+ useEffect(() => {
1740
+ registerResources(resources2, localeCode);
1729
1741
  }, [localeCode, resources2]);
1742
+ }
1743
+ var ExternalLocaleProvider = (props) => {
1744
+ useRegisterExternalResources(props.resources);
1730
1745
  return /* @__PURE__ */ jsx(Fragment, { children: props.children });
1731
1746
  };
1747
+ function useTranslation(ns, options) {
1748
+ const context = useContext(I18nContext);
1749
+ return useTranslation$1(ns, {
1750
+ i18n: context?.i18n || i18n_default,
1751
+ // @ts-ignore
1752
+ // when the language resource is loaded, notify the translation component to re-render
1753
+ bindI18nStore: "added",
1754
+ ...options
1755
+ });
1756
+ }
1757
+
1758
+ // src/external/utils.ts
1759
+ var preloadDefaultResource = (messages) => {
1760
+ i18n_default.addResourceBundle(defaultLng, defaultNS, messages, true, true);
1761
+ };
1732
1762
 
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 };
1763
+ export { Backend, ExternalLocaleProvider, LanguageContext, LanguageProvider, LocaleEnum, LocaleProvider, asMessageRecord, createI18nInstance, defaultLanguages, defaultLng, defaultNS, en, generatePath, getLocalePathFromPathname, i18n_default as i18n, i18nCookieKey, i18nLocalStorageKey, importLocaleJsonModule, parseI18nLang, preloadDefaultResource, registerDefaultResource, registerResources, removeLangPrefix, useLanguageContext, useLocaleCode, useRegisterExternalResources, useTranslation };
1734
1764
  //# sourceMappingURL=index.mjs.map
1735
1765
  //# sourceMappingURL=index.mjs.map