@orderly.network/i18n 2.12.0 → 2.12.1-alpha.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 +27 -314
- package/bin/cli.js +92 -37
- package/dist/{constant-D_rlt5w0.d.mts → constant-DkvDyddr.d.mts} +12 -40
- package/dist/{constant-D_rlt5w0.d.ts → constant-DkvDyddr.d.ts} +12 -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 +84 -20
- package/dist/index.d.ts +84 -20
- package/dist/index.js +138 -107
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +129 -106
- package/dist/index.mjs.map +1 -1
- package/dist/locale.csv +7 -105
- package/dist/locales/de.json +7 -37
- package/dist/locales/en.json +7 -37
- package/dist/locales/es.json +7 -37
- package/dist/locales/fr.json +7 -37
- package/dist/locales/id.json +7 -37
- package/dist/locales/it.json +7 -37
- package/dist/locales/ja.json +7 -37
- package/dist/locales/ko.json +7 -37
- package/dist/locales/nl.json +7 -37
- package/dist/locales/pl.json +7 -37
- package/dist/locales/pt.json +7 -37
- package/dist/locales/ru.json +7 -37
- package/dist/locales/tc.json +7 -37
- package/dist/locales/tr.json +7 -37
- package/dist/locales/uk.json +7 -37
- package/dist/locales/vi.json +7 -37
- package/dist/locales/zh.json +7 -37
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +25 -50
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +25 -50
- 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 +13 -11
- package/{script → scripts}/copyLocales.js +1 -1
- package/scripts/filterLocaleKeys.js +127 -0
- package/{script → scripts}/generateCsv.js +3 -3
- package/{script → scripts}/utils.js +20 -14
- /package/{script → scripts}/csv2json.js +0 -0
- /package/{script → scripts}/diffCsv.js +0 -0
- /package/{script → scripts}/fillJson.js +0 -0
- /package/{script → scripts}/generateEnJson.js +0 -0
- /package/{script → scripts}/generateMissingKeys.js +0 -0
- /package/{script → scripts}/json-csv-converter.js +0 -0
- /package/{script → scripts}/json2csv.js +0 -0
- /package/{script → scripts}/mergeJson.js +0 -0
- /package/{script → scripts}/separateJson.js +0 -0
package/README.md
CHANGED
|
@@ -1,334 +1,47 @@
|
|
|
1
1
|
# @orderly.network/i18n
|
|
2
2
|
|
|
3
|
-
Internationalization and
|
|
3
|
+
Internationalization and CLI tools for Orderly SDK. Based on i18next ecosystem.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Quick start
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### 1. Wrap Your App with LocaleProvider
|
|
10
|
-
|
|
11
|
-
The LocaleProvider is the core component that supplies localized resources to your application. Make sure to wrap your app’s root component with LocaleProvider.
|
|
7
|
+
Install the package, wrap your app root with `LocaleProvider`, and you get English by default.
|
|
12
8
|
|
|
13
9
|
```tsx
|
|
14
10
|
import { LocaleProvider } from "@orderly.network/i18n";
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
<YourApp />
|
|
18
|
-
</LocaleProvider>;
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### 2. Provide Locale Data
|
|
22
|
-
|
|
23
|
-
#### Default Language
|
|
24
|
-
|
|
25
|
-
- English (`en`) is included by default.
|
|
26
|
-
|
|
27
|
-
#### Supported Locales
|
|
28
|
-
|
|
29
|
-
We currently support **16 locales**
|
|
30
|
-
|
|
31
|
-
| Locale Code | Language |
|
|
32
|
-
| ----------- | ---------- |
|
|
33
|
-
| `en` | English |
|
|
34
|
-
| `zh` | Chinese |
|
|
35
|
-
| `ja` | Japanese |
|
|
36
|
-
| `es` | Spanish |
|
|
37
|
-
| `ko` | Korean |
|
|
38
|
-
| `vi` | Vietnamese |
|
|
39
|
-
| `de` | German |
|
|
40
|
-
| `fr` | French |
|
|
41
|
-
| `ru` | Russian |
|
|
42
|
-
| `id` | Indonesian |
|
|
43
|
-
| `tr` | Turkish |
|
|
44
|
-
| `it` | Italian |
|
|
45
|
-
| `pt` | Portuguese |
|
|
46
|
-
| `uk` | Ukrainian |
|
|
47
|
-
| `pl` | Polish |
|
|
48
|
-
| `nl` | Dutch |
|
|
49
|
-
|
|
50
|
-
#### CSV for Easy Translation
|
|
51
|
-
|
|
52
|
-
- Each release generates a `dist/locale.csv` file to simplify translation workflows.
|
|
53
|
-
- We provide a CLI tool to convert between CSV and JSON formats.
|
|
54
|
-
|
|
55
|
-
### 3. Extending Locale Files
|
|
56
|
-
|
|
57
|
-
You can localize both the SDK UI and your own custom components.
|
|
58
|
-
|
|
59
|
-
- When adding custom keys, prefix them with `extend.` to avoid conflicts with default keys.
|
|
60
|
-
|
|
61
|
-
```json
|
|
62
|
-
{
|
|
63
|
-
"extend.custom.button.label": "My Custom Button"
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Example
|
|
68
|
-
|
|
69
|
-
Here's a complete example of how to set up the i18n integration:
|
|
70
|
-
|
|
71
|
-
### Async load locale files
|
|
72
|
-
|
|
73
|
-
```typescript
|
|
74
|
-
import { FC, ReactNode } from "react";
|
|
75
|
-
import { WalletConnectorProvider } from "@orderly.network/wallet-connector";
|
|
76
|
-
import { OrderlyAppProvider } from "@orderly.network/react-app";
|
|
77
|
-
import { LocaleProvider, LocaleEnum, LocaleCode } from "@orderly.network/i18n";
|
|
78
|
-
|
|
79
|
-
const OrderlyProvider: FC<{ children: ReactNode }> = (props) => {
|
|
80
|
-
const onLanguageChanged = async (lang: LocaleCode) => {};
|
|
81
|
-
|
|
82
|
-
// please copy build-in locale files (@orderly.network/i18n/locales) to you public/locales
|
|
83
|
-
// and copy you extend locale files to public/locales/extend
|
|
84
|
-
const loadPath = (lang: LocaleCode) => {
|
|
85
|
-
if (lang === LocaleEnum.en) {
|
|
86
|
-
// because en is built-in, we need to load the en extend only
|
|
87
|
-
return `/locales/extend/${lang}.json`;
|
|
88
|
-
}
|
|
89
|
-
return [`/locales/${lang}.json`, `/locales/extend/${lang}.json`];
|
|
90
|
-
};
|
|
91
|
-
|
|
12
|
+
export function App() {
|
|
92
13
|
return (
|
|
93
|
-
<LocaleProvider
|
|
94
|
-
|
|
95
|
-
backend={{ loadPath }}
|
|
96
|
-
>
|
|
97
|
-
<WalletConnectorProvider>
|
|
98
|
-
<OrderlyAppProvider
|
|
99
|
-
brokerId="orderly"
|
|
100
|
-
brokerName="Orderly"
|
|
101
|
-
networkId="testnet"
|
|
102
|
-
>
|
|
103
|
-
{props.children}
|
|
104
|
-
</OrderlyAppProvider>
|
|
105
|
-
</WalletConnectorProvider>
|
|
14
|
+
<LocaleProvider>
|
|
15
|
+
<YourApp />
|
|
106
16
|
</LocaleProvider>
|
|
107
17
|
);
|
|
108
|
-
}
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Sync Load locale data
|
|
112
|
-
|
|
113
|
-
```typescript
|
|
114
|
-
import { FC, ReactNode } from "react";
|
|
115
|
-
import { WalletConnectorProvider } from "@orderly.network/wallet-connector";
|
|
116
|
-
import { OrderlyAppProvider } from "@orderly.network/react-app";
|
|
117
|
-
import { LocaleProvider, LocaleCode, Resources } from "@orderly.network/i18n";
|
|
118
|
-
import zh from "@orderly.network/i18n/locales/zh.json";
|
|
119
|
-
import ja from "@orderly.network/i18n/locales/ja.json";
|
|
120
|
-
import ko from "@orderly.network/i18n/locales/ko.json";
|
|
121
|
-
|
|
122
|
-
// extend or overrides English translations
|
|
123
|
-
const extendEn = {
|
|
124
|
-
"extend.trading": "Trading",
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
// extend or overrides chinese translations
|
|
128
|
-
const extendZh = {
|
|
129
|
-
"extend.trading": "交易",
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
// extend or overrides japanese translations
|
|
133
|
-
const extendJa = {
|
|
134
|
-
"extend.trading": "取引",
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// extend or overrides korean translations
|
|
138
|
-
const extendKo = {
|
|
139
|
-
"extend.trading": "거래",
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
// define language resources
|
|
143
|
-
const resources: Resources = {
|
|
144
|
-
en: extendEn,
|
|
145
|
-
zh: {
|
|
146
|
-
...zh,
|
|
147
|
-
...extendZh,
|
|
148
|
-
},
|
|
149
|
-
ja: {
|
|
150
|
-
...ja,
|
|
151
|
-
...extendJa,
|
|
152
|
-
},
|
|
153
|
-
ko: {
|
|
154
|
-
...ko,
|
|
155
|
-
...extendKo,
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const OrderlyProvider: FC<{ children: ReactNode }> = (props) => {
|
|
160
|
-
const onLanguageChanged = (locale: LocaleCode) => {};
|
|
161
|
-
|
|
162
|
-
return (
|
|
163
|
-
<LocaleProvider resources={resources} onLanguageChanged={onLocaleChange}>
|
|
164
|
-
<WalletConnectorProvider>
|
|
165
|
-
<OrderlyAppProvider
|
|
166
|
-
brokerId="orderly"
|
|
167
|
-
brokerName="Orderly"
|
|
168
|
-
networkId="testnet"
|
|
169
|
-
>
|
|
170
|
-
{props.children}
|
|
171
|
-
</OrderlyAppProvider>
|
|
172
|
-
</WalletConnectorProvider>
|
|
173
|
-
</LocaleProvider>
|
|
174
|
-
);
|
|
175
|
-
};
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### Add custom languages
|
|
179
|
-
|
|
180
|
-
We also support adding more custom languages
|
|
181
|
-
|
|
182
|
-
```typescript
|
|
183
|
-
import { FC, ReactNode } from "react";
|
|
184
|
-
import { WalletConnectorProvider } from "@orderly.network/wallet-connector";
|
|
185
|
-
import { OrderlyAppProvider } from "@orderly.network/react-app";
|
|
186
|
-
import {
|
|
187
|
-
LocaleProvider,
|
|
188
|
-
Resources,
|
|
189
|
-
LocaleEnum,
|
|
190
|
-
LocaleCode,
|
|
191
|
-
Language,
|
|
192
|
-
} from "@orderly.network/i18n";
|
|
193
|
-
|
|
194
|
-
// japanese locale
|
|
195
|
-
const ja = {
|
|
196
|
-
"extend.ja": "日本語",
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
// korean locale
|
|
200
|
-
const ko = {
|
|
201
|
-
"extend.ko": "한국어",
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
// define language resources
|
|
205
|
-
const resources: Resources = {
|
|
206
|
-
ja,
|
|
207
|
-
ko,
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
// custom languages
|
|
211
|
-
const languages: Language[] = [
|
|
212
|
-
{ localCode: LocaleEnum.en, displayName: "English" },
|
|
213
|
-
{ localCode: LocaleEnum.ja, displayName: "日本語" },
|
|
214
|
-
{ localCode: LocaleEnum.ko, displayName: "한국어" },
|
|
215
|
-
];
|
|
216
|
-
|
|
217
|
-
const OrderlyProvider: FC<{ children: ReactNode }> = (props) => {
|
|
218
|
-
const onLanguageChanged = (locale: LocaleCode) => {};
|
|
219
|
-
|
|
220
|
-
return (
|
|
221
|
-
<LocaleProvider
|
|
222
|
-
resources={resources}
|
|
223
|
-
languages={languages}
|
|
224
|
-
onLanguageChanged={onLanguageChanged}
|
|
225
|
-
>
|
|
226
|
-
<WalletConnectorProvider>
|
|
227
|
-
<OrderlyAppProvider
|
|
228
|
-
brokerId="orderly"
|
|
229
|
-
brokerName="Orderly"
|
|
230
|
-
networkId="testnet"
|
|
231
|
-
>
|
|
232
|
-
{props.children}
|
|
233
|
-
</OrderlyAppProvider>
|
|
234
|
-
</WalletConnectorProvider>
|
|
235
|
-
</LocaleProvider>
|
|
236
|
-
);
|
|
237
|
-
};
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
## CLI
|
|
241
|
-
|
|
242
|
-
## Usage
|
|
243
|
-
|
|
244
|
-
The package provides a CLI tool for managing Internationalization files.
|
|
245
|
-
|
|
246
|
-
```bash
|
|
247
|
-
npx @orderly.network/i18n <command> [options]
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
## Commands
|
|
251
|
-
|
|
252
|
-
### csv2json
|
|
253
|
-
|
|
254
|
-
Convert a locale CSV file to multiple locale JSON files.
|
|
255
|
-
|
|
256
|
-
```bash
|
|
257
|
-
npx @orderly.network/i18n csv2json <input> <outputDir>
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
Example:
|
|
261
|
-
|
|
262
|
-
```bash
|
|
263
|
-
npx @orderly.network/i18n csv2json ./dist/locale.csv ./dist/locales
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
### json2csv
|
|
267
|
-
|
|
268
|
-
Convert multiple locale JSON files to a single locale CSV file.
|
|
269
|
-
|
|
270
|
-
```bash
|
|
271
|
-
npx @orderly.network/i18n json2csv <inputDir> <output>
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
Example:
|
|
275
|
-
|
|
276
|
-
```bash
|
|
277
|
-
npx @orderly.network/i18n json2csv ./locales ./dist/locale.csv
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### diffcsv
|
|
281
|
-
|
|
282
|
-
Compare two locale CSV files to find differences.
|
|
283
|
-
|
|
284
|
-
```bash
|
|
285
|
-
npx @orderly.network/i18n diffcsv <oldFile> <newFile>
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
Example:
|
|
289
|
-
|
|
290
|
-
```bash
|
|
291
|
-
npx @orderly.network/i18n diffcsv ./dist/locale1.csv ./dist/locale2.csv
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
### fillJson
|
|
295
|
-
|
|
296
|
-
Fill values from an input locale JSON file and generate a new locale JSON file.
|
|
297
|
-
|
|
298
|
-
```bash
|
|
299
|
-
npx @orderly.network/i18n fillJson <input> <output>
|
|
18
|
+
}
|
|
300
19
|
```
|
|
301
20
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
```bash
|
|
305
|
-
npx @orderly.network/i18n fillJson ./src/locale/zh.json ./dist/locale/zh.json
|
|
306
|
-
```
|
|
21
|
+
For multiple locales, custom keys, Vite bundling, HTTP loading, or the CLI, see the **Documentation** links below.
|
|
307
22
|
|
|
308
|
-
|
|
23
|
+
## Documentation
|
|
309
24
|
|
|
310
|
-
|
|
25
|
+
| Topic | Link |
|
|
26
|
+
| ----------------------------------------------------------------- | -------------------------------------------------------- |
|
|
27
|
+
| AI / Agent integration | [docs/guide/AGENTS.md](./docs/guide/AGENTS.md) |
|
|
28
|
+
| Package exports | [docs/guide/exports.md](./docs/guide/exports.md) |
|
|
29
|
+
| Integration (providers, locales, extend keys, external resources) | [docs/guide/integration.md](./docs/guide/integration.md) |
|
|
30
|
+
| Utils (paths and locale helpers) | [docs/guide/utils.md](./docs/guide/utils.md) |
|
|
31
|
+
| Examples (recommended AsyncResources + alternatives) | [docs/guide/examples.md](./docs/guide/examples.md) |
|
|
32
|
+
| CLI (`i18n` binary) | [docs/guide/cli.md](./docs/guide/cli.md) |
|
|
311
33
|
|
|
312
|
-
|
|
313
|
-
npx @orderly.network/i18n separateJson <inputDir> <outputDir> <separateKey>
|
|
314
|
-
```
|
|
34
|
+
**Suggested reading order:** Agents start with [AGENTS](./docs/guide/AGENTS.md). Otherwise: [Integration](./docs/guide/integration.md) (API and behavior) → [Examples](./docs/guide/examples.md) (copy-paste recipes as needed) → [CLI](./docs/guide/cli.md) / [Utils](./docs/guide/utils.md) when relevant.
|
|
315
35
|
|
|
316
|
-
|
|
36
|
+
Generated API notes for `src/` live under `packages/i18n/docs/` in the monorepo only (not published in the npm package). The **user guide** under `docs/guide/` is included in the package so links above work after `npm install`.
|
|
317
37
|
|
|
318
|
-
|
|
319
|
-
npx @orderly.network/i18n separateJson ./locales ./dist/locales extend
|
|
320
|
-
```
|
|
38
|
+
### Package exports (summary)
|
|
321
39
|
|
|
322
|
-
|
|
40
|
+
| Export | Description |
|
|
41
|
+
| --------------------------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
42
|
+
| `@orderly.network/i18n` | Main entry: providers, hooks, `i18n`, resource helpers, types — see [exports guide](./docs/guide/exports.md) |
|
|
43
|
+
| `@orderly.network/i18n/locales/*` | Built-in locale JSON files |
|
|
44
|
+
| `@orderly.network/i18n/constant` | Constants (`LocaleEnum`, `defaultLanguages`, …) |
|
|
45
|
+
| `@orderly.network/i18n/utils` | Utilities — see [Utils](./docs/guide/utils.md) |
|
|
323
46
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
```bash
|
|
327
|
-
npx @orderly.network/i18n mergeJson <inputDir> <outputDir>
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
Example:
|
|
331
|
-
|
|
332
|
-
```bash
|
|
333
|
-
npx @orderly.network/i18n mergeJson ./dist/locales1 ./dist/locales2
|
|
334
|
-
```
|
|
47
|
+
The default i18n namespace is **`translation`** (`defaultNS`).
|
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;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
|
|
3
3
|
declare const en: {
|
|
4
|
+
"tradingPoints.points": string;
|
|
4
5
|
"notification.campaign": string;
|
|
5
6
|
"notification.delisting": string;
|
|
6
7
|
"notification.general": string;
|
|
@@ -130,42 +131,6 @@ declare const en: {
|
|
|
130
131
|
"errorBoundary.refresh": string;
|
|
131
132
|
"dmm.maker": string;
|
|
132
133
|
"dmm.taker": string;
|
|
133
|
-
"tradingPoints.points": string;
|
|
134
|
-
"tradingPoints.startsIn": string;
|
|
135
|
-
"tradingPoints.days": string;
|
|
136
|
-
"tradingPoints.hours": string;
|
|
137
|
-
"tradingPoints.minutes": string;
|
|
138
|
-
"tradingPoints.seconds": string;
|
|
139
|
-
"tradingPoints.learnMore": string;
|
|
140
|
-
"tradingPoints.stagePoints": string;
|
|
141
|
-
"tradingPoints.stageRanking": string;
|
|
142
|
-
"tradingPoints.referralCode": string;
|
|
143
|
-
"tradingPoints.referralLink": string;
|
|
144
|
-
"tradingPoints.currentPoints": string;
|
|
145
|
-
"tradingPoints.ranking": string;
|
|
146
|
-
"tradingPoints.myPoints": string;
|
|
147
|
-
"tradingPoints.thisWeek": string;
|
|
148
|
-
"tradingPoints.lastWeek": string;
|
|
149
|
-
"tradingPoints.all": string;
|
|
150
|
-
"tradingPoints.tradePoints": string;
|
|
151
|
-
"tradingPoints.tradePointsTooltip": string;
|
|
152
|
-
"tradingPoints.tradeNow": string;
|
|
153
|
-
"tradingPoints.pnlPoints": string;
|
|
154
|
-
"tradingPoints.pnlPointsTooltip": string;
|
|
155
|
-
"tradingPoints.referralPoints": string;
|
|
156
|
-
"tradingPoints.referralPointsTooltip": string;
|
|
157
|
-
"tradingPoints.copyLink": string;
|
|
158
|
-
"tradingPoints.faq.title": string;
|
|
159
|
-
"tradingPoints.faq.whatArePoints.question": string;
|
|
160
|
-
"tradingPoints.faq.whatArePoints.answer": string;
|
|
161
|
-
"tradingPoints.faq.allocation.question": string;
|
|
162
|
-
"tradingPoints.faq.allocation.answer": string;
|
|
163
|
-
"tradingPoints.faq.distribution.question": string;
|
|
164
|
-
"tradingPoints.faq.distribution.answer": string;
|
|
165
|
-
"tradingPoints.faq.pnl.question": string;
|
|
166
|
-
"tradingPoints.faq.pnl.answer": string;
|
|
167
|
-
"tradingPoints.faq.referral.question": string;
|
|
168
|
-
"tradingPoints.faq.referral.answer": string;
|
|
169
134
|
"tradingLeaderboard.leaderboard": string;
|
|
170
135
|
"tradingLeaderboard.campaigns": string;
|
|
171
136
|
"tradingLeaderboard.ongoing": string;
|
|
@@ -226,6 +191,10 @@ declare const en: {
|
|
|
226
191
|
"affiliate.referralCode.label": string;
|
|
227
192
|
"affiliate.referralCode.bound": string;
|
|
228
193
|
"affiliate.referralCode.notExist": string;
|
|
194
|
+
"affiliate.referralCode.bind.modal.title": string;
|
|
195
|
+
"affiliate.referralCode.bind.modal.description": string;
|
|
196
|
+
"affiliate.referralCode.bind.input.placeholder": string;
|
|
197
|
+
"affiliate.referralCode.bind.skip": string;
|
|
229
198
|
"affiliate.process.title": string;
|
|
230
199
|
"affiliate.process.step1.title": string;
|
|
231
200
|
"affiliate.process.step1.description": string;
|
|
@@ -287,6 +256,7 @@ declare const en: {
|
|
|
287
256
|
"affiliate.direct": string;
|
|
288
257
|
"affiliate.directInclBonus": string;
|
|
289
258
|
"affiliate.indirect": string;
|
|
259
|
+
"affiliate.referredBy": string;
|
|
290
260
|
"affiliate.referrals": string;
|
|
291
261
|
"affiliate.referralCode.edit.modal.title": string;
|
|
292
262
|
"affiliate.referralCode.create": string;
|
|
@@ -1300,6 +1270,8 @@ interface LocaleMessages extends EnType, ExtendLocaleMessages {
|
|
|
1300
1270
|
type Resources<T extends {} = {}> = {
|
|
1301
1271
|
[key in LocaleCode]?: Partial<LocaleMessages & T>;
|
|
1302
1272
|
};
|
|
1273
|
+
/** Async loader for a single locale/namespace message table (see `useRegisterExternalResources`, ExternalLocaleProvider, LocaleProvider `resources`). */
|
|
1274
|
+
type AsyncResources = (lang: LocaleCode, ns: string) => Promise<Record<string, string>>;
|
|
1303
1275
|
declare module "i18next" {
|
|
1304
1276
|
interface CustomTypeOptions {
|
|
1305
1277
|
resources: {
|
|
@@ -1327,7 +1299,7 @@ type PopupProps = {
|
|
|
1327
1299
|
/** popup style */
|
|
1328
1300
|
style?: React.CSSProperties;
|
|
1329
1301
|
};
|
|
1330
|
-
type
|
|
1302
|
+
type LanguageContextState = {
|
|
1331
1303
|
/**
|
|
1332
1304
|
* custom languages
|
|
1333
1305
|
*/
|
|
@@ -1345,8 +1317,8 @@ type LocaleContextState = {
|
|
|
1345
1317
|
*/
|
|
1346
1318
|
popup?: PopupProps;
|
|
1347
1319
|
};
|
|
1348
|
-
declare const
|
|
1349
|
-
declare const
|
|
1320
|
+
declare const LanguageContext: react.Context<LanguageContextState>;
|
|
1321
|
+
declare const useLanguageContext: () => LanguageContextState;
|
|
1350
1322
|
|
|
1351
1323
|
declare enum LocaleEnum {
|
|
1352
1324
|
/** English */
|
|
@@ -1390,4 +1362,4 @@ declare const defaultNS = "translation";
|
|
|
1390
1362
|
declare const i18nLocalStorageKey = "orderly_i18nLng";
|
|
1391
1363
|
declare const i18nCookieKey = "orderly_i18nLng";
|
|
1392
1364
|
|
|
1393
|
-
export { type LocaleCode as L, type PopupMode as P, type Resources as R, type
|
|
1365
|
+
export { type AsyncResources as A, type LocaleCode as L, type PopupMode as P, type Resources as R, type LanguageContextState as a, type Language as b, type PopupProps as c, LanguageContext as d, type LocaleMessages as e, LocaleEnum as f, defaultLanguages as g, defaultLng as h, defaultNS as i, i18nLocalStorageKey as j, i18nCookieKey as k, en as l, useLanguageContext as u };
|