@orderly.network/i18n 3.0.4-alpha.2 → 3.0.4-alpha.4
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/dist/{constant-BwPxVQ3H.d.mts → constant-CIx423sl.d.mts} +2 -0
- package/dist/{constant-BwPxVQ3H.d.ts → constant-CIx423sl.d.ts} +2 -0
- package/dist/constant.d.mts +1 -1
- package/dist/constant.d.ts +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +96 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -14
- package/dist/index.mjs.map +1 -1
- package/dist/locale.csv +4 -2
- package/dist/locales/de.json +4 -2
- package/dist/locales/en.json +3 -1
- package/dist/locales/es.json +4 -2
- package/dist/locales/fr.json +4 -2
- package/dist/locales/id.json +4 -2
- package/dist/locales/it.json +4 -2
- package/dist/locales/ja.json +4 -2
- package/dist/locales/ko.json +4 -2
- package/dist/locales/nl.json +4 -2
- package/dist/locales/pl.json +4 -2
- package/dist/locales/pt.json +4 -2
- package/dist/locales/ru.json +4 -2
- package/dist/locales/tc.json +4 -2
- package/dist/locales/tr.json +4 -2
- package/dist/locales/uk.json +4 -2
- package/dist/locales/vi.json +4 -2
- package/dist/locales/zh.json +4 -2
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +38 -1
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +38 -1
- package/dist/utils.mjs.map +1 -1
- package/docs/guide/integration.md +76 -27
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -637,7 +637,7 @@ var orderEntry = {
|
|
|
637
637
|
"marginMode.crossMargin": "Cross Margin",
|
|
638
638
|
"marginMode.isolatedMargin": "Isolated Margin",
|
|
639
639
|
"marginMode.crossMarginDescription": "Margin and PnL are shared across positions. You may lose all positions if liquidation occurs.",
|
|
640
|
-
"marginMode.isolatedMarginDescription": "Margin and PnL are independent for each position. You'll only lose the current position if liquidation occurs.",
|
|
640
|
+
"marginMode.isolatedMarginDescription": "Margin and PnL are independent for each position. You'll only lose the current position if liquidation occurs. Only USDC is accepted as collateral. <0>Learn more</0>",
|
|
641
641
|
"marginMode.current": "Current",
|
|
642
642
|
"marginMode.marginModeSettings": "Margin mode settings",
|
|
643
643
|
"marginMode.updatedSuccessfully": "Updated successfully",
|
|
@@ -1308,6 +1308,8 @@ var transfer = {
|
|
|
1308
1308
|
"transfer.LTV.tooltip": `If your LTV exceeds {{threshold}}% or your USDC balance plus Unsettled PnL falls below {{usdcThreshold}}, your collateral will be automatically converted with a haircut. To avoid this, you can manually convert assets to USDC.`,
|
|
1309
1309
|
"transfer.LTV.currentLTV": "Current LTV",
|
|
1310
1310
|
"transfer.LTV.isolatedModeUsdcOnly": "Only USDC can be used as margin in Isolated Mode.",
|
|
1311
|
+
"transfer.LTV.availableCrossMarginHint": "Available balance = USDC balance + Unsettled PnL. All collateral assets contribute to your available margin.",
|
|
1312
|
+
"transfer.LTV.isolatedMarginOrderHint": "In Isolated Margin mode, only USDC is accepted as margin. Convert your assets to USDC to place orders.",
|
|
1311
1313
|
"transfer.convert": "Convert",
|
|
1312
1314
|
// "transfer.convert.note": "Please note that convert fees will be charged.",
|
|
1313
1315
|
"transfer.deposit.globalMaxQty.error": "Your deposit couldn't be processed because the global deposit cap for {{token}} on {{chain}} has been reached. This is typically resolved after rebalancing, which takes around 1 hour. Please try again later, or use a smaller amount or a different chain. <0>Learn more</0>",
|
|
@@ -1483,6 +1485,25 @@ var en = {
|
|
|
1483
1485
|
...navigation
|
|
1484
1486
|
};
|
|
1485
1487
|
|
|
1488
|
+
// src/resourceBundles/externalResources.ts
|
|
1489
|
+
var externalResourcePreloaders = /* @__PURE__ */ new Set();
|
|
1490
|
+
function registerExternalResourcePreloader(preloader) {
|
|
1491
|
+
externalResourcePreloaders.add(preloader);
|
|
1492
|
+
return () => {
|
|
1493
|
+
externalResourcePreloaders.delete(preloader);
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1496
|
+
async function preloadExternalResources(lang) {
|
|
1497
|
+
await Promise.all(
|
|
1498
|
+
Array.from(externalResourcePreloaders).map(async (preloader) => {
|
|
1499
|
+
try {
|
|
1500
|
+
await preloader(lang);
|
|
1501
|
+
} catch (error) {
|
|
1502
|
+
}
|
|
1503
|
+
})
|
|
1504
|
+
);
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1486
1507
|
// src/i18n.ts
|
|
1487
1508
|
var resources = {
|
|
1488
1509
|
[defaultLng]: { [defaultNS]: en }
|
|
@@ -1506,6 +1527,28 @@ function createI18nInstance(options) {
|
|
|
1506
1527
|
var i18n = createI18nInstance({
|
|
1507
1528
|
resources
|
|
1508
1529
|
});
|
|
1530
|
+
var parseChangeLanguageTarget = (lang) => {
|
|
1531
|
+
if (!lang) {
|
|
1532
|
+
return void 0;
|
|
1533
|
+
}
|
|
1534
|
+
const localeCodes = Object.values(LocaleEnum);
|
|
1535
|
+
if (localeCodes.includes(lang)) {
|
|
1536
|
+
return lang;
|
|
1537
|
+
}
|
|
1538
|
+
const match = lang.match(/^([a-z]{2})/i);
|
|
1539
|
+
if (match && localeCodes.includes(match[1])) {
|
|
1540
|
+
return match[1];
|
|
1541
|
+
}
|
|
1542
|
+
return lang;
|
|
1543
|
+
};
|
|
1544
|
+
var originalChangeLanguage = i18n.changeLanguage.bind(i18n);
|
|
1545
|
+
i18n.changeLanguage = (async (lang, callback) => {
|
|
1546
|
+
const localeCode = parseChangeLanguageTarget(lang);
|
|
1547
|
+
if (localeCode) {
|
|
1548
|
+
await preloadExternalResources(localeCode);
|
|
1549
|
+
}
|
|
1550
|
+
return originalChangeLanguage(lang, callback);
|
|
1551
|
+
});
|
|
1509
1552
|
i18n.init();
|
|
1510
1553
|
var i18n_default = i18n;
|
|
1511
1554
|
var LanguageContext = createContext({
|
|
@@ -1715,18 +1758,63 @@ function useLocaleCode() {
|
|
|
1715
1758
|
}, [i18n_default]);
|
|
1716
1759
|
return localeCode;
|
|
1717
1760
|
}
|
|
1761
|
+
|
|
1762
|
+
// src/hooks/useRegisterExternalResources.ts
|
|
1763
|
+
var asyncResourceLoadCache = /* @__PURE__ */ new WeakMap();
|
|
1764
|
+
function getAsyncResourceLoadState(resources2) {
|
|
1765
|
+
let state = asyncResourceLoadCache.get(resources2);
|
|
1766
|
+
if (!state) {
|
|
1767
|
+
state = {
|
|
1768
|
+
loadedLocales: /* @__PURE__ */ new Set(),
|
|
1769
|
+
pendingLoads: /* @__PURE__ */ new Map()
|
|
1770
|
+
};
|
|
1771
|
+
asyncResourceLoadCache.set(resources2, state);
|
|
1772
|
+
}
|
|
1773
|
+
return state;
|
|
1774
|
+
}
|
|
1775
|
+
function loadAsyncResources(resources2, localeCode) {
|
|
1776
|
+
const state = getAsyncResourceLoadState(resources2);
|
|
1777
|
+
if (state.loadedLocales.has(localeCode)) {
|
|
1778
|
+
return Promise.resolve();
|
|
1779
|
+
}
|
|
1780
|
+
const pendingLoad = state.pendingLoads.get(localeCode);
|
|
1781
|
+
if (pendingLoad) {
|
|
1782
|
+
return pendingLoad;
|
|
1783
|
+
}
|
|
1784
|
+
const loadPromise = registerResources(resources2, localeCode).then(() => {
|
|
1785
|
+
state.loadedLocales.add(localeCode);
|
|
1786
|
+
}).finally(() => {
|
|
1787
|
+
state.pendingLoads.delete(localeCode);
|
|
1788
|
+
});
|
|
1789
|
+
state.pendingLoads.set(localeCode, loadPromise);
|
|
1790
|
+
return loadPromise;
|
|
1791
|
+
}
|
|
1792
|
+
function useRegisterExternalResources(resources2) {
|
|
1793
|
+
const localeCode = useLocaleCode();
|
|
1794
|
+
useEffect(() => {
|
|
1795
|
+
if (typeof resources2 === "function") {
|
|
1796
|
+
return registerExternalResourcePreloader(
|
|
1797
|
+
(lang) => loadAsyncResources(resources2, lang)
|
|
1798
|
+
);
|
|
1799
|
+
}
|
|
1800
|
+
}, [resources2]);
|
|
1801
|
+
useEffect(() => {
|
|
1802
|
+
if (typeof resources2 === "function") {
|
|
1803
|
+
loadAsyncResources(resources2, localeCode).catch((error) => {
|
|
1804
|
+
});
|
|
1805
|
+
} else {
|
|
1806
|
+
registerResources(resources2, localeCode);
|
|
1807
|
+
}
|
|
1808
|
+
}, [localeCode, resources2]);
|
|
1809
|
+
}
|
|
1718
1810
|
var LocaleProvider = (props) => {
|
|
1719
1811
|
const { children, locale, resource, resources: resources2, ...languageProviderProps } = props;
|
|
1720
|
-
|
|
1812
|
+
useRegisterExternalResources(resources2);
|
|
1721
1813
|
useEffect(() => {
|
|
1722
|
-
if (resources2) {
|
|
1723
|
-
registerResources(resources2, locale ?? localeCodeFromI18n);
|
|
1724
|
-
return;
|
|
1725
|
-
}
|
|
1726
|
-
if (resource && locale) {
|
|
1814
|
+
if (!resources2 && resource && locale) {
|
|
1727
1815
|
i18n_default.addResourceBundle(locale, defaultNS, resource, true, true);
|
|
1728
1816
|
}
|
|
1729
|
-
}, [locale,
|
|
1817
|
+
}, [locale, resource, resources2]);
|
|
1730
1818
|
useEffect(() => {
|
|
1731
1819
|
if (locale && locale !== i18n_default.language) {
|
|
1732
1820
|
i18n_default.changeLanguage(locale);
|
|
@@ -1734,12 +1822,6 @@ var LocaleProvider = (props) => {
|
|
|
1734
1822
|
}, [locale]);
|
|
1735
1823
|
return /* @__PURE__ */ jsx(LanguageProvider, { ...languageProviderProps, children: /* @__PURE__ */ jsx(I18nextProvider, { i18n: i18n_default, defaultNS, children }) });
|
|
1736
1824
|
};
|
|
1737
|
-
function useRegisterExternalResources(resources2) {
|
|
1738
|
-
const localeCode = useLocaleCode();
|
|
1739
|
-
useEffect(() => {
|
|
1740
|
-
registerResources(resources2, localeCode);
|
|
1741
|
-
}, [localeCode, resources2]);
|
|
1742
|
-
}
|
|
1743
1825
|
var ExternalLocaleProvider = (props) => {
|
|
1744
1826
|
useRegisterExternalResources(props.resources);
|
|
1745
1827
|
return /* @__PURE__ */ jsx(Fragment, { children: props.children });
|