@orderly.network/i18n 2.10.2 → 3.0.0-beta.0
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 +193 -34
- package/bin/cli.js +92 -37
- package/dist/{constant-UZhfXyyb.d.mts → constant-BeXwHrGj.d.mts} +27 -0
- package/dist/{constant-UZhfXyyb.d.ts → constant-BeXwHrGj.d.ts} +27 -0
- package/dist/constant.d.mts +1 -1
- package/dist/constant.d.ts +1 -1
- package/dist/index.d.mts +34 -9
- package/dist/index.d.ts +34 -9
- package/dist/index.js +80 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -19
- package/dist/index.mjs.map +1 -1
- package/dist/locale.csv +30 -3
- package/dist/locales/de.json +30 -3
- package/dist/locales/en.json +30 -3
- package/dist/locales/es.json +30 -3
- package/dist/locales/fr.json +30 -3
- package/dist/locales/id.json +30 -3
- package/dist/locales/it.json +30 -3
- package/dist/locales/ja.json +30 -3
- package/dist/locales/ko.json +30 -3
- package/dist/locales/nl.json +30 -3
- package/dist/locales/pl.json +30 -3
- package/dist/locales/pt.json +30 -3
- package/dist/locales/ru.json +30 -3
- package/dist/locales/tc.json +30 -3
- package/dist/locales/tr.json +30 -3
- package/dist/locales/uk.json +30 -3
- package/dist/locales/vi.json +30 -3
- package/dist/locales/zh.json +30 -3
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +46 -12
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +46 -12
- package/dist/utils.mjs.map +1 -1
- package/package.json +7 -7
- package/script/copyLocales.js +0 -11
- package/script/csv2json.js +0 -28
- package/script/diffCsv.js +0 -175
- package/script/fillJson.js +0 -33
- package/script/generateCsv.js +0 -36
- package/script/generateEnJson.js +0 -11
- package/script/generateMissingKeys.js +0 -49
- package/script/json-csv-converter.js +0 -286
- package/script/json2csv.js +0 -38
- package/script/mergeJson.js +0 -67
- package/script/separateJson.js +0 -50
- package/script/utils.js +0 -88
package/README.md
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
# @orderly.network/i18n
|
|
2
2
|
|
|
3
|
-
Internationalization and
|
|
3
|
+
Internationalization and CLI tools for Orderly SDK. Based on i18next ecosystem.
|
|
4
|
+
|
|
5
|
+
**Quick start:** Install the package, wrap your app root with `LocaleProvider`, and you get English by default. For multiple locales or custom keys, see the sections below.
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Integration Guide](#integration-guide)
|
|
10
|
+
- [Wrap Your App with LocaleProvider](#1-wrap-your-app-with-localeprovider)
|
|
11
|
+
- [Provide Locale Data](#2-provide-locale-data)
|
|
12
|
+
- [Extending Locale Files](#3-extending-locale-files)
|
|
13
|
+
- [Integrate External Resources](#4-integrate-external-resources)
|
|
14
|
+
- [Package exports](#package-exports)
|
|
15
|
+
- [Example](#example)
|
|
16
|
+
- [Async load locale files](#async-load-locale-files)
|
|
17
|
+
- [Sync load locale data](#sync-load-locale-data)
|
|
18
|
+
- [Add custom languages](#add-custom-languages)
|
|
19
|
+
- [CLI](#cli)
|
|
20
|
+
- [Usage](#usage)
|
|
21
|
+
- [Commands](#commands)
|
|
22
|
+
|
|
23
|
+
## Package exports
|
|
24
|
+
|
|
25
|
+
| Export | Description |
|
|
26
|
+
| ---------------------------------- | -------------------------------------------------------------------------------- |
|
|
27
|
+
| `@orderly.network/i18n` | Main entry: `LocaleProvider`, hooks, types |
|
|
28
|
+
| `@orderly.network/i18n/locales/`\* | Built-in locale JSON files |
|
|
29
|
+
| `@orderly.network/i18n/constant` | Constants (e.g. `LocaleEnum`) |
|
|
30
|
+
| `@orderly.network/i18n/utils` | Utility functions |
|
|
31
|
+
| `@orderly.network/i18n/external` | External integration helpers: `ExternalLocaleProvider`, `preloadDefaultResource` |
|
|
32
|
+
|
|
33
|
+
**Hooks:** `useTranslation` and `useLocaleCode` are exported from the main entry; use them as with react-i18next and the locale context (see type definitions or `docs/` for details).
|
|
4
34
|
|
|
5
35
|
## Integration Guide
|
|
6
36
|
|
|
@@ -26,26 +56,27 @@ import { LocaleProvider } from "@orderly.network/i18n";
|
|
|
26
56
|
|
|
27
57
|
#### Supported Locales
|
|
28
58
|
|
|
29
|
-
We currently support **
|
|
30
|
-
|
|
31
|
-
| Locale Code | Language
|
|
32
|
-
| ----------- |
|
|
33
|
-
| `en` | English
|
|
34
|
-
| `zh` | Chinese
|
|
35
|
-
| `
|
|
36
|
-
| `
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
39
|
-
| `
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
59
|
+
We currently support **17 locales**
|
|
60
|
+
|
|
61
|
+
| Locale Code | Language |
|
|
62
|
+
| ----------- | ------------------- |
|
|
63
|
+
| `en` | English |
|
|
64
|
+
| `zh` | Chinese |
|
|
65
|
+
| `tc` | Traditional Chinese |
|
|
66
|
+
| `ja` | Japanese |
|
|
67
|
+
| `es` | Spanish |
|
|
68
|
+
| `ko` | Korean |
|
|
69
|
+
| `vi` | Vietnamese |
|
|
70
|
+
| `de` | German |
|
|
71
|
+
| `fr` | French |
|
|
72
|
+
| `ru` | Russian |
|
|
73
|
+
| `id` | Indonesian |
|
|
74
|
+
| `tr` | Turkish |
|
|
75
|
+
| `it` | Italian |
|
|
76
|
+
| `pt` | Portuguese |
|
|
77
|
+
| `uk` | Ukrainian |
|
|
78
|
+
| `pl` | Polish |
|
|
79
|
+
| `nl` | Dutch |
|
|
49
80
|
|
|
50
81
|
#### CSV for Easy Translation
|
|
51
82
|
|
|
@@ -64,9 +95,93 @@ You can localize both the SDK UI and your own custom components.
|
|
|
64
95
|
}
|
|
65
96
|
```
|
|
66
97
|
|
|
98
|
+
### 4. Integrate External Resources
|
|
99
|
+
|
|
100
|
+
In more advanced setups, your translations may live outside of this package (for example, in another bundle, a backend service, or a host application). For these cases, use the external integration helpers.
|
|
101
|
+
|
|
102
|
+
#### ExternalLocaleProvider
|
|
103
|
+
|
|
104
|
+
`ExternalLocaleProvider` lets you register translation resources that come from an external source. It supports both **async** and **sync** resource injection:
|
|
105
|
+
|
|
106
|
+
- **Async mode**: pass a function `(lang, ns) => Promise<Record<string, string>>`. It will be called whenever the locale changes, and the returned messages will replace the in-memory bundle for that locale/namespace.
|
|
107
|
+
- **Sync mode**: pass a static `Resources` map, similar to `LocaleProvider.resources`, and all bundles will be registered on mount.
|
|
108
|
+
|
|
109
|
+
Async example (resources fetched from a host app or backend):
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import { LocaleProvider, LocaleCode, Resources } from "@orderly.network/i18n";
|
|
113
|
+
import {
|
|
114
|
+
ExternalLocaleProvider,
|
|
115
|
+
AsyncResources,
|
|
116
|
+
} from "@orderly.network/i18n/external";
|
|
117
|
+
|
|
118
|
+
const loadExternalMessages: AsyncResources = async (
|
|
119
|
+
lang: LocaleCode,
|
|
120
|
+
ns: string,
|
|
121
|
+
) => {
|
|
122
|
+
// fetch translations from your host app, CDN, or backend
|
|
123
|
+
const res = await fetch(`/i18n/${lang}/${ns}.json`);
|
|
124
|
+
return (await res.json()) as Record<string, string>;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export function App() {
|
|
128
|
+
return (
|
|
129
|
+
<LocaleProvider>
|
|
130
|
+
<ExternalLocaleProvider resources={loadExternalMessages}>
|
|
131
|
+
<YourApp />
|
|
132
|
+
</ExternalLocaleProvider>
|
|
133
|
+
</LocaleProvider>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Sync example (host app provides a static map of messages):
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
import { LocaleProvider, Resources } from "@orderly.network/i18n";
|
|
142
|
+
import { ExternalLocaleProvider } from "@orderly.network/i18n/external";
|
|
143
|
+
|
|
144
|
+
const externalResources: Resources = {
|
|
145
|
+
en: {
|
|
146
|
+
"extend.host.title": "Host app title",
|
|
147
|
+
},
|
|
148
|
+
zh: {
|
|
149
|
+
"extend.host.title": "宿主应用标题",
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export function App() {
|
|
154
|
+
return (
|
|
155
|
+
<LocaleProvider>
|
|
156
|
+
<ExternalLocaleProvider resources={externalResources}>
|
|
157
|
+
<YourApp />
|
|
158
|
+
</ExternalLocaleProvider>
|
|
159
|
+
</LocaleProvider>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
`ExternalLocaleProvider` renders no UI; it only manages i18n side effects and simply returns its children.
|
|
165
|
+
|
|
166
|
+
#### Preload default resources
|
|
167
|
+
|
|
168
|
+
`preloadDefaultResource` is a small helper that pre-registers the default language bundle before your React tree renders, which helps avoid a brief flash of raw translation keys:
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
import { preloadDefaultResource } from "@orderly.network/i18n/external";
|
|
172
|
+
|
|
173
|
+
// typically run once during app bootstrap
|
|
174
|
+
preloadDefaultResource({
|
|
175
|
+
"extend.app.loading": "Loading...",
|
|
176
|
+
"extend.app.title": "Orderly App",
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
It uses a deep merge with overwrite semantics, so subsequent calls will keep the in-memory bundle in sync with your external source of truth.
|
|
181
|
+
|
|
67
182
|
## Example
|
|
68
183
|
|
|
69
|
-
|
|
184
|
+
You can load locale data in three ways: **async** via `backend.loadPath` (e.g. from your `public/locales`), **sync** by passing preloaded `resources`, or **custom** by defining a `languages` list and per-locale resources.
|
|
70
185
|
|
|
71
186
|
### Async load locale files
|
|
72
187
|
|
|
@@ -108,7 +223,9 @@ const OrderlyProvider: FC<{ children: ReactNode }> = (props) => {
|
|
|
108
223
|
};
|
|
109
224
|
```
|
|
110
225
|
|
|
111
|
-
### Sync
|
|
226
|
+
### Sync load locale data
|
|
227
|
+
|
|
228
|
+
Use this when you bundle locale JSON (e.g. import from `@orderly.network/i18n/locales/*`) and do not need async loading.
|
|
112
229
|
|
|
113
230
|
```typescript
|
|
114
231
|
import { FC, ReactNode } from "react";
|
|
@@ -160,7 +277,7 @@ const OrderlyProvider: FC<{ children: ReactNode }> = (props) => {
|
|
|
160
277
|
const onLanguageChanged = (locale: LocaleCode) => {};
|
|
161
278
|
|
|
162
279
|
return (
|
|
163
|
-
<LocaleProvider resources={resources} onLanguageChanged={
|
|
280
|
+
<LocaleProvider resources={resources} onLanguageChanged={onLanguageChanged}>
|
|
164
281
|
<WalletConnectorProvider>
|
|
165
282
|
<OrderlyAppProvider
|
|
166
283
|
brokerId="orderly"
|
|
@@ -177,7 +294,7 @@ const OrderlyProvider: FC<{ children: ReactNode }> = (props) => {
|
|
|
177
294
|
|
|
178
295
|
### Add custom languages
|
|
179
296
|
|
|
180
|
-
|
|
297
|
+
You can restrict the language list and provide only the locales you need via `languages` and `resources`.
|
|
181
298
|
|
|
182
299
|
```typescript
|
|
183
300
|
import { FC, ReactNode } from "react";
|
|
@@ -239,15 +356,15 @@ const OrderlyProvider: FC<{ children: ReactNode }> = (props) => {
|
|
|
239
356
|
|
|
240
357
|
## CLI
|
|
241
358
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
The package provides a CLI tool for managing Internationalization files.
|
|
359
|
+
### Usage
|
|
245
360
|
|
|
246
361
|
```bash
|
|
247
362
|
npx @orderly.network/i18n <command> [options]
|
|
248
363
|
```
|
|
249
364
|
|
|
250
|
-
|
|
365
|
+
The CLI manages locale files: CSV/JSON conversion, diff, merge, and key filtering. Commands are listed below.
|
|
366
|
+
|
|
367
|
+
### Commands
|
|
251
368
|
|
|
252
369
|
### csv2json
|
|
253
370
|
|
|
@@ -265,7 +382,7 @@ npx @orderly.network/i18n csv2json ./dist/locale.csv ./dist/locales
|
|
|
265
382
|
|
|
266
383
|
### json2csv
|
|
267
384
|
|
|
268
|
-
Convert multiple locale JSON files
|
|
385
|
+
Convert multiple locale JSON files from any directory into a single locale CSV file (generic JSON → CSV).
|
|
269
386
|
|
|
270
387
|
```bash
|
|
271
388
|
npx @orderly.network/i18n json2csv <inputDir> <output>
|
|
@@ -291,9 +408,23 @@ Example:
|
|
|
291
408
|
npx @orderly.network/i18n diffcsv ./dist/locale1.csv ./dist/locale2.csv
|
|
292
409
|
```
|
|
293
410
|
|
|
411
|
+
### generateCsv
|
|
412
|
+
|
|
413
|
+
Generate a locale CSV file from locale JSON files. Typically used for the package’s own `locales` directory (e.g. when building or releasing).
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
npx @orderly.network/i18n generateCsv <inputDir> <output>
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
Example:
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
npx @orderly.network/i18n generateCsv ./locales ./dist/locale.csv
|
|
423
|
+
```
|
|
424
|
+
|
|
294
425
|
### fillJson
|
|
295
426
|
|
|
296
|
-
|
|
427
|
+
Build a new locale JSON with the same keys as the built-in English set, filling values from the input file (missing keys become empty). Useful for filling missing keys in a locale from another language or template.
|
|
297
428
|
|
|
298
429
|
```bash
|
|
299
430
|
npx @orderly.network/i18n fillJson <input> <output>
|
|
@@ -307,7 +438,7 @@ npx @orderly.network/i18n fillJson ./src/locale/zh.json ./dist/locale/zh.json
|
|
|
307
438
|
|
|
308
439
|
### separateJson
|
|
309
440
|
|
|
310
|
-
|
|
441
|
+
Split each locale JSON by key prefix: keys starting with `separateKey.` go into an `extend/` subdirectory under `outputDir`, the rest stay at the root of `outputDir`.
|
|
311
442
|
|
|
312
443
|
```bash
|
|
313
444
|
npx @orderly.network/i18n separateJson <inputDir> <outputDir> <separateKey>
|
|
@@ -321,7 +452,7 @@ npx @orderly.network/i18n separateJson ./locales ./dist/locales extend
|
|
|
321
452
|
|
|
322
453
|
### mergeJson
|
|
323
454
|
|
|
324
|
-
Merge default and extend JSON files
|
|
455
|
+
Merge default and extend JSON files from a single input directory into one file per locale. The input directory must contain both the main locale JSON files and an `extend/` subdirectory with matching locale files; merged output is written to `outputDir`.
|
|
325
456
|
|
|
326
457
|
```bash
|
|
327
458
|
npx @orderly.network/i18n mergeJson <inputDir> <outputDir>
|
|
@@ -330,5 +461,33 @@ npx @orderly.network/i18n mergeJson <inputDir> <outputDir>
|
|
|
330
461
|
Example:
|
|
331
462
|
|
|
332
463
|
```bash
|
|
333
|
-
npx @orderly.network/i18n mergeJson ./
|
|
464
|
+
npx @orderly.network/i18n mergeJson ./locales ./dist/locales
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### filterKeys
|
|
468
|
+
|
|
469
|
+
Filter locale JSON keys by prefix: keep only keys matching the prefix, or remove keys matching the prefix. Operates on `packages/i18n/locales` by default (or a custom directory via `--locales-dir`). You must specify exactly one of `--keep` or `--remove`.
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
npx @orderly.network/i18n filterKeys (--keep | -k | --remove | -r) --prefix <prefix> [--locales-dir <dir>]
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
Options:
|
|
476
|
+
|
|
477
|
+
- `--keep`, `-k` — Keep only keys that start with the given prefix.
|
|
478
|
+
- `--remove`, `-r` — Remove keys that start with the given prefix.
|
|
479
|
+
- `--prefix <prefix>` — (Required) Key prefix to match (e.g. `trading.` or `trading`).
|
|
480
|
+
- `--locales-dir <dir>` — Directory containing locale JSON files (default: `packages/i18n/locales`).
|
|
481
|
+
|
|
482
|
+
Examples:
|
|
483
|
+
|
|
484
|
+
```bash
|
|
485
|
+
# Keep only keys with prefix "trading."
|
|
486
|
+
npx @orderly.network/i18n filterKeys --keep --prefix trading.
|
|
487
|
+
|
|
488
|
+
# Remove keys with prefix "trading." (short form)
|
|
489
|
+
npx @orderly.network/i18n filterKeys -r --prefix trading.
|
|
490
|
+
|
|
491
|
+
# Use a custom locales directory
|
|
492
|
+
npx @orderly.network/i18n filterKeys -k --prefix extend. --locales-dir ./my-locales
|
|
334
493
|
```
|
package/bin/cli.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
const yargs = require("yargs/yargs");
|
|
4
4
|
const { hideBin } = require("yargs/helpers");
|
|
5
|
-
|
|
6
|
-
const { json2csv } = require("../
|
|
7
|
-
const { csv2json } = require("../
|
|
8
|
-
const { diffCsv } = require("../
|
|
9
|
-
const { fillJson } = require("../
|
|
10
|
-
const { separateJson } = require("../
|
|
11
|
-
const { mergeJson } = require("../
|
|
5
|
+
const { generateCsv } = require("../scripts/generateCsv");
|
|
6
|
+
const { json2csv } = require("../scripts/json2csv");
|
|
7
|
+
const { csv2json } = require("../scripts/csv2json");
|
|
8
|
+
const { diffCsv } = require("../scripts/diffCsv");
|
|
9
|
+
const { fillJson } = require("../scripts/fillJson");
|
|
10
|
+
const { separateJson } = require("../scripts/separateJson");
|
|
11
|
+
const { mergeJson } = require("../scripts/mergeJson");
|
|
12
|
+
const { filterLocaleKeys } = require("../scripts/filterLocaleKeys");
|
|
12
13
|
main();
|
|
13
14
|
|
|
14
15
|
async function main() {
|
|
@@ -23,6 +24,10 @@ async function main() {
|
|
|
23
24
|
inputDir,
|
|
24
25
|
outputDir,
|
|
25
26
|
separateKey,
|
|
27
|
+
keep,
|
|
28
|
+
remove,
|
|
29
|
+
prefix,
|
|
30
|
+
localesDir,
|
|
26
31
|
} = argv;
|
|
27
32
|
|
|
28
33
|
const command = _[0];
|
|
@@ -38,9 +43,9 @@ async function main() {
|
|
|
38
43
|
case "diffcsv":
|
|
39
44
|
await diffCsv(oldFile, newFile);
|
|
40
45
|
break;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
case "generateCsv":
|
|
47
|
+
await generateCsv(inputDir, output);
|
|
48
|
+
break;
|
|
44
49
|
case "fillJson":
|
|
45
50
|
await fillJson(input, output);
|
|
46
51
|
break;
|
|
@@ -50,6 +55,9 @@ async function main() {
|
|
|
50
55
|
case "mergeJson":
|
|
51
56
|
await mergeJson(inputDir, outputDir);
|
|
52
57
|
break;
|
|
58
|
+
case "filterKeys":
|
|
59
|
+
filterLocaleKeys(remove ? "remove" : "keep", prefix, localesDir);
|
|
60
|
+
break;
|
|
53
61
|
default:
|
|
54
62
|
console.log("Invalid command");
|
|
55
63
|
break;
|
|
@@ -87,9 +95,9 @@ function getArgv() {
|
|
|
87
95
|
},
|
|
88
96
|
(argv) => {
|
|
89
97
|
console.log(
|
|
90
|
-
`Converting ${argv.input} to locale JSON files, output directory: ${argv.outputDir}
|
|
98
|
+
`Converting ${argv.input} to locale JSON files, output directory: ${argv.outputDir}`,
|
|
91
99
|
);
|
|
92
|
-
}
|
|
100
|
+
},
|
|
93
101
|
)
|
|
94
102
|
|
|
95
103
|
// json2csv command
|
|
@@ -112,9 +120,9 @@ function getArgv() {
|
|
|
112
120
|
},
|
|
113
121
|
(argv) => {
|
|
114
122
|
console.log(
|
|
115
|
-
`Converting locale JSON files: ${argv.inputDir} to locale CSV: ${argv.output}
|
|
123
|
+
`Converting locale JSON files: ${argv.inputDir} to locale CSV: ${argv.output}`,
|
|
116
124
|
);
|
|
117
|
-
}
|
|
125
|
+
},
|
|
118
126
|
)
|
|
119
127
|
|
|
120
128
|
// diffcsv command
|
|
@@ -136,27 +144,32 @@ function getArgv() {
|
|
|
136
144
|
},
|
|
137
145
|
(argv) => {
|
|
138
146
|
console.log(
|
|
139
|
-
`Comparing locale CSV files: ${argv.oldFile} and ${argv.newFile}
|
|
147
|
+
`Comparing locale CSV files: ${argv.oldFile} and ${argv.newFile}`,
|
|
140
148
|
);
|
|
141
|
-
}
|
|
149
|
+
},
|
|
142
150
|
)
|
|
143
151
|
|
|
144
152
|
// generateCsv command
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
153
|
+
.command(
|
|
154
|
+
"generateCsv <inputDir> <output>",
|
|
155
|
+
"Generate a locale CSV file from locale JSON files",
|
|
156
|
+
(yargs) => {
|
|
157
|
+
return yargs
|
|
158
|
+
.positional("inputDir", {
|
|
159
|
+
describe: "Input directory for locale JSON files",
|
|
160
|
+
type: "string",
|
|
161
|
+
demandOption: true,
|
|
162
|
+
})
|
|
163
|
+
.positional("output", {
|
|
164
|
+
describe: "Output path for the locale CSV file",
|
|
165
|
+
type: "string",
|
|
166
|
+
demandOption: true,
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
(argv) => {
|
|
170
|
+
console.log(`Generating locale CSV file at: ${argv.output}`);
|
|
171
|
+
},
|
|
172
|
+
)
|
|
160
173
|
|
|
161
174
|
// fillJson command
|
|
162
175
|
.command(
|
|
@@ -177,9 +190,9 @@ function getArgv() {
|
|
|
177
190
|
},
|
|
178
191
|
(argv) => {
|
|
179
192
|
console.log(
|
|
180
|
-
`Filling values from the input locale JSON file: ${argv.input} and generating a new locale JSON file: ${argv.output}
|
|
193
|
+
`Filling values from the input locale JSON file: ${argv.input} and generating a new locale JSON file: ${argv.output}`,
|
|
181
194
|
);
|
|
182
|
-
}
|
|
195
|
+
},
|
|
183
196
|
)
|
|
184
197
|
|
|
185
198
|
// separateJson command
|
|
@@ -206,9 +219,9 @@ function getArgv() {
|
|
|
206
219
|
},
|
|
207
220
|
(argv) => {
|
|
208
221
|
console.log(
|
|
209
|
-
`Separating json files into multiple files: ${argv.inputDir} to ${argv.outputDir} with key: ${argv.key}
|
|
222
|
+
`Separating json files into multiple files: ${argv.inputDir} to ${argv.outputDir} with key: ${argv.key}`,
|
|
210
223
|
);
|
|
211
|
-
}
|
|
224
|
+
},
|
|
212
225
|
)
|
|
213
226
|
|
|
214
227
|
// mergeJson command
|
|
@@ -231,9 +244,51 @@ function getArgv() {
|
|
|
231
244
|
},
|
|
232
245
|
(argv) => {
|
|
233
246
|
console.log(
|
|
234
|
-
`Merging JSON files from ${argv.inputDir} to ${argv.outputDir}
|
|
247
|
+
`Merging JSON files from ${argv.inputDir} to ${argv.outputDir}`,
|
|
248
|
+
);
|
|
249
|
+
},
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
// filterKeys command (filterLocaleKeys script)
|
|
253
|
+
.command(
|
|
254
|
+
"filterKeys [options]",
|
|
255
|
+
"Filter locale JSON keys by prefix: keep or remove keys matching the prefix (operates on packages/i18n/locales by default)",
|
|
256
|
+
(yargs) => {
|
|
257
|
+
return yargs
|
|
258
|
+
.option("keep", {
|
|
259
|
+
alias: "k",
|
|
260
|
+
type: "boolean",
|
|
261
|
+
describe: "Keep only keys that start with the given prefix",
|
|
262
|
+
})
|
|
263
|
+
.option("remove", {
|
|
264
|
+
alias: "r",
|
|
265
|
+
type: "boolean",
|
|
266
|
+
describe: "Remove keys that start with the given prefix",
|
|
267
|
+
})
|
|
268
|
+
.option("prefix", {
|
|
269
|
+
type: "string",
|
|
270
|
+
demandOption: true,
|
|
271
|
+
describe: "Key prefix to match (e.g. trading. or trading)",
|
|
272
|
+
})
|
|
273
|
+
.option("locales-dir", {
|
|
274
|
+
type: "string",
|
|
275
|
+
describe:
|
|
276
|
+
"Directory containing locale JSON files (default: packages/i18n/locales)",
|
|
277
|
+
})
|
|
278
|
+
.check((argv) => {
|
|
279
|
+
if (argv.keep === argv.remove) {
|
|
280
|
+
throw new Error(
|
|
281
|
+
"Please specify exactly one of --keep|-k or --remove|-r",
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
return true;
|
|
285
|
+
});
|
|
286
|
+
},
|
|
287
|
+
(argv) => {
|
|
288
|
+
console.log(
|
|
289
|
+
`Filtering locale keys: ${argv.remove ? "removing" : "keeping"} keys with prefix "${argv.prefix}"`,
|
|
235
290
|
);
|
|
236
|
-
}
|
|
291
|
+
},
|
|
237
292
|
);
|
|
238
293
|
|
|
239
294
|
return argv.argv;
|
|
@@ -452,6 +452,7 @@ declare const en: {
|
|
|
452
452
|
"transfer.LTV.description": string;
|
|
453
453
|
"transfer.LTV.tooltip": string;
|
|
454
454
|
"transfer.LTV.currentLTV": string;
|
|
455
|
+
"transfer.LTV.isolatedModeUsdcOnly": string;
|
|
455
456
|
"transfer.convert": string;
|
|
456
457
|
"transfer.deposit.globalMaxQty.error": string;
|
|
457
458
|
"transfer.deposit.gasFee.error": string;
|
|
@@ -668,6 +669,20 @@ declare const en: {
|
|
|
668
669
|
"orderEntry.slTriggerPrice.error.max": string;
|
|
669
670
|
"orderEntry.total.error.min": string;
|
|
670
671
|
"orderEntry.initialMarginTotal.error.min": string;
|
|
672
|
+
"marginMode.switchMarginMode": string;
|
|
673
|
+
"marginMode.cross": string;
|
|
674
|
+
"marginMode.isolated": string;
|
|
675
|
+
"marginMode.crossMargin": string;
|
|
676
|
+
"marginMode.isolatedMargin": string;
|
|
677
|
+
"marginMode.crossMarginDescription": string;
|
|
678
|
+
"marginMode.isolatedMarginDescription": string;
|
|
679
|
+
"marginMode.current": string;
|
|
680
|
+
"marginMode.marginModeSettings": string;
|
|
681
|
+
"marginMode.updatedSuccessfully": string;
|
|
682
|
+
"marginMode.perpetualFutures": string;
|
|
683
|
+
"marginMode.searchPlaceholder": string;
|
|
684
|
+
"marginMode.selectAll": string;
|
|
685
|
+
"marginMode.setAs": string;
|
|
671
686
|
"orderEntry.startPrice.error.required": string;
|
|
672
687
|
"orderEntry.startPrice.error.min": string;
|
|
673
688
|
"orderEntry.startPrice.error.max": string;
|
|
@@ -885,6 +900,17 @@ declare const en: {
|
|
|
885
900
|
"positions.reverse.marketOpenShort": string;
|
|
886
901
|
"positions.reverse.reverseToLong": string;
|
|
887
902
|
"positions.reverse.reverseToShort": string;
|
|
903
|
+
"positions.adjustMargin.title": string;
|
|
904
|
+
"positions.adjustMargin.add": string;
|
|
905
|
+
"positions.adjustMargin.reduce": string;
|
|
906
|
+
"positions.adjustMargin.quantity": string;
|
|
907
|
+
"positions.adjustMargin.max": string;
|
|
908
|
+
"positions.adjustMargin.currentMargin": string;
|
|
909
|
+
"positions.adjustMargin.liqPriceAfter": string;
|
|
910
|
+
"positions.adjustMargin.leverageAfter": string;
|
|
911
|
+
"positions.adjustMargin.success": string;
|
|
912
|
+
"positions.adjustMargin.failed": string;
|
|
913
|
+
"positions.adjustMargin.marginCannotMoreThanMax": string;
|
|
888
914
|
"chart.now": string;
|
|
889
915
|
"trading.layout": string;
|
|
890
916
|
"trading.layout.advanced": string;
|
|
@@ -1106,6 +1132,7 @@ declare const en: {
|
|
|
1106
1132
|
"markets.symbolInfoBar.predFundingRate": string;
|
|
1107
1133
|
"markets.symbolInfoBar.predFundingRate.tooltip": string;
|
|
1108
1134
|
"common.cancel": string;
|
|
1135
|
+
"common.close": string;
|
|
1109
1136
|
"common.confirm": string;
|
|
1110
1137
|
"common.ok": string;
|
|
1111
1138
|
"common.yes": string;
|
|
@@ -452,6 +452,7 @@ declare const en: {
|
|
|
452
452
|
"transfer.LTV.description": string;
|
|
453
453
|
"transfer.LTV.tooltip": string;
|
|
454
454
|
"transfer.LTV.currentLTV": string;
|
|
455
|
+
"transfer.LTV.isolatedModeUsdcOnly": string;
|
|
455
456
|
"transfer.convert": string;
|
|
456
457
|
"transfer.deposit.globalMaxQty.error": string;
|
|
457
458
|
"transfer.deposit.gasFee.error": string;
|
|
@@ -668,6 +669,20 @@ declare const en: {
|
|
|
668
669
|
"orderEntry.slTriggerPrice.error.max": string;
|
|
669
670
|
"orderEntry.total.error.min": string;
|
|
670
671
|
"orderEntry.initialMarginTotal.error.min": string;
|
|
672
|
+
"marginMode.switchMarginMode": string;
|
|
673
|
+
"marginMode.cross": string;
|
|
674
|
+
"marginMode.isolated": string;
|
|
675
|
+
"marginMode.crossMargin": string;
|
|
676
|
+
"marginMode.isolatedMargin": string;
|
|
677
|
+
"marginMode.crossMarginDescription": string;
|
|
678
|
+
"marginMode.isolatedMarginDescription": string;
|
|
679
|
+
"marginMode.current": string;
|
|
680
|
+
"marginMode.marginModeSettings": string;
|
|
681
|
+
"marginMode.updatedSuccessfully": string;
|
|
682
|
+
"marginMode.perpetualFutures": string;
|
|
683
|
+
"marginMode.searchPlaceholder": string;
|
|
684
|
+
"marginMode.selectAll": string;
|
|
685
|
+
"marginMode.setAs": string;
|
|
671
686
|
"orderEntry.startPrice.error.required": string;
|
|
672
687
|
"orderEntry.startPrice.error.min": string;
|
|
673
688
|
"orderEntry.startPrice.error.max": string;
|
|
@@ -885,6 +900,17 @@ declare const en: {
|
|
|
885
900
|
"positions.reverse.marketOpenShort": string;
|
|
886
901
|
"positions.reverse.reverseToLong": string;
|
|
887
902
|
"positions.reverse.reverseToShort": string;
|
|
903
|
+
"positions.adjustMargin.title": string;
|
|
904
|
+
"positions.adjustMargin.add": string;
|
|
905
|
+
"positions.adjustMargin.reduce": string;
|
|
906
|
+
"positions.adjustMargin.quantity": string;
|
|
907
|
+
"positions.adjustMargin.max": string;
|
|
908
|
+
"positions.adjustMargin.currentMargin": string;
|
|
909
|
+
"positions.adjustMargin.liqPriceAfter": string;
|
|
910
|
+
"positions.adjustMargin.leverageAfter": string;
|
|
911
|
+
"positions.adjustMargin.success": string;
|
|
912
|
+
"positions.adjustMargin.failed": string;
|
|
913
|
+
"positions.adjustMargin.marginCannotMoreThanMax": string;
|
|
888
914
|
"chart.now": string;
|
|
889
915
|
"trading.layout": string;
|
|
890
916
|
"trading.layout.advanced": string;
|
|
@@ -1106,6 +1132,7 @@ declare const en: {
|
|
|
1106
1132
|
"markets.symbolInfoBar.predFundingRate": string;
|
|
1107
1133
|
"markets.symbolInfoBar.predFundingRate.tooltip": string;
|
|
1108
1134
|
"common.cancel": string;
|
|
1135
|
+
"common.close": string;
|
|
1109
1136
|
"common.confirm": string;
|
|
1110
1137
|
"common.ok": string;
|
|
1111
1138
|
"common.yes": string;
|
package/dist/constant.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { f as LocaleEnum, g as defaultLanguages, h as defaultLng, i as defaultNS, k as i18nCookieKey, j as i18nLocalStorageKey } from './constant-
|
|
1
|
+
export { f as LocaleEnum, g as defaultLanguages, h as defaultLng, i as defaultNS, k as i18nCookieKey, j as i18nLocalStorageKey } from './constant-BeXwHrGj.mjs';
|
|
2
2
|
import 'react';
|
package/dist/constant.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { f as LocaleEnum, g as defaultLanguages, h as defaultLng, i as defaultNS, k as i18nCookieKey, j as i18nLocalStorageKey } from './constant-
|
|
1
|
+
export { f as LocaleEnum, g as defaultLanguages, h as defaultLng, i as defaultNS, k as i18nCookieKey, j as i18nLocalStorageKey } from './constant-BeXwHrGj.js';
|
|
2
2
|
import 'react';
|