@liberfi.io/i18n 0.1.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 +334 -0
- package/bin/cli.js +240 -0
- package/dist/constant.d.mts +9 -0
- package/dist/constant.d.ts +9 -0
- package/dist/constant.js +2 -0
- package/dist/constant.js.map +1 -0
- package/dist/constant.mjs +2 -0
- package/dist/constant.mjs.map +1 -0
- package/dist/index.d.mts +80 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/locale.csv +25 -0
- package/dist/locales/en.json +26 -0
- package/dist/types-DY-Gbo__.d.mts +81 -0
- package/dist/types-DY-Gbo__.d.ts +81 -0
- package/dist/utils.d.mts +63 -0
- package/dist/utils.d.ts +63 -0
- package/dist/utils.js +2 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +2 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +84 -0
- package/script/copyLocales.js +11 -0
- package/script/csv2json.js +28 -0
- package/script/diffCsv.js +175 -0
- package/script/fillJson.js +33 -0
- package/script/generateCsv.js +36 -0
- package/script/generateEnJson.js +11 -0
- package/script/generateMissingKeys.js +48 -0
- package/script/json-csv-converter.js +201 -0
- package/script/json2csv.js +38 -0
- package/script/mergeJson.js +62 -0
- package/script/separateJson.js +50 -0
- package/script/utils.js +88 -0
package/README.md
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
# @liberfi.io/i18n
|
|
2
|
+
|
|
3
|
+
Internationalization and cli tools for Liberfi React SDK. Based on i18next ecosystem.
|
|
4
|
+
|
|
5
|
+
## Integration Guide
|
|
6
|
+
|
|
7
|
+
Follow these steps to integrate localization support in your app using Liberfi React SDK:
|
|
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.
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { LocaleProvider } from "@liberfi.io/i18n";
|
|
15
|
+
|
|
16
|
+
<LocaleProvider>
|
|
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 "@liberfi.io/wallet-connector";
|
|
76
|
+
import { LiberfiAppProvider } from "@liberfi.io/react-app";
|
|
77
|
+
import { LocaleProvider, LocaleEnum, LocaleCode } from "@liberfi.io/i18n";
|
|
78
|
+
|
|
79
|
+
const LiberfiProvider: FC<{ children: ReactNode }> = (props) => {
|
|
80
|
+
const onLanguageChanged = async (lang: LocaleCode) => {};
|
|
81
|
+
|
|
82
|
+
// please copy build-in locale files (@liberfi.io/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
|
+
|
|
92
|
+
return (
|
|
93
|
+
<LocaleProvider
|
|
94
|
+
onLanguageChanged={onLanguageChanged}
|
|
95
|
+
backend={{ loadPath }}
|
|
96
|
+
>
|
|
97
|
+
<WalletConnectorProvider>
|
|
98
|
+
<LiberfiAppProvider
|
|
99
|
+
brokerId="liberfi"
|
|
100
|
+
brokerName="Liberfi"
|
|
101
|
+
networkId="testnet"
|
|
102
|
+
>
|
|
103
|
+
{props.children}
|
|
104
|
+
</LiberfiAppProvider>
|
|
105
|
+
</WalletConnectorProvider>
|
|
106
|
+
</LocaleProvider>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Sync Load locale data
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { FC, ReactNode } from "react";
|
|
115
|
+
import { WalletConnectorProvider } from "@liberfi.io/wallet-connector";
|
|
116
|
+
import { LiberfiAppProvider } from "@liberfi.io/react-app";
|
|
117
|
+
import { LocaleProvider, LocaleCode, Resources } from "@liberfi.io/i18n";
|
|
118
|
+
import zh from "@liberfi.io/i18n/locales/zh.json";
|
|
119
|
+
import ja from "@liberfi.io/i18n/locales/ja.json";
|
|
120
|
+
import ko from "@liberfi.io/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 LiberfiProvider: FC<{ children: ReactNode }> = (props) => {
|
|
160
|
+
const onLanguageChanged = (locale: LocaleCode) => {};
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<LocaleProvider resources={resources} onLanguageChanged={onLocaleChange}>
|
|
164
|
+
<WalletConnectorProvider>
|
|
165
|
+
<LiberfiAppProvider
|
|
166
|
+
brokerId="liberfi"
|
|
167
|
+
brokerName="Liberfi"
|
|
168
|
+
networkId="testnet"
|
|
169
|
+
>
|
|
170
|
+
{props.children}
|
|
171
|
+
</LiberfiAppProvider>
|
|
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 "@liberfi.io/wallet-connector";
|
|
185
|
+
import { LiberfiAppProvider } from "@liberfi.io/react-app";
|
|
186
|
+
import {
|
|
187
|
+
LocaleProvider,
|
|
188
|
+
Resources,
|
|
189
|
+
LocaleEnum,
|
|
190
|
+
LocaleCode,
|
|
191
|
+
Language,
|
|
192
|
+
} from "@liberfi.io/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 LiberfiProvider: 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
|
+
<LiberfiAppProvider
|
|
228
|
+
brokerId="liberfi"
|
|
229
|
+
brokerName="Liberfi"
|
|
230
|
+
networkId="testnet"
|
|
231
|
+
>
|
|
232
|
+
{props.children}
|
|
233
|
+
</LiberfiAppProvider>
|
|
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 @liberfi.io/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 @liberfi.io/i18n csv2json <input> <outputDir>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Example:
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
npx @liberfi.io/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 @liberfi.io/i18n json2csv <inputDir> <output>
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Example:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
npx @liberfi.io/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 @liberfi.io/i18n diffcsv <oldFile> <newFile>
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Example:
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
npx @liberfi.io/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 @liberfi.io/i18n fillJson <input> <output>
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Example:
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
npx @liberfi.io/i18n fillJson ./src/locale/zh.json ./dist/locale/zh.json
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### separateJson
|
|
309
|
+
|
|
310
|
+
Separate JSON files into default and extend key values based on a specified key.
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
npx @liberfi.io/i18n separateJson <inputDir> <outputDir> <separateKey>
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Example:
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
npx @liberfi.io/i18n separateJson ./locales ./dist/locales extend
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### mergeJson
|
|
323
|
+
|
|
324
|
+
Merge default and extend JSON files back into one file.
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
npx @liberfi.io/i18n mergeJson <inputDir> <outputDir>
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Example:
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
npx @liberfi.io/i18n mergeJson ./dist/locales1 ./dist/locales2
|
|
334
|
+
```
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const yargs = require("yargs/yargs");
|
|
4
|
+
const { hideBin } = require("yargs/helpers");
|
|
5
|
+
// const { generateCsv } = require("../script/generateCsv");
|
|
6
|
+
const { json2csv } = require("../script/json2csv");
|
|
7
|
+
const { csv2json } = require("../script/csv2json");
|
|
8
|
+
const { diffCsv } = require("../script/diffCsv");
|
|
9
|
+
const { fillJson } = require("../script/fillJson");
|
|
10
|
+
const { separateJson } = require("../script/separateJson");
|
|
11
|
+
const { mergeJson } = require("../script/mergeJson");
|
|
12
|
+
main();
|
|
13
|
+
|
|
14
|
+
async function main() {
|
|
15
|
+
const argv = getArgv();
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
_,
|
|
19
|
+
input,
|
|
20
|
+
output,
|
|
21
|
+
oldFile,
|
|
22
|
+
newFile,
|
|
23
|
+
inputDir,
|
|
24
|
+
outputDir,
|
|
25
|
+
separateKey,
|
|
26
|
+
} = argv;
|
|
27
|
+
|
|
28
|
+
const command = _[0];
|
|
29
|
+
// console.log("argv", argv);
|
|
30
|
+
|
|
31
|
+
switch (command) {
|
|
32
|
+
case "json2csv":
|
|
33
|
+
await json2csv(inputDir, output);
|
|
34
|
+
break;
|
|
35
|
+
case "csv2json":
|
|
36
|
+
await csv2json(input, outputDir);
|
|
37
|
+
break;
|
|
38
|
+
case "diffcsv":
|
|
39
|
+
await diffCsv(oldFile, newFile);
|
|
40
|
+
break;
|
|
41
|
+
// case "generateCsv":
|
|
42
|
+
// await generateCsv(output);
|
|
43
|
+
// break;
|
|
44
|
+
case "fillJson":
|
|
45
|
+
await fillJson(input, output);
|
|
46
|
+
break;
|
|
47
|
+
case "separateJson":
|
|
48
|
+
await separateJson(inputDir, outputDir, separateKey);
|
|
49
|
+
break;
|
|
50
|
+
case "mergeJson":
|
|
51
|
+
await mergeJson(inputDir, outputDir);
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
console.log("Invalid command");
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function getArgv() {
|
|
60
|
+
const argv = yargs(hideBin(process.argv))
|
|
61
|
+
.scriptName("")
|
|
62
|
+
.usage("i18n locale tools")
|
|
63
|
+
.usage("$0 <command> [options]")
|
|
64
|
+
.strict()
|
|
65
|
+
// Error if no subcommand is provided
|
|
66
|
+
.demandCommand(1, "Please provide a valid subcommand")
|
|
67
|
+
.help()
|
|
68
|
+
// Add `-h` as an alias for `--help`
|
|
69
|
+
.alias("h", "help")
|
|
70
|
+
|
|
71
|
+
// csv2json command
|
|
72
|
+
.command(
|
|
73
|
+
"csv2json <input> <outputDir>",
|
|
74
|
+
"Convert locale CSV to multiple locale JSON files",
|
|
75
|
+
(yargs) => {
|
|
76
|
+
return yargs
|
|
77
|
+
.positional("input", {
|
|
78
|
+
describe: "Input path for the locale CSV file",
|
|
79
|
+
type: "string",
|
|
80
|
+
demandOption: true,
|
|
81
|
+
})
|
|
82
|
+
.positional("outputDir", {
|
|
83
|
+
describe: "Output directory for locale JSON files",
|
|
84
|
+
type: "string",
|
|
85
|
+
demandOption: true,
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
(argv) => {
|
|
89
|
+
console.log(
|
|
90
|
+
`Converting ${argv.input} to locale JSON files, output directory: ${argv.outputDir}`,
|
|
91
|
+
);
|
|
92
|
+
},
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
// json2csv command
|
|
96
|
+
.command(
|
|
97
|
+
"json2csv <inputDir> <output>",
|
|
98
|
+
"Convert locale JSON files to a locale CSV file",
|
|
99
|
+
(yargs) => {
|
|
100
|
+
return yargs
|
|
101
|
+
.positional("inputDir", {
|
|
102
|
+
describe:
|
|
103
|
+
"Input directory for locale JSON files (all JSON files in the directory will be converted)",
|
|
104
|
+
type: "string",
|
|
105
|
+
demandOption: true,
|
|
106
|
+
})
|
|
107
|
+
.positional("output", {
|
|
108
|
+
describe: "Output path for the locale CSV file",
|
|
109
|
+
type: "string",
|
|
110
|
+
demandOption: true,
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
(argv) => {
|
|
114
|
+
console.log(
|
|
115
|
+
`Converting locale JSON files: ${argv.inputDir} to locale CSV: ${argv.output}`,
|
|
116
|
+
);
|
|
117
|
+
},
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
// diffcsv command
|
|
121
|
+
.command(
|
|
122
|
+
"diffcsv <oldFile> <newFile>",
|
|
123
|
+
"Compare two locale CSV files",
|
|
124
|
+
(yargs) => {
|
|
125
|
+
return yargs
|
|
126
|
+
.positional("oldFile", {
|
|
127
|
+
describe: "Path to the first locale CSV file",
|
|
128
|
+
type: "string",
|
|
129
|
+
demandOption: true,
|
|
130
|
+
})
|
|
131
|
+
.positional("newFile", {
|
|
132
|
+
describe: "Path to the second CSV file",
|
|
133
|
+
type: "string",
|
|
134
|
+
demandOption: true,
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
(argv) => {
|
|
138
|
+
console.log(
|
|
139
|
+
`Comparing locale CSV files: ${argv.oldFile} and ${argv.newFile}`,
|
|
140
|
+
);
|
|
141
|
+
},
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
// generateCsv command
|
|
145
|
+
// .command(
|
|
146
|
+
// "generateCsv <output>",
|
|
147
|
+
// "Generate a locale CSV file",
|
|
148
|
+
// (yargs) => {
|
|
149
|
+
// return yargs.positional("output", {
|
|
150
|
+
// describe: "Output path for the locale CSV file",
|
|
151
|
+
// type: "string",
|
|
152
|
+
// // Required
|
|
153
|
+
// demandOption: true,
|
|
154
|
+
// });
|
|
155
|
+
// },
|
|
156
|
+
// (argv) => {
|
|
157
|
+
// console.log(`Generating locale CSV file at: ${argv.output}`);
|
|
158
|
+
// }
|
|
159
|
+
// )
|
|
160
|
+
|
|
161
|
+
// fillJson command
|
|
162
|
+
.command(
|
|
163
|
+
"fillJson <input> <output>",
|
|
164
|
+
"Fill values from the input locale JSON file and generate a new locale JSON file",
|
|
165
|
+
(yargs) => {
|
|
166
|
+
return yargs
|
|
167
|
+
.positional("input", {
|
|
168
|
+
describe: "Input path for the locale JSON file",
|
|
169
|
+
type: "string",
|
|
170
|
+
demandOption: true,
|
|
171
|
+
})
|
|
172
|
+
.positional("output", {
|
|
173
|
+
describe: "Output path for the locale JSON file",
|
|
174
|
+
type: "string",
|
|
175
|
+
demandOption: true,
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
(argv) => {
|
|
179
|
+
console.log(
|
|
180
|
+
`Filling values from the input locale JSON file: ${argv.input} and generating a new locale JSON file: ${argv.output}`,
|
|
181
|
+
);
|
|
182
|
+
},
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
// separateJson command
|
|
186
|
+
.command(
|
|
187
|
+
"separateJson <inputDir> <outputDir> <separateKey>",
|
|
188
|
+
"Separate json file default and extend key values based on the key",
|
|
189
|
+
(yargs) => {
|
|
190
|
+
return yargs
|
|
191
|
+
.positional("inputDir", {
|
|
192
|
+
describe: "Input directory for locale JSON files",
|
|
193
|
+
type: "string",
|
|
194
|
+
demandOption: true,
|
|
195
|
+
})
|
|
196
|
+
.positional("outputDir", {
|
|
197
|
+
describe: "Output directory for locale JSON files",
|
|
198
|
+
type: "string",
|
|
199
|
+
demandOption: true,
|
|
200
|
+
})
|
|
201
|
+
.positional("separateKey", {
|
|
202
|
+
describe: "Key to separate the json files",
|
|
203
|
+
type: "string",
|
|
204
|
+
demandOption: true,
|
|
205
|
+
});
|
|
206
|
+
},
|
|
207
|
+
(argv) => {
|
|
208
|
+
console.log(
|
|
209
|
+
`Separating json files into multiple files: ${argv.inputDir} to ${argv.outputDir} with key: ${argv.key}`,
|
|
210
|
+
);
|
|
211
|
+
},
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
// mergeJson command
|
|
215
|
+
.command(
|
|
216
|
+
"mergeJson <inputDir> <outputDir>",
|
|
217
|
+
"Merge default and extend JSON files back into one file",
|
|
218
|
+
(yargs) => {
|
|
219
|
+
return yargs
|
|
220
|
+
.positional("inputDir", {
|
|
221
|
+
describe:
|
|
222
|
+
"Input directory containing both default and extend JSON files",
|
|
223
|
+
type: "string",
|
|
224
|
+
demandOption: true,
|
|
225
|
+
})
|
|
226
|
+
.positional("outputDir", {
|
|
227
|
+
describe: "Output directory for merged JSON files",
|
|
228
|
+
type: "string",
|
|
229
|
+
demandOption: true,
|
|
230
|
+
});
|
|
231
|
+
},
|
|
232
|
+
(argv) => {
|
|
233
|
+
console.log(
|
|
234
|
+
`Merging JSON files from ${argv.inputDir} to ${argv.outputDir}`,
|
|
235
|
+
);
|
|
236
|
+
},
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
return argv.argv;
|
|
240
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { a as Language } from './types-DY-Gbo__.mjs';
|
|
2
|
+
|
|
3
|
+
declare const defaultLanguages: Language[];
|
|
4
|
+
declare const defaultLng = LocaleEnum.en;
|
|
5
|
+
declare const defaultNS = "translation";
|
|
6
|
+
declare const i18nLocalStorageKey = "liberfi_i18nLng";
|
|
7
|
+
declare const i18nCookieKey = "liberfi_i18nLng";
|
|
8
|
+
|
|
9
|
+
export { defaultLanguages, defaultLng, defaultNS, i18nCookieKey, i18nLocalStorageKey };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { a as Language } from './types-DY-Gbo__.js';
|
|
2
|
+
|
|
3
|
+
declare const defaultLanguages: Language[];
|
|
4
|
+
declare const defaultLng = LocaleEnum.en;
|
|
5
|
+
declare const defaultNS = "translation";
|
|
6
|
+
declare const i18nLocalStorageKey = "liberfi_i18nLng";
|
|
7
|
+
declare const i18nCookieKey = "liberfi_i18nLng";
|
|
8
|
+
|
|
9
|
+
export { defaultLanguages, defaultLng, defaultNS, i18nCookieKey, i18nLocalStorageKey };
|
package/dist/constant.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';require('i18next');var t=[{localCode:"en",displayName:"English"},{localCode:"zh",displayName:"\u4E2D\u6587"},{localCode:"ja",displayName:"\u65E5\u672C\u8A9E"},{localCode:"es",displayName:"Espa\xF1ol"},{localCode:"ko",displayName:"\uD55C\uAD6D\uC5B4"},{localCode:"vi",displayName:"Ti\u1EBFng Vi\u1EC7t"},{localCode:"de",displayName:"Deutsch"},{localCode:"fr",displayName:"Fran\xE7ais"},{localCode:"ru",displayName:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{localCode:"id",displayName:"Bahasa Indonesia"},{localCode:"tr",displayName:"T\xFCrk\xE7e"},{localCode:"it",displayName:"Italiano"},{localCode:"pt",displayName:"Portugu\xEAs"},{localCode:"uk",displayName:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{localCode:"pl",displayName:"Polski"},{localCode:"nl",displayName:"Nederlands"}],d="en",i="translation",p="liberfi_i18nLng",r="liberfi_i18nLng";exports.defaultLanguages=t;exports.defaultLng=d;exports.defaultNS=i;exports.i18nCookieKey=r;exports.i18nLocalStorageKey=p;//# sourceMappingURL=constant.js.map
|
|
2
|
+
//# sourceMappingURL=constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constant.ts"],"names":["defaultLanguages","defaultLng","defaultNS","i18nLocalStorageKey","i18nCookieKey"],"mappings":"gCAEO,IAAMA,CAAAA,CAA+B,CAC1C,CAAE,SAAA,CAAA,IAAA,CAA0B,YAAa,SAAU,CAAA,CACnD,CAAE,SAAA,CAAA,IAAA,CAA0B,WAAA,CAAa,cAAK,CAAA,CAC9C,CAAE,eAA0B,WAAA,CAAa,oBAAM,EAC/C,CAAE,SAAA,CAAA,IAAA,CAA0B,YAAa,YAAU,CAAA,CACnD,CAAE,SAAA,CAAA,IAAA,CAA0B,WAAA,CAAa,oBAAM,CAAA,CAC/C,CAAE,eAA0B,WAAA,CAAa,sBAAa,EACtD,CAAE,SAAA,CAAA,IAAA,CAA0B,YAAa,SAAU,CAAA,CACnD,CAAE,SAAA,CAAA,IAAA,CAA0B,WAAA,CAAa,aAAW,CAAA,CACpD,CAAE,SAAA,CAAA,IAAA,CAA0B,WAAA,CAAa,4CAAU,CAAA,CACnD,CAAE,eAA0B,WAAA,CAAa,kBAAmB,EAC5D,CAAE,SAAA,CAAA,IAAA,CAA0B,YAAa,cAAS,CAAA,CAClD,CAAE,SAAA,CAAA,IAAA,CAA0B,WAAA,CAAa,UAAW,CAAA,CACpD,CAAE,eAA0B,WAAA,CAAa,cAAY,EACrD,CAAE,SAAA,CAAA,IAAA,CAA0B,YAAa,8DAAa,CAAA,CACtD,CAAE,SAAA,CAAA,IAAA,CAA0B,WAAA,CAAa,QAAS,CAAA,CAClD,CAAE,eAA0B,WAAA,CAAa,YAAa,CACxD,CAAA,CAEaC,CAAAA,CAAAA,IAAAA,CAEAC,EAAY,aAAA,CAEZC,CAAAA,CAAsB,kBAEtBC,CAAAA,CAAgB","file":"constant.js","sourcesContent":["import { Language, LocaleEnum } from \"./types\";\n\nexport const defaultLanguages: Language[] = [\n { localCode: LocaleEnum.en, displayName: \"English\" }, // English\n { localCode: LocaleEnum.zh, displayName: \"中文\" }, // Chinese\n { localCode: LocaleEnum.ja, displayName: \"日本語\" }, // Japanese\n { localCode: LocaleEnum.es, displayName: \"Español\" }, // Spanish\n { localCode: LocaleEnum.ko, displayName: \"한국어\" }, // Korean\n { localCode: LocaleEnum.vi, displayName: \"Tiếng Việt\" }, // Vietnamese\n { localCode: LocaleEnum.de, displayName: \"Deutsch\" }, // German\n { localCode: LocaleEnum.fr, displayName: \"Français\" }, // French\n { localCode: LocaleEnum.ru, displayName: \"Русский\" }, // Russian\n { localCode: LocaleEnum.id, displayName: \"Bahasa Indonesia\" }, // Indonesian\n { localCode: LocaleEnum.tr, displayName: \"Türkçe\" }, // Turkish\n { localCode: LocaleEnum.it, displayName: \"Italiano\" }, // Italian\n { localCode: LocaleEnum.pt, displayName: \"Português\" }, // Portuguese\n { localCode: LocaleEnum.uk, displayName: \"Українська\" }, // Ukrainian\n { localCode: LocaleEnum.pl, displayName: \"Polski\" }, // Polish\n { localCode: LocaleEnum.nl, displayName: \"Nederlands\" }, // Dutch\n];\n\nexport const defaultLng = LocaleEnum.en;\n\nexport const defaultNS = \"translation\";\n\nexport const i18nLocalStorageKey = \"liberfi_i18nLng\";\n\nexport const i18nCookieKey = \"liberfi_i18nLng\";\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import'i18next';var t=[{localCode:"en",displayName:"English"},{localCode:"zh",displayName:"\u4E2D\u6587"},{localCode:"ja",displayName:"\u65E5\u672C\u8A9E"},{localCode:"es",displayName:"Espa\xF1ol"},{localCode:"ko",displayName:"\uD55C\uAD6D\uC5B4"},{localCode:"vi",displayName:"Ti\u1EBFng Vi\u1EC7t"},{localCode:"de",displayName:"Deutsch"},{localCode:"fr",displayName:"Fran\xE7ais"},{localCode:"ru",displayName:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{localCode:"id",displayName:"Bahasa Indonesia"},{localCode:"tr",displayName:"T\xFCrk\xE7e"},{localCode:"it",displayName:"Italiano"},{localCode:"pt",displayName:"Portugu\xEAs"},{localCode:"uk",displayName:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{localCode:"pl",displayName:"Polski"},{localCode:"nl",displayName:"Nederlands"}],d="en",i="translation",p="liberfi_i18nLng",r="liberfi_i18nLng";export{t as defaultLanguages,d as defaultLng,i as defaultNS,r as i18nCookieKey,p as i18nLocalStorageKey};//# sourceMappingURL=constant.mjs.map
|
|
2
|
+
//# sourceMappingURL=constant.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constant.ts"],"names":["defaultLanguages","defaultLng","defaultNS","i18nLocalStorageKey","i18nCookieKey"],"mappings":"gBAEO,IAAMA,CAAAA,CAA+B,CAC1C,CAAE,SAAA,CAAA,IAAA,CAA0B,YAAa,SAAU,CAAA,CACnD,CAAE,SAAA,CAAA,IAAA,CAA0B,WAAA,CAAa,cAAK,CAAA,CAC9C,CAAE,eAA0B,WAAA,CAAa,oBAAM,EAC/C,CAAE,SAAA,CAAA,IAAA,CAA0B,YAAa,YAAU,CAAA,CACnD,CAAE,SAAA,CAAA,IAAA,CAA0B,WAAA,CAAa,oBAAM,CAAA,CAC/C,CAAE,eAA0B,WAAA,CAAa,sBAAa,EACtD,CAAE,SAAA,CAAA,IAAA,CAA0B,YAAa,SAAU,CAAA,CACnD,CAAE,SAAA,CAAA,IAAA,CAA0B,WAAA,CAAa,aAAW,CAAA,CACpD,CAAE,SAAA,CAAA,IAAA,CAA0B,WAAA,CAAa,4CAAU,CAAA,CACnD,CAAE,eAA0B,WAAA,CAAa,kBAAmB,EAC5D,CAAE,SAAA,CAAA,IAAA,CAA0B,YAAa,cAAS,CAAA,CAClD,CAAE,SAAA,CAAA,IAAA,CAA0B,WAAA,CAAa,UAAW,CAAA,CACpD,CAAE,eAA0B,WAAA,CAAa,cAAY,EACrD,CAAE,SAAA,CAAA,IAAA,CAA0B,YAAa,8DAAa,CAAA,CACtD,CAAE,SAAA,CAAA,IAAA,CAA0B,WAAA,CAAa,QAAS,CAAA,CAClD,CAAE,eAA0B,WAAA,CAAa,YAAa,CACxD,CAAA,CAEaC,CAAAA,CAAAA,IAAAA,CAEAC,EAAY,aAAA,CAEZC,CAAAA,CAAsB,kBAEtBC,CAAAA,CAAgB","file":"constant.mjs","sourcesContent":["import { Language, LocaleEnum } from \"./types\";\n\nexport const defaultLanguages: Language[] = [\n { localCode: LocaleEnum.en, displayName: \"English\" }, // English\n { localCode: LocaleEnum.zh, displayName: \"中文\" }, // Chinese\n { localCode: LocaleEnum.ja, displayName: \"日本語\" }, // Japanese\n { localCode: LocaleEnum.es, displayName: \"Español\" }, // Spanish\n { localCode: LocaleEnum.ko, displayName: \"한국어\" }, // Korean\n { localCode: LocaleEnum.vi, displayName: \"Tiếng Việt\" }, // Vietnamese\n { localCode: LocaleEnum.de, displayName: \"Deutsch\" }, // German\n { localCode: LocaleEnum.fr, displayName: \"Français\" }, // French\n { localCode: LocaleEnum.ru, displayName: \"Русский\" }, // Russian\n { localCode: LocaleEnum.id, displayName: \"Bahasa Indonesia\" }, // Indonesian\n { localCode: LocaleEnum.tr, displayName: \"Türkçe\" }, // Turkish\n { localCode: LocaleEnum.it, displayName: \"Italiano\" }, // Italian\n { localCode: LocaleEnum.pt, displayName: \"Português\" }, // Portuguese\n { localCode: LocaleEnum.uk, displayName: \"Українська\" }, // Ukrainian\n { localCode: LocaleEnum.pl, displayName: \"Polski\" }, // Polish\n { localCode: LocaleEnum.nl, displayName: \"Nederlands\" }, // Dutch\n];\n\nexport const defaultLng = LocaleEnum.en;\n\nexport const defaultNS = \"translation\";\n\nexport const i18nLocalStorageKey = \"liberfi_i18nLng\";\n\nexport const i18nCookieKey = \"liberfi_i18nLng\";\n"]}
|