@scoutello/i18n-magic 0.15.2 โ 0.18.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 +178 -17
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +101 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/check-missing.d.ts +1 -0
- package/dist/commands/check-missing.d.ts.map +1 -0
- package/dist/commands/check-missing.js +13 -0
- package/dist/commands/check-missing.js.map +1 -0
- package/dist/commands/clean.d.ts +3 -0
- package/dist/commands/clean.d.ts.map +1 -0
- package/dist/commands/clean.js +81 -0
- package/dist/commands/clean.js.map +1 -0
- package/dist/commands/create-pruned-namespace-automated.d.ts +20 -0
- package/dist/commands/create-pruned-namespace-automated.d.ts.map +1 -0
- package/dist/commands/create-pruned-namespace-automated.js +98 -0
- package/dist/commands/create-pruned-namespace-automated.js.map +1 -0
- package/dist/commands/create-pruned-namespace.d.ts +3 -0
- package/dist/commands/create-pruned-namespace.d.ts.map +1 -0
- package/dist/commands/create-pruned-namespace.js +122 -0
- package/dist/commands/create-pruned-namespace.js.map +1 -0
- package/dist/commands/replace.d.ts +1 -0
- package/dist/commands/replace.d.ts.map +1 -0
- package/dist/commands/replace.js +58 -0
- package/dist/commands/replace.js.map +1 -0
- package/dist/commands/scan.d.ts +1 -0
- package/dist/commands/scan.d.ts.map +1 -0
- package/dist/commands/scan.js +70 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/sync-locales.d.ts +1 -0
- package/dist/commands/sync-locales.d.ts.map +1 -0
- package/dist/commands/sync-locales.js +78 -0
- package/dist/commands/sync-locales.js.map +1 -0
- package/dist/i18n-magic.cjs.development.js +458 -126
- package/dist/i18n-magic.cjs.development.js.map +1 -1
- package/dist/i18n-magic.cjs.production.min.js +1 -1
- package/dist/i18n-magic.cjs.production.min.js.map +1 -1
- package/dist/i18n-magic.esm.js +449 -126
- package/dist/i18n-magic.esm.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -9
- package/dist/index.js.map +1 -0
- package/dist/lib/languges.d.ts +1 -0
- package/dist/lib/languges.d.ts.map +1 -0
- package/dist/lib/languges.js +146 -0
- package/dist/lib/languges.js.map +1 -0
- package/dist/lib/types.d.ts +8 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +3 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +220 -0
- package/dist/lib/utils.js.map +1 -0
- package/package.json +37 -14
- package/src/cli.ts +117 -0
- package/src/commands/clean.ts +105 -0
- package/src/commands/create-pruned-namespace-automated.ts +165 -0
- package/src/commands/create-pruned-namespace.ts +165 -0
- package/src/commands/scan.ts +12 -0
- package/src/index.ts +23 -106
- package/src/lib/types.ts +8 -0
package/README.md
CHANGED
|
@@ -1,15 +1,47 @@
|
|
|
1
|
-
# i18n Magic
|
|
1
|
+
# i18n Magic โจ
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**The intelligent CLI toolkit that automates your internationalization workflow with AI-powered translations.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
i18n Magic streamlines the entire translation management process for your JavaScript/TypeScript projects. Say goodbye to manually maintaining translation files and hello to automated, context-aware translations that keep your international users happy.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## ๐ What it does
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
- **๐ Smart Detection**: Automatically scans your codebase to find translation keys
|
|
10
|
+
- **๐ค AI Translation**: Generates high-quality translations using OpenAI or Gemini models
|
|
11
|
+
- **๐ Sync & Maintain**: Keeps all your locales in perfect sync
|
|
12
|
+
- **๐งน Clean & Optimize**: Removes unused translations and creates optimized bundles
|
|
13
|
+
- **โก CI/CD Ready**: Perfect for automated workflows and deployment pipelines
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
## ๐ Requirements
|
|
16
|
+
|
|
17
|
+
- JSON-based i18n libraries (react-i18next, next-i18next, vue-i18n, etc.)
|
|
18
|
+
- Node.js 16+
|
|
19
|
+
- An OpenAI or Google Gemini API key
|
|
20
|
+
|
|
21
|
+
## ๐ ๏ธ Quick Setup
|
|
22
|
+
|
|
23
|
+
### 1. Install the package
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install -g @scoutello/i18n-magic
|
|
27
|
+
# or use directly with npx
|
|
28
|
+
npx @scoutello/i18n-magic
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. Set up your API key
|
|
32
|
+
|
|
33
|
+
Create a `.env` file in your project root:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Choose one:
|
|
37
|
+
OPENAI_API_KEY=your_openai_api_key_here
|
|
38
|
+
# OR
|
|
39
|
+
GEMINI_API_KEY=your_gemini_api_key_here
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 3. Create your configuration
|
|
43
|
+
|
|
44
|
+
Create an `i18n-magic.js` file in your project root with your project-specific settings:
|
|
13
45
|
|
|
14
46
|
```js
|
|
15
47
|
module.exports = {
|
|
@@ -27,10 +59,42 @@ module.exports = {
|
|
|
27
59
|
OPENAI_API_KEY: '.', // Alternative to using .env file
|
|
28
60
|
GEMINI_API_KEY: '', // Alternative to using .env file
|
|
29
61
|
disableTranslation: false, // Set to true to skip automatic translations during the scan step. Useful if you want to sync the other languages during CI/CD using sync.
|
|
62
|
+
autoClear: true, // When using the scan command, always run the clean before
|
|
63
|
+
|
|
64
|
+
// Optional: Namespace-specific configurations for pruned translations
|
|
65
|
+
pruneNamespaces: [
|
|
66
|
+
{
|
|
67
|
+
sourceNamespace: 'common',
|
|
68
|
+
newNamespace: 'dashboard',
|
|
69
|
+
globPatterns: ['./apps/dashboard/**/*.tsx', './apps/dashboard/**/*.ts'],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
sourceNamespace: 'common',
|
|
73
|
+
newNamespace: 'mobile',
|
|
74
|
+
globPatterns: ['./apps/mobile/**/*.tsx', './apps/mobile/**/*.ts'],
|
|
75
|
+
},
|
|
76
|
+
],
|
|
30
77
|
};
|
|
31
78
|
```
|
|
32
79
|
|
|
33
|
-
|
|
80
|
+
### 4. Start using i18n Magic
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Scan for missing translations and add them
|
|
84
|
+
npx @scoutello/i18n-magic scan
|
|
85
|
+
|
|
86
|
+
# Check what's missing without making changes
|
|
87
|
+
npx @scoutello/i18n-magic check-missing
|
|
88
|
+
|
|
89
|
+
# Sync all locales from your default language
|
|
90
|
+
npx @scoutello/i18n-magic sync
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## ๐ง Advanced Configuration
|
|
94
|
+
|
|
95
|
+
### Custom Storage Solutions
|
|
96
|
+
|
|
97
|
+
You can provide custom functions for `loadPath` and `savePath` to store translations in other systems like S3, databases, or CDNs:
|
|
34
98
|
|
|
35
99
|
```js
|
|
36
100
|
const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3")
|
|
@@ -73,19 +137,42 @@ module.exports = {
|
|
|
73
137
|
};
|
|
74
138
|
```
|
|
75
139
|
|
|
76
|
-
|
|
140
|
+
## ๐ Available Commands
|
|
141
|
+
|
|
142
|
+
All commands can be run with:
|
|
77
143
|
|
|
78
144
|
```bash
|
|
79
145
|
npx @scoutello/i18n-magic [command]
|
|
80
146
|
```
|
|
81
147
|
|
|
82
|
-
`scan`
|
|
148
|
+
### `scan`
|
|
149
|
+
|
|
150
|
+
Scan your codebase for missing translations and automatically generate them. This command analyzes your code to find translation keys that don't exist in your translation files yet.
|
|
151
|
+
|
|
152
|
+
The command will:
|
|
153
|
+
|
|
154
|
+
1. Scan all files matching your glob patterns for translation usage
|
|
155
|
+
2. Identify missing translation keys in your default locale
|
|
156
|
+
3. Prompt you to provide translations for each missing key
|
|
157
|
+
4. Automatically translate to all other configured locales using AI
|
|
158
|
+
5. Save the new translations to your JSON files
|
|
159
|
+
|
|
160
|
+
This is useful for:
|
|
83
161
|
|
|
84
|
-
|
|
162
|
+
- Adding new translations during development
|
|
163
|
+
- Ensuring all translation keys have corresponding values
|
|
164
|
+
- Maintaining translation consistency across locales
|
|
85
165
|
|
|
86
|
-
`replace`
|
|
166
|
+
### `replace`
|
|
87
167
|
|
|
88
|
-
|
|
168
|
+
Update an existing translation key with a new value and automatically translate it to all other locales. This command allows you to modify existing translations while maintaining consistency across all languages.
|
|
169
|
+
|
|
170
|
+
The command will:
|
|
171
|
+
|
|
172
|
+
1. Prompt you to select or specify the translation key to replace
|
|
173
|
+
2. Ask for the new translation value in your default locale
|
|
174
|
+
3. Automatically translate the new value to all other configured locales using AI
|
|
175
|
+
4. Update all translation files with the new values
|
|
89
176
|
|
|
90
177
|
You can specify the key in two ways:
|
|
91
178
|
|
|
@@ -94,10 +181,84 @@ You can specify the key in two ways:
|
|
|
94
181
|
|
|
95
182
|
If no key is provided, you will be prompted to enter one.
|
|
96
183
|
|
|
97
|
-
|
|
184
|
+
This is useful for:
|
|
185
|
+
|
|
186
|
+
- Updating existing translations that need changes
|
|
187
|
+
- Fixing translation errors across all locales
|
|
188
|
+
- Maintaining consistency when modifying content
|
|
189
|
+
|
|
190
|
+
### `check-missing`
|
|
191
|
+
|
|
192
|
+
Check if there are any missing translations without making any changes. This command performs a dry-run analysis to identify translation gaps in your project.
|
|
193
|
+
|
|
194
|
+
The command will:
|
|
195
|
+
|
|
196
|
+
1. Scan all files matching your glob patterns for translation usage
|
|
197
|
+
2. Check if all found translation keys exist in your translation files
|
|
198
|
+
3. Report any missing translations without prompting for input
|
|
199
|
+
4. Exit with an error code if missing translations are found
|
|
200
|
+
|
|
201
|
+
This is useful for:
|
|
202
|
+
|
|
203
|
+
- CI/CD pipelines to ensure translation completeness
|
|
204
|
+
- Pre-commit hooks to catch missing translations early
|
|
205
|
+
- Quality assurance checks before deployment
|
|
206
|
+
- Automated testing of translation coverage
|
|
207
|
+
|
|
208
|
+
### `sync`
|
|
209
|
+
|
|
210
|
+
Synchronize translations from your default locale to all other configured locales using AI translation. This command takes existing translations in your default language and generates corresponding translations for all other locales.
|
|
211
|
+
|
|
212
|
+
The command will:
|
|
213
|
+
|
|
214
|
+
1. Load all translation keys from your default locale
|
|
215
|
+
2. Identify keys that are missing in other locales
|
|
216
|
+
3. Automatically translate missing keys using AI
|
|
217
|
+
4. Update translation files for all non-default locales
|
|
218
|
+
5. Preserve existing translations (only adds missing ones)
|
|
219
|
+
|
|
220
|
+
This is useful for:
|
|
221
|
+
|
|
222
|
+
- CI/CD pipelines to ensure all locales are up-to-date
|
|
223
|
+
- Batch translation of new content
|
|
224
|
+
- Maintaining translation parity across languages
|
|
225
|
+
- Automated deployment workflows
|
|
226
|
+
|
|
227
|
+
**Note**: This command works best when used with `disableTranslation: true` in your config to separate the scanning and translation phases.
|
|
228
|
+
|
|
229
|
+
### `prune`
|
|
230
|
+
|
|
231
|
+
Create a pruned namespace from an existing namespace, containing only the translation keys that are actually used in specific files. This is useful for creating optimized translation bundles for different parts of your application (e.g., dashboard, mobile app, etc.).
|
|
232
|
+
|
|
233
|
+
The command will:
|
|
234
|
+
|
|
235
|
+
1. Prompt you to select a source namespace to prune from
|
|
236
|
+
2. Ask for a name for the new namespace
|
|
237
|
+
3. Ask for glob patterns to scan for translation usage
|
|
238
|
+
4. Extract all translation keys used in the matched files
|
|
239
|
+
5. Create new translation files for all locales containing only the used keys
|
|
240
|
+
|
|
241
|
+
This is particularly useful for:
|
|
242
|
+
|
|
243
|
+
- Creating namespace-specific translation bundles
|
|
244
|
+
- Reducing bundle size by including only necessary translations
|
|
245
|
+
- Optimizing performance in micro-frontends or modular applications
|
|
246
|
+
|
|
247
|
+
You can also automate this process using the `pruneNamespaces` configuration in your `i18n-magic.js` file (see configuration example above).
|
|
248
|
+
|
|
249
|
+
### `clean`
|
|
250
|
+
|
|
251
|
+
Remove unused translation keys from all locales. This command scans your codebase to find which translation keys are actually being used and removes any keys that are no longer referenced in your code.
|
|
252
|
+
|
|
253
|
+
The command will:
|
|
98
254
|
|
|
99
|
-
|
|
255
|
+
1. Scan all files matching your glob patterns for translation usage
|
|
256
|
+
2. Compare found keys with existing translation files
|
|
257
|
+
3. Remove unused keys from all locale files
|
|
258
|
+
4. Report how many keys were removed
|
|
100
259
|
|
|
101
|
-
|
|
260
|
+
This is useful for:
|
|
102
261
|
|
|
103
|
-
|
|
262
|
+
- Keeping translation files clean and maintainable
|
|
263
|
+
- Reducing bundle size by removing dead translations
|
|
264
|
+
- Regular maintenance in CI/CD pipelines
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
9
|
+
const openai_1 = __importDefault(require("openai"));
|
|
10
|
+
const check_missing_1 = require("./commands/check-missing");
|
|
11
|
+
const clean_1 = require("./commands/clean");
|
|
12
|
+
const create_pruned_namespace_1 = require("./commands/create-pruned-namespace");
|
|
13
|
+
const replace_1 = require("./commands/replace");
|
|
14
|
+
const scan_1 = require("./commands/scan");
|
|
15
|
+
const sync_locales_1 = require("./commands/sync-locales");
|
|
16
|
+
const utils_1 = require("./lib/utils");
|
|
17
|
+
const program = new commander_1.Command();
|
|
18
|
+
program
|
|
19
|
+
.name("i18n-magic")
|
|
20
|
+
.description("CLI to help you manage your locales JSON with translations, replacements, etc. with OpenAI.")
|
|
21
|
+
.version("0.2.0")
|
|
22
|
+
.option("-c, --config <path>", "path to config file")
|
|
23
|
+
.option("-e, --env <path>", "path to .env file");
|
|
24
|
+
const commands = [
|
|
25
|
+
{
|
|
26
|
+
name: "scan",
|
|
27
|
+
description: "Scan for missing translations, get prompted for each, translate it to the other locales and save it to the JSON file.",
|
|
28
|
+
action: scan_1.translateMissing,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "replace",
|
|
32
|
+
description: "Replace a translation based on the key, and translate it to the other locales and save it to the JSON file.",
|
|
33
|
+
action: replace_1.replaceTranslation,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "check-missing",
|
|
37
|
+
description: "Check if there are any missing translations. Useful for a CI/CD pipeline or husky hook.",
|
|
38
|
+
action: check_missing_1.checkMissing,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "sync",
|
|
42
|
+
description: "Sync the translations from the default locale to the other locales. Useful for a CI/CD pipeline or husky hook.",
|
|
43
|
+
action: sync_locales_1.syncLocales,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "clean",
|
|
47
|
+
description: "Remove unused translations from all locales. Useful for a CI/CD pipeline or husky hook.",
|
|
48
|
+
action: clean_1.removeUnusedKeys,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "prune",
|
|
52
|
+
description: "Create a pruned namespace from the other namespaces.",
|
|
53
|
+
action: create_pruned_namespace_1.createPrunedNamespace,
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
for (const command of commands) {
|
|
57
|
+
const cmd = program.command(command.name).description(command.description);
|
|
58
|
+
// Add key option to replace command
|
|
59
|
+
if (command.name === "replace") {
|
|
60
|
+
cmd
|
|
61
|
+
.option("-k, --key <key>", "translation key to replace")
|
|
62
|
+
.allowExcessArguments(true)
|
|
63
|
+
.argument("[key]", "translation key to replace");
|
|
64
|
+
}
|
|
65
|
+
cmd.action(async (arg, options) => {
|
|
66
|
+
const res = dotenv_1.default.config({
|
|
67
|
+
path: program.opts().env || ".env",
|
|
68
|
+
});
|
|
69
|
+
const config = await (0, utils_1.loadConfig)({
|
|
70
|
+
configPath: program.opts().config,
|
|
71
|
+
});
|
|
72
|
+
const isGemini = config.model?.includes("gemini");
|
|
73
|
+
// Get API key from environment or config
|
|
74
|
+
const openaiKey = res.parsed.OPENAI_API_KEY || config.OPENAI_API_KEY;
|
|
75
|
+
const geminiKey = res.parsed.GEMINI_API_KEY || config.GEMINI_API_KEY;
|
|
76
|
+
// Select appropriate key based on model type
|
|
77
|
+
const key = isGemini ? geminiKey : openaiKey;
|
|
78
|
+
if (!key) {
|
|
79
|
+
const keyType = isGemini ? "GEMINI_API_KEY" : "OPENAI_API_KEY";
|
|
80
|
+
console.error(`Please provide a${isGemini ? " Gemini" : "n OpenAI"} API key in your .env file or config, called ${keyType}.`);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
const openai = new openai_1.default({
|
|
84
|
+
apiKey: key,
|
|
85
|
+
...(isGemini && {
|
|
86
|
+
baseURL: "https://generativelanguage.googleapis.com/v1beta/openai/",
|
|
87
|
+
}),
|
|
88
|
+
});
|
|
89
|
+
// For replace command, check for key in argument or option
|
|
90
|
+
if (command.name === "replace") {
|
|
91
|
+
// If key is provided as positional argument, use that first
|
|
92
|
+
const keyToUse = typeof arg === "string" ? arg : options.key;
|
|
93
|
+
command.action({ ...config, openai }, keyToUse);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
command.action({ ...config, openai });
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
program.parse(process.argv);
|
|
101
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmC;AACnC,oDAA2B;AAC3B,oDAA2B;AAC3B,4DAAuD;AACvD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AC3D,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,4DAA4D;YAC5D,MAAM,QAAQ,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAA;YAC5D,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAA;QACjD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QACvC,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-missing.d.ts","sourceRoot":"","sources":["../../src/commands/check-missing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGjD,eAAO,MAAM,YAAY,GAAU,QAAQ,aAAa,kBAOvD,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkMissing = void 0;
|
|
4
|
+
const utils_1 = require("../lib/utils");
|
|
5
|
+
const checkMissing = async (config) => {
|
|
6
|
+
const newKeys = await (0, utils_1.getMissingKeys)(config);
|
|
7
|
+
if (newKeys.length > 0) {
|
|
8
|
+
console.error("Error: Missing translations found!");
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
exports.checkMissing = checkMissing;
|
|
13
|
+
//# sourceMappingURL=check-missing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-missing.js","sourceRoot":"","sources":["../../src/commands/check-missing.ts"],"names":[],"mappings":";;;AACA,wCAA6C;AAEtC,MAAM,YAAY,GAAG,KAAK,EAAE,MAAqB,EAAE,EAAE;IAC1D,MAAM,OAAO,GAAG,MAAM,IAAA,sBAAc,EAAC,MAAM,CAAC,CAAA;IAE5C,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAA;QACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC,CAAA;AAPY,QAAA,YAAY,gBAOxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAQjD,eAAO,MAAM,gBAAgB,GAAU,QAAQ,aAAa,kBA6F3D,CAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.removeUnusedKeys = void 0;
|
|
7
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
8
|
+
const i18next_scanner_1 = require("i18next-scanner");
|
|
9
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
10
|
+
const utils_1 = require("../lib/utils");
|
|
11
|
+
const removeUnusedKeys = async (config) => {
|
|
12
|
+
const { globPatterns, namespaces, defaultNamespace, locales, loadPath, savePath, } = config;
|
|
13
|
+
// Set up the parser
|
|
14
|
+
const parser = new i18next_scanner_1.Parser({
|
|
15
|
+
nsSeparator: false,
|
|
16
|
+
keySeparator: false,
|
|
17
|
+
});
|
|
18
|
+
// Find all files to scan
|
|
19
|
+
const files = await (0, fast_glob_1.default)([...globPatterns, "!**/node_modules/**"]);
|
|
20
|
+
// Extract all translation keys from the codebase
|
|
21
|
+
const extractedKeys = [];
|
|
22
|
+
for (const file of files) {
|
|
23
|
+
const content = node_fs_1.default.readFileSync(file, "utf-8");
|
|
24
|
+
parser.parseFuncFromString(content, { list: ["t"] }, (key) => {
|
|
25
|
+
extractedKeys.push(key);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
// Remove duplicates
|
|
29
|
+
const uniqueExtractedKeys = (0, utils_1.removeDuplicatesFromArray)(extractedKeys);
|
|
30
|
+
// Track stats for reporting
|
|
31
|
+
const stats = {
|
|
32
|
+
total: 0,
|
|
33
|
+
removed: 0,
|
|
34
|
+
};
|
|
35
|
+
// Process each namespace and locale
|
|
36
|
+
for (const namespace of namespaces) {
|
|
37
|
+
// Build a set of pure keys that are actually used in the codebase for this namespace
|
|
38
|
+
const usedKeysSet = new Set();
|
|
39
|
+
for (const key of uniqueExtractedKeys) {
|
|
40
|
+
const pureKey = (0, utils_1.getPureKey)(key, namespace, namespace === defaultNamespace);
|
|
41
|
+
if (pureKey) {
|
|
42
|
+
usedKeysSet.add(pureKey);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Process each locale
|
|
46
|
+
for (const locale of locales) {
|
|
47
|
+
// Load existing keys for this locale and namespace
|
|
48
|
+
const existingKeys = await (0, utils_1.loadLocalesFile)(loadPath, locale, namespace);
|
|
49
|
+
const existingKeysCount = Object.keys(existingKeys).length;
|
|
50
|
+
stats.total += existingKeysCount;
|
|
51
|
+
// Create a new object with only the keys that are used
|
|
52
|
+
const cleanedKeys = {};
|
|
53
|
+
let removedCount = 0;
|
|
54
|
+
for (const [key, value] of Object.entries(existingKeys)) {
|
|
55
|
+
if (usedKeysSet.has(key)) {
|
|
56
|
+
cleanedKeys[key] = value;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
removedCount++;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
stats.removed += removedCount;
|
|
63
|
+
// Only write the file if keys were removed
|
|
64
|
+
if (removedCount > 0) {
|
|
65
|
+
await (0, utils_1.writeLocalesFile)(savePath, locale, namespace, cleanedKeys);
|
|
66
|
+
console.log(`โ Removed ${removedCount} unused keys from ${locale}:${namespace} (${Object.keys(cleanedKeys).length} keys remaining)`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
console.log(`No unused keys found in ${locale}:${namespace}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (stats.removed > 0) {
|
|
74
|
+
console.log(`โ
Removed ${stats.removed} unused keys (out of ${stats.total} total keys)`);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
console.log(`โ
No unused keys found in the project (${stats.total} total keys)`);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
exports.removeUnusedKeys = removeUnusedKeys;
|
|
81
|
+
//# sourceMappingURL=clean.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean.js","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAC5B,qDAAwC;AACxC,sDAAwB;AAExB,wCAKqB;AAEd,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAqB,EAAE,EAAE;IAC9D,MAAM,EACJ,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,GAAG,MAAM,CAAA;IAEV,oBAAoB;IACpB,MAAM,MAAM,GAAG,IAAI,wBAAM,CAAC;QACxB,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAA;IAEF,yBAAyB;IACzB,MAAM,KAAK,GAAG,MAAM,IAAA,mBAAI,EAAC,CAAC,GAAG,YAAY,EAAE,qBAAqB,CAAC,CAAC,CAAA;IAElE,iDAAiD;IACjD,MAAM,aAAa,GAAG,EAAE,CAAA;IACxB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC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K,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;gBACxD,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBACzB,WAAW,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;gBAC1B,CAAC;qBAAM,CAAC;oBACN,YAAY,EAAE,CAAA;gBAChB,CAAC;YACH,CAAC;YAED,KAAK,CAAC,OAAO,IAAI,YAAY,CAAA;YAE7B,2CAA2C;YAC3C,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;gBACrB,MAAM,IAAA,wBAAgB,EAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;gBAChE,OAAO,CAAC,GAAG,CACT,aAAa,YAAY,qBAAqB,MAAM,IAAI,SAAS,KAC/D,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAC3B,kBAAkB,CACnB,CAAA;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,2BAA2B,MAAM,IAAI,SAAS,EAAE,CAAC,CAAA;YAC/D,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CACT,aAAa,KAAK,CAAC,OAAO,wBAAwB,KAAK,CAAC,KAAK,cAAc,CAC5E,CAAA;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CACT,0CAA0C,KAAK,CAAC,KAAK,cAAc,CACpE,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AA7FY,QAAA,gBAAgB,oBA6F5B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Configuration } from "../lib/types";
|
|
2
|
+
export interface PruneOptions {
|
|
3
|
+
sourceNamespace: string;
|
|
4
|
+
newNamespace: string;
|
|
5
|
+
globPatterns: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface PruneResult {
|
|
8
|
+
locale: string;
|
|
9
|
+
keyCount: number;
|
|
10
|
+
success: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PruneResponse {
|
|
14
|
+
success: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
keysCount: number;
|
|
17
|
+
results?: PruneResult[];
|
|
18
|
+
}
|
|
19
|
+
export declare const createPrunedNamespaceAutomated: (config: Configuration, options: PruneOptions) => Promise<PruneResponse>;
|
|
20
|
+
//# sourceMappingURL=create-pruned-namespace-automated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-pruned-namespace-automated.d.ts","sourceRoot":"","sources":["../../src/commands/create-pruned-namespace-automated.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAQjD,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,WAAW,EAAE,CAAA;CACxB;AAED,eAAO,MAAM,8BAA8B,GACzC,QAAQ,aAAa,EACrB,SAAS,YAAY,KACpB,OAAO,CAAC,aAAa,CAkIvB,CAAA"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createPrunedNamespaceAutomated = void 0;
|
|
7
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
8
|
+
const i18next_scanner_1 = require("i18next-scanner");
|
|
9
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
10
|
+
const utils_1 = require("../lib/utils");
|
|
11
|
+
const createPrunedNamespaceAutomated = async (config, options) => {
|
|
12
|
+
const { namespaces, loadPath, savePath, locales, defaultNamespace } = config;
|
|
13
|
+
const { sourceNamespace, newNamespace, globPatterns } = options;
|
|
14
|
+
// Validate inputs
|
|
15
|
+
if (!namespaces.includes(sourceNamespace)) {
|
|
16
|
+
throw new Error(`Source namespace '${sourceNamespace}' not found in configuration`);
|
|
17
|
+
}
|
|
18
|
+
if (namespaces.includes(newNamespace)) {
|
|
19
|
+
throw new Error(`Namespace '${newNamespace}' already exists`);
|
|
20
|
+
}
|
|
21
|
+
console.log(`Creating pruned namespace '${newNamespace}' from '${sourceNamespace}'`);
|
|
22
|
+
console.log(`Using glob patterns: ${globPatterns.join(", ")}`);
|
|
23
|
+
// Extract keys from files matching the glob patterns
|
|
24
|
+
const parser = new i18next_scanner_1.Parser({
|
|
25
|
+
nsSeparator: false,
|
|
26
|
+
keySeparator: false,
|
|
27
|
+
});
|
|
28
|
+
const files = await (0, fast_glob_1.default)([...globPatterns, "!**/node_modules/**"]);
|
|
29
|
+
console.log(`Found ${files.length} files to scan`);
|
|
30
|
+
const extractedKeys = [];
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
const content = node_fs_1.default.readFileSync(file, "utf-8");
|
|
33
|
+
parser.parseFuncFromString(content, { list: ["t"] }, (key) => {
|
|
34
|
+
extractedKeys.push(key);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const uniqueExtractedKeys = (0, utils_1.removeDuplicatesFromArray)(extractedKeys);
|
|
38
|
+
console.log(`Found ${uniqueExtractedKeys.length} unique translation keys`);
|
|
39
|
+
// Filter keys that belong to the source namespace
|
|
40
|
+
const relevantKeys = [];
|
|
41
|
+
for (const key of uniqueExtractedKeys) {
|
|
42
|
+
const pureKey = (0, utils_1.getPureKey)(key, sourceNamespace, sourceNamespace === defaultNamespace);
|
|
43
|
+
if (pureKey) {
|
|
44
|
+
relevantKeys.push(pureKey);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
console.log(`Found ${relevantKeys.length} keys from namespace '${sourceNamespace}'`);
|
|
48
|
+
if (relevantKeys.length === 0) {
|
|
49
|
+
console.log("No relevant keys found. Exiting...");
|
|
50
|
+
return {
|
|
51
|
+
success: false,
|
|
52
|
+
message: "No relevant keys found",
|
|
53
|
+
keysCount: 0,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// Get translations from source namespace and create new namespace files
|
|
57
|
+
const results = [];
|
|
58
|
+
for (const locale of locales) {
|
|
59
|
+
try {
|
|
60
|
+
// Load source namespace translations
|
|
61
|
+
const sourceTranslations = await (0, utils_1.loadLocalesFile)(loadPath, locale, sourceNamespace);
|
|
62
|
+
// Create new namespace with only the keys used in the glob pattern files
|
|
63
|
+
const newNamespaceTranslations = {};
|
|
64
|
+
for (const key of relevantKeys) {
|
|
65
|
+
if (sourceTranslations[key]) {
|
|
66
|
+
newNamespaceTranslations[key] = sourceTranslations[key];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Write the new namespace file
|
|
70
|
+
await (0, utils_1.writeLocalesFile)(savePath, locale, newNamespace, newNamespaceTranslations);
|
|
71
|
+
const keyCount = Object.keys(newNamespaceTranslations).length;
|
|
72
|
+
console.log(`Created pruned namespace '${newNamespace}' for locale '${locale}' with ${keyCount} keys`);
|
|
73
|
+
results.push({
|
|
74
|
+
locale,
|
|
75
|
+
keyCount,
|
|
76
|
+
success: true,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
console.error(`Error creating pruned namespace for locale '${locale}':`, error);
|
|
81
|
+
results.push({
|
|
82
|
+
locale,
|
|
83
|
+
keyCount: 0,
|
|
84
|
+
success: false,
|
|
85
|
+
error: error instanceof Error ? error.message : String(error),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
console.log(`โ
Successfully created pruned namespace '${newNamespace}'`);
|
|
90
|
+
return {
|
|
91
|
+
success: true,
|
|
92
|
+
message: `Created pruned namespace '${newNamespace}' with ${relevantKeys.length} keys`,
|
|
93
|
+
keysCount: relevantKeys.length,
|
|
94
|
+
results,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
exports.createPrunedNamespaceAutomated = createPrunedNamespaceAutomated;
|
|
98
|
+
//# sourceMappingURL=create-pruned-namespace-automated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-pruned-namespace-automated.js","sourceRoot":"","sources":["../../src/commands/create-pruned-namespace-automated.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAC5B,qDAAwC;AACxC,sDAAwB;AAExB,wCAKqB;AAsBd,MAAM,8BAA8B,GAAG,KAAK,EACjD,MAAqB,EACrB,OAAqB,EACG,EAAE;IAC1B,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAA;IAC5E,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,OAAO,CAAA;IAE/D,kBAAkB;IAClB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CACb,qBAAqB,eAAe,8BAA8B,CACnE,CAAA;IACH,CAAC;IAED,IAAI,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,cAAc,YAAY,kBAAkB,CAAC,CAAA;IAC/D,CAAC;IAED,OAAO,CAAC,GAAG,CACT,8BAA8B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IAAI,EACzD,KAAK,CACN,CAAA;YACD,OAAO,CAAC,IAAI,CAAC;gBACX,MAAM;gBACN,QAAQ,EAAE,CAAC;gBACX,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,4CAA4C,YAAY,GAAG,CAAC,CAAA;IAExE,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,6BAA6B,YAAY,UAAU,YAAY,CAAC,MAAM,OAAO;QACtF,SAAS,EAAE,YAAY,CAAC,MAAM;QAC9B,OAAO;KACR,CAAA;AACH,CAAC,CAAA;AArIY,QAAA,8BAA8B,kCAqI1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-pruned-namespace.d.ts","sourceRoot":"","sources":["../../src/commands/create-pruned-namespace.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAQjD,eAAO,MAAM,qBAAqB,GAAU,QAAQ,aAAa,kBAwJhE,CAAA"}
|