@orderly.network/i18n 3.0.0-beta.1 → 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.
- package/README.md +23 -469
- package/dist/{constant-BeXwHrGj.d.mts → constant-BwPxVQ3H.d.mts} +45 -40
- package/dist/{constant-BeXwHrGj.d.ts → constant-BwPxVQ3H.d.ts} +45 -40
- package/dist/constant.d.mts +1 -1
- package/dist/constant.d.ts +1 -1
- package/dist/constant.js.map +1 -1
- package/dist/constant.mjs.map +1 -1
- package/dist/index.d.mts +74 -30
- package/dist/index.d.ts +74 -30
- package/dist/index.js +156 -120
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +148 -118
- package/dist/index.mjs.map +1 -1
- package/dist/locale.csv +42 -107
- package/dist/locales/de.json +42 -39
- package/dist/locales/en.json +42 -39
- package/dist/locales/es.json +42 -39
- package/dist/locales/fr.json +42 -39
- package/dist/locales/id.json +42 -39
- package/dist/locales/it.json +42 -39
- package/dist/locales/ja.json +42 -39
- package/dist/locales/ko.json +42 -39
- package/dist/locales/nl.json +42 -39
- package/dist/locales/pl.json +42 -39
- package/dist/locales/pt.json +42 -39
- package/dist/locales/ru.json +42 -39
- package/dist/locales/tc.json +42 -39
- package/dist/locales/tr.json +42 -39
- package/dist/locales/uk.json +42 -39
- package/dist/locales/vi.json +42 -39
- package/dist/locales/zh.json +42 -39
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +51 -48
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +51 -48
- package/dist/utils.mjs.map +1 -1
- package/docs/guide/AGENTS.md +109 -0
- package/docs/guide/cli.md +133 -0
- package/docs/guide/examples.md +455 -0
- package/docs/guide/exports.md +14 -0
- package/docs/guide/integration.md +223 -0
- package/docs/guide/utils.md +14 -0
- package/package.json +8 -6
- package/scripts/copyLocales.js +11 -0
- package/scripts/csv2json.js +28 -0
- package/scripts/diffCsv.js +175 -0
- package/scripts/fillJson.js +33 -0
- package/scripts/filterLocaleKeys.js +127 -0
- package/scripts/generateCsv.js +36 -0
- package/scripts/generateEnJson.js +11 -0
- package/scripts/generateMissingKeys.js +49 -0
- package/scripts/json-csv-converter.js +286 -0
- package/scripts/json2csv.js +38 -0
- package/scripts/mergeJson.js +67 -0
- package/scripts/separateJson.js +50 -0
- package/scripts/utils.js +94 -0
package/dist/index.js
CHANGED
|
@@ -99,6 +99,10 @@ var affiliate = {
|
|
|
99
99
|
"affiliate.referralCode.label": "Enter referral code",
|
|
100
100
|
"affiliate.referralCode.bound": "Referral code bound",
|
|
101
101
|
"affiliate.referralCode.notExist": "This referral code does not exist.",
|
|
102
|
+
"affiliate.referralCode.bind.modal.title": "Were you referred by someone?",
|
|
103
|
+
"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.",
|
|
104
|
+
"affiliate.referralCode.bind.input.placeholder": "Enter referrer's code",
|
|
105
|
+
"affiliate.referralCode.bind.skip": "No, I was not referred by anyone",
|
|
102
106
|
"affiliate.process.title": "How It Works",
|
|
103
107
|
"affiliate.process.step1.title": "Trade $10,000+ or apply",
|
|
104
108
|
"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.",
|
|
@@ -130,7 +134,7 @@ var affiliate = {
|
|
|
130
134
|
"affiliate.base": "Affiliate",
|
|
131
135
|
"affiliate.directBonus": "Direct bonus",
|
|
132
136
|
"affiliate.commission.30d": "30d commission",
|
|
133
|
-
"affiliate.commission.column.activeUsers": "
|
|
137
|
+
"affiliate.commission.column.activeUsers": "New traders",
|
|
134
138
|
"affiliate.myReferees": "My referees",
|
|
135
139
|
"affiliate.referees": "Referees",
|
|
136
140
|
"affiliate.referees.column.refereeAddress": "Referee address",
|
|
@@ -160,6 +164,7 @@ var affiliate = {
|
|
|
160
164
|
"affiliate.direct": "Direct",
|
|
161
165
|
"affiliate.directInclBonus": "Incl. {{amount}} bonus",
|
|
162
166
|
"affiliate.indirect": "Indirect",
|
|
167
|
+
"affiliate.referredBy": "Referred by {{name}}",
|
|
163
168
|
"affiliate.referrals": "Referrals",
|
|
164
169
|
"affiliate.referralCode.edit.modal.title": "Configure your referral settings",
|
|
165
170
|
"affiliate.referralCode.create": "Create referral code",
|
|
@@ -188,6 +193,8 @@ var affiliate = {
|
|
|
188
193
|
"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.",
|
|
189
194
|
"affiliate.newReferralProgram.tradeUnlock": "Trade to unlock",
|
|
190
195
|
"affiliate.newReferralProgram.tradeUnlock.description": "Trade {{volume}} USDC volume to unlock the ability to invite friends and earn commissions.",
|
|
196
|
+
"affiliate.newReferralProgram.wereYouReferred": "Were you referred by someone?",
|
|
197
|
+
"affiliate.newReferralProgram.referredBy": "You were referred by {{code}}.",
|
|
191
198
|
"affiliate.commissionConfiguration": "Commission configuration",
|
|
192
199
|
"affiliate.totalCommissionAvailable": "Total commission available",
|
|
193
200
|
"affiliate.configure": "Configure",
|
|
@@ -465,6 +472,7 @@ var markets = {
|
|
|
465
472
|
"markets.favorites": "Favorites",
|
|
466
473
|
"markets.recent": "Recent",
|
|
467
474
|
"markets.newListings": "New listings",
|
|
475
|
+
"markets.community": "Community",
|
|
468
476
|
"markets.allMarkets": "All markets",
|
|
469
477
|
"markets.openInterest": "Open interest",
|
|
470
478
|
"markets.openInterest.tooltip": "Total size of positions per side.",
|
|
@@ -514,7 +522,13 @@ var markets = {
|
|
|
514
522
|
"markets.symbolInfoBar.24hVolume": "24h volume",
|
|
515
523
|
"markets.symbolInfoBar.24hVolume.tooltip": "24 hour total trading volume on the Orderly Network.",
|
|
516
524
|
"markets.symbolInfoBar.predFundingRate": "Est. funding rate",
|
|
517
|
-
"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."
|
|
525
|
+
"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.",
|
|
526
|
+
"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."
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
// src/locale/module/navigation.ts
|
|
530
|
+
var navigation = {
|
|
531
|
+
"tradingPoints.points": "Points"
|
|
518
532
|
};
|
|
519
533
|
|
|
520
534
|
// src/locale/module/notification.ts
|
|
@@ -559,6 +573,7 @@ var orderEntry = {
|
|
|
559
573
|
"orderEntry.orderType.ioc.tooltip": "Executes immediately; any unfilled amount is canceled.",
|
|
560
574
|
"orderEntry.orderType.fok": "FOK",
|
|
561
575
|
"orderEntry.orderType.fok.tooltip": "Executes immediately in full, or is canceled entirely.",
|
|
576
|
+
"orderEntry.orderType.symbolPostOnly.tooltip": "This symbol is in POST_ONLY mode. Only limit orders are accepted until the order book is ready.",
|
|
562
577
|
"orderEntry.orderType.scaledOrder": "Scaled",
|
|
563
578
|
"orderEntry.orderType.trailingStop": "Trailing stop",
|
|
564
579
|
"orderEntry.orderSize": "Order size",
|
|
@@ -631,10 +646,13 @@ var orderEntry = {
|
|
|
631
646
|
"marginMode.current": "Current",
|
|
632
647
|
"marginMode.marginModeSettings": "Margin mode settings",
|
|
633
648
|
"marginMode.updatedSuccessfully": "Updated successfully",
|
|
649
|
+
"marginMode.noEditableSymbolsSelected": "No editable symbols selected",
|
|
650
|
+
"marginMode.failedToUpdateMarginMode": "Failed to update margin mode",
|
|
634
651
|
"marginMode.perpetualFutures": "Perpetual futures",
|
|
635
652
|
"marginMode.searchPlaceholder": "Search",
|
|
636
653
|
"marginMode.selectAll": "Select all",
|
|
637
654
|
"marginMode.setAs": "Set as",
|
|
655
|
+
"marginMode.disabledSymbolTooltip": "This symbol is independently operated by a third party. Isolated Margin is enforced to prevent risk from affecting your other positions.",
|
|
638
656
|
"orderEntry.startPrice.error.required": "Start price is required",
|
|
639
657
|
"orderEntry.startPrice.error.min": "Start price must be greater than {{value}}",
|
|
640
658
|
"orderEntry.startPrice.error.max": "Start price must be less than {{value}}",
|
|
@@ -663,7 +681,12 @@ var orderEntry = {
|
|
|
663
681
|
"orderEntry.reduceOnly.reminder": "Reduce-only reminder",
|
|
664
682
|
"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?",
|
|
665
683
|
"orderEntry.placeOrderNow": "Place order now",
|
|
666
|
-
"orderEntry.maxQty.reminder.content": "Order qty reduced to max available: {{maxQty}}"
|
|
684
|
+
"orderEntry.maxQty.reminder.content": "Order qty reduced to max available: {{maxQty}}",
|
|
685
|
+
"orderEntry.permissionlessNotice.title": "Community-Listed Market Notice",
|
|
686
|
+
"orderEntry.permissionlessNotice.content1": "This market was listed by a third-party deployer through the permissionless listing system.",
|
|
687
|
+
"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.",
|
|
688
|
+
"orderEntry.permissionlessNotice.content3": "Please review the deployer's documentation and trade at your own risk.",
|
|
689
|
+
"orderEntry.permissionlessNotice.checkbox": "I understand this is a community-listed market and accept the risks."
|
|
667
690
|
};
|
|
668
691
|
|
|
669
692
|
// src/locale/module/orders.ts
|
|
@@ -730,6 +753,8 @@ var portfolio = {
|
|
|
730
753
|
"portfolio.overview.performance.cumulativePnl": "Cumulative PnL",
|
|
731
754
|
"portfolio.overview.performance.dailyVolume": "Daily Volume",
|
|
732
755
|
"portfolio.overview.performance.cumulativeVolume": "Cumulative Volume",
|
|
756
|
+
"portfolio.overview.todaysPnl": "Today's PnL",
|
|
757
|
+
"portfolio.overview.todaysVol": "Today's Vol",
|
|
733
758
|
"portfolio.overview.distribution": "Distribution",
|
|
734
759
|
"portfolio.overview.transferHistory": "Transfer history",
|
|
735
760
|
"portfolio.overview.vaults": "Vaults",
|
|
@@ -937,7 +962,9 @@ var tpsl = {
|
|
|
937
962
|
"tpsl.tpTrigger": "TP trigger",
|
|
938
963
|
"tpsl.slTrigger": "SL trigger",
|
|
939
964
|
"tpsl.pnl": "PnL",
|
|
940
|
-
"tpsl.
|
|
965
|
+
"tpsl.offsetHolder": "Offset",
|
|
966
|
+
"tpsl.offset": "Offset (From entry)",
|
|
967
|
+
"tpsl.offsetPercent": "Offset% (From entry)",
|
|
941
968
|
"tpsl.add": "Add",
|
|
942
969
|
"tpsl.cancelAll": "Cancel all",
|
|
943
970
|
"tpsl.dragToSet": "Drag to set TP/SL",
|
|
@@ -983,7 +1010,9 @@ var tpsl = {
|
|
|
983
1010
|
"tpsl.tpslDetail.qty": "Qty.",
|
|
984
1011
|
"tpsl.tpslDetail.estPnl": "Est. PnL",
|
|
985
1012
|
"tpsl.tpslDetail.estPnl.tooltip": "The actual value may differ based on the actual trading price. This value is only for reference.",
|
|
986
|
-
"tpsl.agreement": "You agree to edit your {{symbol}} order."
|
|
1013
|
+
"tpsl.agreement": "You agree to edit your {{symbol}} order.",
|
|
1014
|
+
"tpsl.offsetMark": "Offset (From mark)",
|
|
1015
|
+
"tpsl.offsetPercentMark": "Offset% (From mark)"
|
|
987
1016
|
};
|
|
988
1017
|
|
|
989
1018
|
// src/locale/module/trading.ts
|
|
@@ -1063,6 +1092,7 @@ var trading = {
|
|
|
1063
1092
|
"trading.rwa.tooltip.openIn": "Regular trading hours will open in <0>{{timeFormat}}</0>",
|
|
1064
1093
|
"trading.rwa.tooltip.checkDetailRules": "Check detail rules",
|
|
1065
1094
|
"trading.rwa.countdown.title": "US markets are closing soon, volatility may be lower.",
|
|
1095
|
+
"trading.symbolDelisting": "{{symbol}} has entered forced deleveraging mode (insufficient liquidity depth / insufficient IF balance). Your position on this symbol only allows closing operations.",
|
|
1066
1096
|
"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.",
|
|
1067
1097
|
"trading.rwa.mWeb.outsideMarketHours.desc": "Regular trading hours are about to close - 24/7 trading continues; price may slow and liquidity may be lower.",
|
|
1068
1098
|
"trading.rwa.mWeb.insideMarketHours.desc": "Regular trading hours are about to open - get ready."
|
|
@@ -1106,46 +1136,6 @@ var tradingLeaderboard = {
|
|
|
1106
1136
|
"tradingLeaderboard.tradingVolume.tooltip": "Total trading volume generated during the campaign period. Updated every 30 seconds."
|
|
1107
1137
|
};
|
|
1108
1138
|
|
|
1109
|
-
// src/locale/module/tradingPoints.ts
|
|
1110
|
-
var tradingPoints = {
|
|
1111
|
-
"tradingPoints.points": "Points",
|
|
1112
|
-
"tradingPoints.startsIn": "Starts in",
|
|
1113
|
-
"tradingPoints.days": "Days",
|
|
1114
|
-
"tradingPoints.hours": "Hours",
|
|
1115
|
-
"tradingPoints.minutes": "Minutes",
|
|
1116
|
-
"tradingPoints.seconds": "Seconds",
|
|
1117
|
-
"tradingPoints.learnMore": "Learn more",
|
|
1118
|
-
"tradingPoints.stagePoints": "Stage points",
|
|
1119
|
-
"tradingPoints.stageRanking": "Stage ranking",
|
|
1120
|
-
"tradingPoints.referralCode": "Referral code",
|
|
1121
|
-
"tradingPoints.referralLink": "Referral link",
|
|
1122
|
-
"tradingPoints.currentPoints": "Current points",
|
|
1123
|
-
"tradingPoints.ranking": "Ranking",
|
|
1124
|
-
"tradingPoints.myPoints": "My points",
|
|
1125
|
-
"tradingPoints.thisWeek": "This week",
|
|
1126
|
-
"tradingPoints.lastWeek": "Last week",
|
|
1127
|
-
"tradingPoints.all": "All",
|
|
1128
|
-
"tradingPoints.tradePoints": "Trade points",
|
|
1129
|
-
"tradingPoints.tradePointsTooltip": "Trade Points are calculated based on your perps trading volume.Updated daily.",
|
|
1130
|
-
"tradingPoints.tradeNow": "Trade now",
|
|
1131
|
-
"tradingPoints.pnlPoints": "PNL points",
|
|
1132
|
-
"tradingPoints.pnlPointsTooltip": "Both profit or loss of each trade will be recorded. Updated daily.",
|
|
1133
|
-
"tradingPoints.referralPoints": "Referral points",
|
|
1134
|
-
"tradingPoints.referralPointsTooltip": "First-level invitee's rebates: {{l1}}%, Second-level invitee's rebates: {{l2}}%, Update daily.",
|
|
1135
|
-
"tradingPoints.copyLink": "Copy Link",
|
|
1136
|
-
"tradingPoints.faq.title": "FAQ",
|
|
1137
|
-
"tradingPoints.faq.whatArePoints.question": "What are Points?",
|
|
1138
|
-
"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.",
|
|
1139
|
-
"tradingPoints.faq.allocation.question": "What is the points allocation criteria?",
|
|
1140
|
-
"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",
|
|
1141
|
-
"tradingPoints.faq.distribution.question": "When will points be distributed?",
|
|
1142
|
-
"tradingPoints.faq.distribution.answer": "Points are distributed at 08:00 UTC everyday.",
|
|
1143
|
-
"tradingPoints.faq.pnl.question": "How are PNL points calculated?",
|
|
1144
|
-
"tradingPoints.faq.pnl.answer": "Points are based on your net profit or loss each trading.",
|
|
1145
|
-
"tradingPoints.faq.referral.question": "How does the referral work?",
|
|
1146
|
-
"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."
|
|
1147
|
-
};
|
|
1148
|
-
|
|
1149
1139
|
// src/locale/module/tradingRewards.ts
|
|
1150
1140
|
var tradingRewards = {
|
|
1151
1141
|
"tradingRewards.rewards": "Rewards",
|
|
@@ -1199,6 +1189,7 @@ var tradingView = {
|
|
|
1199
1189
|
"tradingView.displayControl.buySell": "Buy/Sell",
|
|
1200
1190
|
"tradingView.displayControl.limitOrders": "Limit orders",
|
|
1201
1191
|
"tradingView.displayControl.stopOrders": "Stop orders",
|
|
1192
|
+
"tradingView.displayControl.liquidationPrice": "Liquidation Price",
|
|
1202
1193
|
"tradingView.noScriptSrc": "Due to TradingView's policy, you will need to apply for your own license.",
|
|
1203
1194
|
"tradingView.noScriptSrc.1": "1. Please apply for your TradingView Advanced Chart license <0>here</0>",
|
|
1204
1195
|
"tradingView.noScriptSrc.2": "2. Follow the instructions on <0>orderly.network</0> to set up."
|
|
@@ -1221,10 +1212,20 @@ var transfer = {
|
|
|
1221
1212
|
"transfer.deposit.requested": "Deposit requested",
|
|
1222
1213
|
"transfer.deposit.completed": "Deposit completed",
|
|
1223
1214
|
"transfer.deposit.failed": "Deposit failed",
|
|
1215
|
+
"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.",
|
|
1216
|
+
"transfer.exclusiveDeposit.selectFirst": "Select your network and token first",
|
|
1217
|
+
"transfer.exclusiveDeposit.selectNetwork": "Select network",
|
|
1218
|
+
"transfer.exclusiveDeposit.selectToken": "Select token",
|
|
1219
|
+
"transfer.exclusiveDeposit.minDeposit": "Min. deposit",
|
|
1220
|
+
"transfer.exclusiveDeposit.estimatedTime": "Estimated time",
|
|
1221
|
+
"transfer.exclusiveDeposit.estimatedTime.default": "~ 5 min",
|
|
1222
|
+
"transfer.exclusiveDeposit.depositPending": "Deposit pending: {{amount}} {{symbol}}",
|
|
1224
1223
|
"transfer.deposit.feeUnavailable": "Fee data is currently unavailable. Please try again later.",
|
|
1225
1224
|
"transfer.deposit.notEnoughGas": "Not enough gas. Add some {{token}} to your wallet to continue.",
|
|
1226
1225
|
"transfer.deposit.exceedCap": "Amount exceeds user deposit cap",
|
|
1227
1226
|
"transfer.deposit.closeToMaxLimit": "Deposit amount too close to maximum limit. To ensure your transaction succeeds, please reduce the amount",
|
|
1227
|
+
"transfer.deposit.tab.connectedWallet": "From connected wallet",
|
|
1228
|
+
"transfer.deposit.tab.exchangeOrOtherWallet": "From exchange / other wallet",
|
|
1228
1229
|
"transfer.deposit.estGasFee": "Est. gas fee",
|
|
1229
1230
|
"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.",
|
|
1230
1231
|
"transfer.deposit.destinationGasFee": "Destination gas fee",
|
|
@@ -1333,7 +1334,9 @@ var ui = {
|
|
|
1333
1334
|
"ui.messageCenter.tooltip": "Check recent announcements",
|
|
1334
1335
|
"ui.pagination.morePages": "More pages",
|
|
1335
1336
|
"ui.pagination.rowsPerPage": "Rows per page",
|
|
1336
|
-
"ui.picker.selectDate": "Select Date"
|
|
1337
|
+
"ui.picker.selectDate": "Select Date",
|
|
1338
|
+
"ui.dialog.srOnly.title": "Dialog",
|
|
1339
|
+
"ui.sheet.srOnly.title": "Sheet"
|
|
1337
1340
|
};
|
|
1338
1341
|
|
|
1339
1342
|
// src/locale/module/vaults.ts
|
|
@@ -1479,10 +1482,10 @@ var en = {
|
|
|
1479
1482
|
...affiliate,
|
|
1480
1483
|
...ui,
|
|
1481
1484
|
...tradingLeaderboard,
|
|
1482
|
-
...tradingPoints,
|
|
1483
1485
|
...widget,
|
|
1484
1486
|
...vaults,
|
|
1485
|
-
...notification
|
|
1487
|
+
...notification,
|
|
1488
|
+
...navigation
|
|
1486
1489
|
};
|
|
1487
1490
|
|
|
1488
1491
|
// src/i18n.ts
|
|
@@ -1510,8 +1513,30 @@ var i18n = createI18nInstance({
|
|
|
1510
1513
|
});
|
|
1511
1514
|
i18n.init();
|
|
1512
1515
|
var i18n_default = i18n;
|
|
1516
|
+
var LanguageContext = react.createContext({
|
|
1517
|
+
languages: [],
|
|
1518
|
+
onLanguageBeforeChanged: () => Promise.resolve(),
|
|
1519
|
+
onLanguageChanged: () => Promise.resolve()
|
|
1520
|
+
});
|
|
1521
|
+
var useLanguageContext = () => {
|
|
1522
|
+
return react.useContext(LanguageContext);
|
|
1523
|
+
};
|
|
1524
|
+
|
|
1525
|
+
// src/resourceBundles/registerResources.ts
|
|
1526
|
+
async function registerResources(resources2, localeCode) {
|
|
1527
|
+
if (typeof resources2 === "function") {
|
|
1528
|
+
const resource = await resources2(localeCode, defaultNS);
|
|
1529
|
+
i18n_default.addResourceBundle(localeCode, defaultNS, resource, true, true);
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
if (resources2) {
|
|
1533
|
+
Object.entries(resources2).forEach(([locale, messages]) => {
|
|
1534
|
+
i18n_default.addResourceBundle(locale, defaultNS, messages, true, true);
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1513
1538
|
|
|
1514
|
-
// src/
|
|
1539
|
+
// src/resourceBundles/httpBackend.ts
|
|
1515
1540
|
var Backend = class {
|
|
1516
1541
|
constructor(options) {
|
|
1517
1542
|
this.options = options;
|
|
@@ -1555,15 +1580,38 @@ var Backend = class {
|
|
|
1555
1580
|
await Promise.all(promises);
|
|
1556
1581
|
}
|
|
1557
1582
|
};
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
});
|
|
1563
|
-
var useLocaleContext = () => {
|
|
1564
|
-
return react.useContext(LocaleContext);
|
|
1583
|
+
|
|
1584
|
+
// src/resourceBundles/registerDefaultResource.ts
|
|
1585
|
+
var registerDefaultResource = (messages) => {
|
|
1586
|
+
i18n_default.addResourceBundle(defaultLng, defaultNS, messages, true, true);
|
|
1565
1587
|
};
|
|
1566
1588
|
|
|
1589
|
+
// src/resourceBundles/importLocaleJsonModule.ts
|
|
1590
|
+
function asMessageRecord(value) {
|
|
1591
|
+
if (!value) {
|
|
1592
|
+
return {};
|
|
1593
|
+
}
|
|
1594
|
+
if (typeof value !== "string") {
|
|
1595
|
+
return value;
|
|
1596
|
+
}
|
|
1597
|
+
try {
|
|
1598
|
+
return JSON.parse(value);
|
|
1599
|
+
} catch {
|
|
1600
|
+
return {};
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
async function importLocaleJsonModule(loader) {
|
|
1604
|
+
if (!loader) {
|
|
1605
|
+
return asMessageRecord(void 0);
|
|
1606
|
+
}
|
|
1607
|
+
try {
|
|
1608
|
+
const mod = await loader();
|
|
1609
|
+
return asMessageRecord(mod.default);
|
|
1610
|
+
} catch {
|
|
1611
|
+
return {};
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1567
1615
|
// src/utils.ts
|
|
1568
1616
|
function parseI18nLang(lang, localeCodes, defaultLang) {
|
|
1569
1617
|
localeCodes = localeCodes || Object.values(LocaleEnum);
|
|
@@ -1601,19 +1649,9 @@ function generatePath(params) {
|
|
|
1601
1649
|
localePath = locale || parseI18nLang(i18n_default.language);
|
|
1602
1650
|
return `/${localePath}${path}${searchUrl}`;
|
|
1603
1651
|
}
|
|
1604
|
-
var
|
|
1605
|
-
const { children, ...rest } = props;
|
|
1606
|
-
return (
|
|
1607
|
-
// @ts-ignore
|
|
1608
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactI18next.I18nextProvider, { ...rest, children })
|
|
1609
|
-
);
|
|
1610
|
-
};
|
|
1611
|
-
var LocaleProvider = (props) => {
|
|
1652
|
+
var LanguageProvider = (props) => {
|
|
1612
1653
|
const {
|
|
1613
1654
|
children,
|
|
1614
|
-
locale,
|
|
1615
|
-
resource,
|
|
1616
|
-
resources: resources2,
|
|
1617
1655
|
backend,
|
|
1618
1656
|
popup,
|
|
1619
1657
|
supportedLanguages,
|
|
@@ -1623,22 +1661,6 @@ var LocaleProvider = (props) => {
|
|
|
1623
1661
|
} = props;
|
|
1624
1662
|
const [languages, setLanguages] = react.useState(defaultLanguages);
|
|
1625
1663
|
const backendRef = react.useRef(new Backend(backend));
|
|
1626
|
-
react.useEffect(() => {
|
|
1627
|
-
if (resources2) {
|
|
1628
|
-
Object.entries(resources2).forEach(([locale2, messages]) => {
|
|
1629
|
-
i18n_default.addResourceBundle(locale2, defaultNS, messages, true, true);
|
|
1630
|
-
});
|
|
1631
|
-
return;
|
|
1632
|
-
}
|
|
1633
|
-
if (resource && locale) {
|
|
1634
|
-
i18n_default.addResourceBundle(locale, defaultNS, resource, true, true);
|
|
1635
|
-
}
|
|
1636
|
-
}, [locale, resource, resources2]);
|
|
1637
|
-
react.useEffect(() => {
|
|
1638
|
-
if (locale && locale !== i18n_default.language) {
|
|
1639
|
-
i18n_default.changeLanguage(locale);
|
|
1640
|
-
}
|
|
1641
|
-
}, [locale]);
|
|
1642
1664
|
react.useEffect(() => {
|
|
1643
1665
|
if (Array.isArray(props.languages)) {
|
|
1644
1666
|
setLanguages(props.languages);
|
|
@@ -1649,7 +1671,7 @@ var LocaleProvider = (props) => {
|
|
|
1649
1671
|
).filter((item) => !!item)
|
|
1650
1672
|
);
|
|
1651
1673
|
}
|
|
1652
|
-
}, [
|
|
1674
|
+
}, [props.languages, supportedLanguages]);
|
|
1653
1675
|
react.useEffect(() => {
|
|
1654
1676
|
const initLanguage = async () => {
|
|
1655
1677
|
const lang = typeof convertDetectedLanguage === "function" ? convertDetectedLanguage(i18n_default.language) : parseI18nLang(i18n_default.language);
|
|
@@ -1681,59 +1703,67 @@ var LocaleProvider = (props) => {
|
|
|
1681
1703
|
onLanguageChanged: languageChangedHandle
|
|
1682
1704
|
};
|
|
1683
1705
|
}, [popup, languages, languageBeforeChangedHandle, languageChangedHandle]);
|
|
1684
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1706
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LanguageContext.Provider, { value: memoizedValue, children });
|
|
1685
1707
|
};
|
|
1686
|
-
function useTranslation(ns, options) {
|
|
1687
|
-
const context = react.useContext(reactI18next.I18nContext);
|
|
1688
|
-
return reactI18next.useTranslation(ns, {
|
|
1689
|
-
i18n: context?.i18n || i18n_default,
|
|
1690
|
-
// @ts-ignore
|
|
1691
|
-
// when the language resource is loaded, notify the translation component to re-render
|
|
1692
|
-
bindI18nStore: "added",
|
|
1693
|
-
...options
|
|
1694
|
-
});
|
|
1695
|
-
}
|
|
1696
1708
|
function useLocaleCode() {
|
|
1697
|
-
const [
|
|
1709
|
+
const [localeCode, setLocaleCode] = react.useState(
|
|
1698
1710
|
parseI18nLang(i18n_default.language)
|
|
1699
1711
|
);
|
|
1700
1712
|
react.useEffect(() => {
|
|
1701
1713
|
const handleLanguageChange = (lng) => {
|
|
1702
|
-
|
|
1714
|
+
setLocaleCode(lng);
|
|
1703
1715
|
};
|
|
1704
1716
|
i18n_default.on("languageChanged", handleLanguageChange);
|
|
1705
1717
|
return () => {
|
|
1706
1718
|
i18n_default.off("languageChanged", handleLanguageChange);
|
|
1707
1719
|
};
|
|
1708
1720
|
}, [i18n_default]);
|
|
1709
|
-
return
|
|
1721
|
+
return localeCode;
|
|
1710
1722
|
}
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
i18n_default.addResourceBundle(defaultLng, defaultNS, messages, true, true);
|
|
1715
|
-
};
|
|
1716
|
-
var asyncAddResource = async (localeCode, resources2) => {
|
|
1717
|
-
const resource = await resources2(localeCode, defaultNS);
|
|
1718
|
-
i18n_default.addResourceBundle(localeCode, defaultNS, resource, true, true);
|
|
1719
|
-
};
|
|
1720
|
-
var ExternalLocaleProvider = (props) => {
|
|
1721
|
-
const { resources: resources2 } = props;
|
|
1722
|
-
const localeCode = useLocaleCode();
|
|
1723
|
+
var LocaleProvider = (props) => {
|
|
1724
|
+
const { children, locale, resource, resources: resources2, ...languageProviderProps } = props;
|
|
1725
|
+
const localeCodeFromI18n = useLocaleCode();
|
|
1723
1726
|
react.useEffect(() => {
|
|
1724
|
-
if (typeof resources2 === "function") {
|
|
1725
|
-
asyncAddResource(localeCode, resources2);
|
|
1726
|
-
return;
|
|
1727
|
-
}
|
|
1728
1727
|
if (resources2) {
|
|
1729
|
-
|
|
1730
|
-
i18n_default.addResourceBundle(locale, defaultNS, messages, true, true);
|
|
1731
|
-
});
|
|
1728
|
+
registerResources(resources2, locale ?? localeCodeFromI18n);
|
|
1732
1729
|
return;
|
|
1733
1730
|
}
|
|
1731
|
+
if (resource && locale) {
|
|
1732
|
+
i18n_default.addResourceBundle(locale, defaultNS, resource, true, true);
|
|
1733
|
+
}
|
|
1734
|
+
}, [locale, localeCodeFromI18n, resource, resources2]);
|
|
1735
|
+
react.useEffect(() => {
|
|
1736
|
+
if (locale && locale !== i18n_default.language) {
|
|
1737
|
+
i18n_default.changeLanguage(locale);
|
|
1738
|
+
}
|
|
1739
|
+
}, [locale]);
|
|
1740
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LanguageProvider, { ...languageProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(reactI18next.I18nextProvider, { i18n: i18n_default, defaultNS, children }) });
|
|
1741
|
+
};
|
|
1742
|
+
function useRegisterExternalResources(resources2) {
|
|
1743
|
+
const localeCode = useLocaleCode();
|
|
1744
|
+
react.useEffect(() => {
|
|
1745
|
+
registerResources(resources2, localeCode);
|
|
1734
1746
|
}, [localeCode, resources2]);
|
|
1747
|
+
}
|
|
1748
|
+
var ExternalLocaleProvider = (props) => {
|
|
1749
|
+
useRegisterExternalResources(props.resources);
|
|
1735
1750
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.children });
|
|
1736
1751
|
};
|
|
1752
|
+
function useTranslation(ns, options) {
|
|
1753
|
+
const context = react.useContext(reactI18next.I18nContext);
|
|
1754
|
+
return reactI18next.useTranslation(ns, {
|
|
1755
|
+
i18n: context?.i18n || i18n_default,
|
|
1756
|
+
// @ts-ignore
|
|
1757
|
+
// when the language resource is loaded, notify the translation component to re-render
|
|
1758
|
+
bindI18nStore: "added",
|
|
1759
|
+
...options
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
// src/external/utils.ts
|
|
1764
|
+
var preloadDefaultResource = (messages) => {
|
|
1765
|
+
i18n_default.addResourceBundle(defaultLng, defaultNS, messages, true, true);
|
|
1766
|
+
};
|
|
1737
1767
|
|
|
1738
1768
|
Object.defineProperty(exports, "createInstance", {
|
|
1739
1769
|
enumerable: true,
|
|
@@ -1743,11 +1773,13 @@ Object.defineProperty(exports, "i18next", {
|
|
|
1743
1773
|
enumerable: true,
|
|
1744
1774
|
get: function () { return i18next__default.default; }
|
|
1745
1775
|
});
|
|
1776
|
+
exports.Backend = Backend;
|
|
1746
1777
|
exports.ExternalLocaleProvider = ExternalLocaleProvider;
|
|
1747
|
-
exports.
|
|
1748
|
-
exports.
|
|
1778
|
+
exports.LanguageContext = LanguageContext;
|
|
1779
|
+
exports.LanguageProvider = LanguageProvider;
|
|
1749
1780
|
exports.LocaleEnum = LocaleEnum;
|
|
1750
1781
|
exports.LocaleProvider = LocaleProvider;
|
|
1782
|
+
exports.asMessageRecord = asMessageRecord;
|
|
1751
1783
|
exports.createI18nInstance = createI18nInstance;
|
|
1752
1784
|
exports.defaultLanguages = defaultLanguages;
|
|
1753
1785
|
exports.defaultLng = defaultLng;
|
|
@@ -1758,11 +1790,15 @@ exports.getLocalePathFromPathname = getLocalePathFromPathname;
|
|
|
1758
1790
|
exports.i18n = i18n_default;
|
|
1759
1791
|
exports.i18nCookieKey = i18nCookieKey;
|
|
1760
1792
|
exports.i18nLocalStorageKey = i18nLocalStorageKey;
|
|
1793
|
+
exports.importLocaleJsonModule = importLocaleJsonModule;
|
|
1761
1794
|
exports.parseI18nLang = parseI18nLang;
|
|
1762
1795
|
exports.preloadDefaultResource = preloadDefaultResource;
|
|
1796
|
+
exports.registerDefaultResource = registerDefaultResource;
|
|
1797
|
+
exports.registerResources = registerResources;
|
|
1763
1798
|
exports.removeLangPrefix = removeLangPrefix;
|
|
1799
|
+
exports.useLanguageContext = useLanguageContext;
|
|
1764
1800
|
exports.useLocaleCode = useLocaleCode;
|
|
1765
|
-
exports.
|
|
1801
|
+
exports.useRegisterExternalResources = useRegisterExternalResources;
|
|
1766
1802
|
exports.useTranslation = useTranslation;
|
|
1767
1803
|
Object.keys(reactI18next).forEach(function (k) {
|
|
1768
1804
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|