@scoutello/i18n-magic 0.53.0 → 0.54.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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **The intelligent CLI toolkit that automates your internationalization workflow with AI-powered translations.**
4
4
 
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.
5
+ Stop context switching. Let AI handle your translations while you stay in your code editor.
6
6
 
7
7
  ## 🚀 What it does
8
8
 
@@ -19,373 +19,343 @@ i18n Magic streamlines the entire translation management process for your JavaSc
19
19
  - Node.js 16+
20
20
  - An OpenAI or Google Gemini API key
21
21
 
22
- ## 🛠️ Quick Setup
22
+ ## Why This Matters
23
23
 
24
- ### 1. Install the package
24
+ **Traditional workflow**: 40+ minutes and 13 context switches to add 10 keys across 4 languages.
25
25
 
26
- ```bash
27
- npm install -g @scoutello/i18n-magic
28
- # or use directly with npx
29
- npx @scoutello/i18n-magic
30
- ```
26
+ **With i18n-magic + AI agents**: 2.5 minutes, zero context switches. Stay in flow.
31
27
 
32
- ### 2. Set up your API key
28
+ ---
33
29
 
34
- Create a `.env` file in your project root:
30
+ ## CLI Commands
35
31
 
36
32
  ```bash
37
- # Choose one:
38
- OPENAI_API_KEY=your_openai_api_key_here
39
- # OR
40
- GEMINI_API_KEY=your_gemini_api_key_here
33
+ npx @scoutello/i18n-magic scan # Find & add missing translations
34
+ npx @scoutello/i18n-magic sync # Translate to all languages
35
+ npx @scoutello/i18n-magic replace [key] # Update existing translation
36
+ npx @scoutello/i18n-magic clean # Remove unused keys
37
+ npx @scoutello/i18n-magic check-missing # CI/CD validation
41
38
  ```
42
39
 
43
- ### 3. Create your configuration
40
+ **`scan`** - Scans your codebase for missing keys, prompts you for values, auto-translates to all locales.
44
41
 
45
- Create an `i18n-magic.js` file in your project root with your project-specific settings:
42
+ **`sync`** - Takes your default locale translations and translates missing keys to other locales. Perfect for CI/CD.
46
43
 
47
- ```js
48
- module.exports = {
49
- globPatterns: [
50
- './components/**/*.tsx',
51
- './pages/**/*.tsx',
52
- './lib/**/*.ts',
53
- // Namespace-specific patterns for automatic namespace assignment
54
- {
55
- pattern: './apps/dashboard/**/*.tsx',
56
- namespaces: ['dashboard'],
57
- },
58
- {
59
- pattern: './apps/dashboard/**/*.ts',
60
- namespaces: ['dashboard'],
61
- },
62
- {
63
- pattern: './apps/mobile/**/*.tsx',
64
- namespaces: ['mobile'],
65
- },
66
- {
67
- pattern: './apps/mobile/**/*.ts',
68
- namespaces: ['mobile'],
69
- },
70
- ],
71
- loadPath: 'locales/{{lng}}/{{ns}}.json',
72
- savePath: 'locales/{{lng}}/{{ns}}.json',
73
- locales: ['en', 'de'],
74
- defaultLocale: 'de',
75
- defaultNamespace: 'common',
76
- namespaces: ['common', 'forms', 'dashboard', 'mobile'],
77
- context:
78
- 'This is a context which increases the quality of the translations by giving context to the LLM',
79
- // Optional configurations
80
- model: 'gemini-2.0-flash-lite', // or any OpenAI/Gemini model like 'gpt-4.1-mini'
81
- OPENAI_API_KEY: '.', // Alternative to using .env file
82
- GEMINI_API_KEY: '', // Alternative to using .env file
83
- disableTranslationDuringScan: 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.
84
- autoClear: true, // When using the scan command, always run the clean before
85
- };
44
+ **`replace`** - Update an existing translation key across all locales. Detects which namespaces use the key automatically.
45
+
46
+ **`clean`** - Removes unused translation keys from all locales. Great for keeping files lean.
47
+
48
+ **`check-missing`** - Dry-run check. Exits with error code if translations are missing. Perfect for CI pipelines.
49
+
50
+ ### Namespace Organization (for large apps)
51
+
52
+ ```javascript
53
+ // i18n-magic.js
54
+ globPatterns: [
55
+ './src/shared/**/*.tsx', // → common.json
56
+ { pattern: './src/dashboard/**/*.tsx', namespaces: ['dashboard'] },
57
+ { pattern: './src/mobile/**/*.tsx', namespaces: ['mobile'] }
58
+ ]
86
59
  ```
87
60
 
88
- #### Glob Patterns Configuration
61
+ Result: Separate files per feature (`common.json`, `dashboard.json`, `mobile.json`) across all locales.
89
62
 
90
- The `globPatterns` array supports two formats:
63
+ ---
91
64
 
92
- 1. **String patterns**: Simple glob patterns that apply to all namespaces
65
+ ## The MCP Server: AI Superpowers
93
66
 
94
- ```js
95
- './components/**/*.tsx';
96
- ```
67
+ **MCP (Model Context Protocol)** = API for AI agents.
97
68
 
98
- 2. **Object patterns**: Patterns with namespace-specific configuration for automatic namespace assignment
99
- ```js
100
- {
101
- pattern: './apps/dashboard/**/*.tsx',
102
- namespaces: ['dashboard']
103
- }
104
- ```
69
+ Install the i18n-magic MCP server in Cursor, and your AI gets 5 new tools:
105
70
 
106
- When using object patterns, translation keys found in files matching that pattern will be automatically saved to the specified namespaces. This enables automatic creation of namespace-specific translation files based on where the keys are used in your codebase.
71
+ ### 1. `search_translations` - Prevent Duplicates
72
+ Fuzzy search across all translations. AI searches before adding anything.
107
73
 
108
- ### 4. Start using i18n Magic
74
+ ### 2. `add_translation_key` - Add New Keys
75
+ Adds key to English (`en`) locale. Run `sync` afterward to translate to other languages.
109
76
 
110
- ```bash
111
- # Scan for missing translations and add them
112
- npx @scoutello/i18n-magic scan
77
+ ### 3. `get_translation_key` - Check What Exists
78
+ Retrieve current value for any key.
113
79
 
114
- # Check what's missing without making changes
115
- npx @scoutello/i18n-magic check-missing
80
+ ### 4. `update_translation_key` - Fix & Auto-Translate
81
+ Update a key and **instantly translate to all languages**. No sync needed!
116
82
 
117
- # Sync all locales from your default language
118
- npx @scoutello/i18n-magic sync
119
- ```
83
+ ### 5. `list_untranslated_keys` - Batch Check
84
+ Show all missing keys across your codebase.
120
85
 
121
- ## 🔧 Advanced Configuration
86
+ ---
122
87
 
123
- ### Custom Storage Solutions
88
+ ## Quick Setup (5 Minutes)
124
89
 
125
- You can provide custom functions for `loadPath` and `savePath` to store translations in other systems like S3, databases, or CDNs:
90
+ ### 1. Install
126
91
 
127
- ```js
128
- const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3")
92
+ ```bash
93
+ npm install @scoutello/i18n-magic
94
+ ```
129
95
 
130
- const s3Client = new S3Client({
131
- region: process.env.S3_REGION,
132
- credentials: {
133
- accessKeyId: process.env.S3_ACCESS_KEY,
134
- secretAccessKey: process.env.S3_SECRET_KEY,
135
- },
136
- })
96
+ ### 2. Create `i18n-magic.js` in project root
137
97
 
98
+ ```javascript
138
99
  module.exports = {
139
- ...
140
- // Custom load function
141
- loadPath: async (locale, namespace) => {
142
- // Example: Load from S3
143
- const response = await s3Client.send(
144
- new GetObjectCommand({
145
- Bucket: 'my-translations-bucket',
146
- Key: `locales/${locale}/${namespace}.json`,
147
- })
148
- );
149
- const data = await response.Body.transformToString();
150
- return JSON.parse(data);
151
- },
152
-
153
- // Custom save function
154
- savePath: async (locale, namespace, data) => {
155
- // Example: Save to S3
156
- await s3Client.send(
157
- new PutObjectCommand({
158
- Bucket: 'my-translations-bucket',
159
- Key: `locales/${locale}/${namespace}.json`,
160
- Body: JSON.stringify(data, null, 2),
161
- ContentType: 'application/json',
162
- })
163
- );
164
- },
165
- };
100
+ globPatterns: ['./src/**/*.{ts,tsx,js,jsx}'],
101
+ loadPath: 'locales/{{lng}}/{{ns}}.json',
102
+ savePath: 'locales/{{lng}}/{{ns}}.json',
103
+ locales: ['en', 'de', 'es', 'fr'],
104
+ defaultLocale: 'en',
105
+ namespaces: ['common'],
106
+ defaultNamespace: 'common',
107
+ context: 'Your app description here',
108
+ model: 'gpt-4o-mini', // or 'gemini-2.0-flash-lite'
109
+
110
+ // Optional: Auto-clean before scanning
111
+ autoClear: true,
112
+
113
+ // Optional: Skip translation during scan (translate later with sync)
114
+ disableTranslationDuringScan: false,
115
+ }
166
116
  ```
167
117
 
168
- ## 📚 Available Commands
118
+ **Key options**:
119
+ - `context`: Describe your app/domain. Better context = better translations.
120
+ - `autoClear`: Auto-remove unused keys before scanning.
121
+ - `disableTranslationDuringScan`: Set `true` to only add English during scan, then use `sync` command for translations.
169
122
 
170
- All commands can be run with:
123
+ ### 3. Add API key to `.env`
171
124
 
172
125
  ```bash
173
- npx @scoutello/i18n-magic [command]
126
+ OPENAI_API_KEY=sk-your-key-here
174
127
  ```
175
128
 
176
- ### `scan`
129
+ ### 4. Configure MCP in Cursor
130
+
131
+ Settings → Features → Model Context Protocol:
177
132
 
178
- 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.
133
+ ```json
134
+ {
135
+ "i18n-magic": {
136
+ "command": "node",
137
+ "args": ["./node_modules/@scoutello/i18n-magic/dist/mcp-server.js"]
138
+ }
139
+ }
140
+ ```
179
141
 
180
- The command will:
142
+ ### 5. Restart Cursor
181
143
 
182
- 1. Scan all files matching your glob patterns for translation usage
183
- 2. Automatically determine which namespaces each key belongs to based on the file location
184
- 3. Identify missing translation keys in your default locale
185
- 4. Prompt you to provide translations for each missing key
186
- 5. Automatically translate to all other configured locales using AI
187
- 6. Save the new translations to the appropriate namespace files
144
+ Done! Test by asking: *"Search for translations with 'password'"*
188
145
 
189
- This is useful for:
146
+ ---
190
147
 
191
- - Adding new translations during development
192
- - Ensuring all translation keys have corresponding values
193
- - Maintaining translation consistency across locales
194
- - Automatically organizing translations into the correct namespaces
148
+ ## How to Use It
195
149
 
196
- ### `replace`
150
+ ### Pattern 1: Adding Translations (Search First!)
197
151
 
198
- 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.
152
+ **You**: "Add a submit button"
199
153
 
200
- The command will:
154
+ **AI**:
155
+ 1. Searches existing translations for "submit"
156
+ 2. Finds `submitButton: "Submit"` already exists
157
+ 3. Suggests reusing it
158
+ 4. Generates: `<Button>{t('submitButton')}</Button>`
201
159
 
202
- 1. Automatically detect which namespaces the key is used in based on your codebase
203
- 2. Prompt you to select or specify the translation key to replace
204
- 3. Ask for the new translation value in your default locale
205
- 4. Automatically translate the new value to all other configured locales using AI
206
- 5. Update all relevant namespace files with the new values
160
+ **Result**: No duplicate keys, instant code.
207
161
 
208
- You can specify the key in two ways:
162
+ If nothing exists:
163
+ - AI adds key to English: `add_translation_key`
164
+ - You run: `npx @scoutello/i18n-magic sync`
165
+ - Translated to all languages!
209
166
 
210
- - As a positional argument: `npx @scoutello/i18n-magic replace your.translation.key`
211
- - Using the option flag: `npx @scoutello/i18n-magic replace --key your.translation.key`
167
+ ### Pattern 2: Updating Translations
212
168
 
213
- If no key is provided, you will be prompted to enter one.
169
+ **You**: "Change welcome message to 'Welcome back!'"
214
170
 
215
- This is useful for:
171
+ **AI**:
172
+ 1. Finds the key via search
173
+ 2. Calls `update_translation_key`
174
+ 3. **Auto-translates to ALL languages instantly**
216
175
 
217
- - Updating existing translations that need changes
218
- - Fixing translation errors across all locales
219
- - Maintaining consistency when modifying content
220
- - Automatically updating translations in all relevant namespaces
176
+ No sync needed!
221
177
 
222
- ### `check-missing`
178
+ ### Pattern 3: Batch Check
223
179
 
224
- 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.
180
+ **You**: "What translations are missing?"
225
181
 
226
- The command will:
182
+ **AI**: Calls `list_untranslated_keys`, shows you the list.
227
183
 
228
- 1. Scan all files matching your glob patterns for translation usage
229
- 2. Check if all found translation keys exist in your translation files
230
- 3. Report any missing translations without prompting for input
231
- 4. Exit with an error code if missing translations are found
184
+ Add them now or during development. Your choice.
232
185
 
233
- This is useful for:
186
+ ---
234
187
 
235
- - CI/CD pipelines to ensure translation completeness
236
- - Pre-commit hooks to catch missing translations early
237
- - Quality assurance checks before deployment
238
- - Automated testing of translation coverage
188
+ ## Real Example
239
189
 
240
- ### `sync`
190
+ Building a UserProfile component:
241
191
 
242
- 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.
192
+ **You**: "Replace 'User Profile' with translation"
243
193
 
244
- The command will:
194
+ **AI**:
195
+ - Searches for "user profile"
196
+ - Nothing found
197
+ - Adds: `profile.title: "User Profile"` to en/dashboard.json
198
+ - Updates code: `<h1>{t('profile.title')}</h1>`
245
199
 
246
- 1. Load all translation keys from your default locale
247
- 2. Identify keys that are missing in other locales
248
- 3. Automatically translate missing keys using AI
249
- 4. Update translation files for all non-default locales
250
- 5. Preserve existing translations (only adds missing ones)
200
+ **You**: "Add translations for labels"
251
201
 
252
- This is useful for:
202
+ **AI**:
203
+ - Searches "email" → finds `emailLabel` in common
204
+ - Reuses existing key (no duplicate!)
205
+ - Searches "full name" → nothing found
206
+ - Adds new: `profile.fullNameLabel: "Full Name"`
253
207
 
254
- - CI/CD pipelines to ensure all locales are up-to-date
255
- - Batch translation of new content
256
- - Maintaining translation parity across languages
257
- - Automated deployment workflows
208
+ **You run**:
209
+ ```bash
210
+ npx @scoutello/i18n-magic sync
211
+ ```
258
212
 
259
- **Note**: This command works best when used with `disableTranslationDuringScan: true` in your config to separate the scanning and translation phases. The sync command will always translate regardless of this setting.
213
+ **Result**: All keys now in EN, DE, ES, FR. Took 2 minutes.
260
214
 
261
- ### `clean`
215
+ Later: **"Change title to 'Your Profile'"**
262
216
 
263
- 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.
217
+ **AI**: Calls `update_translation_key` instantly updated in all 4 languages. No sync needed!
264
218
 
265
- The command will:
219
+ ---
266
220
 
267
- 1. Scan all files matching your glob patterns for translation usage
268
- 2. Compare found keys with existing translation files
269
- 3. Remove unused keys from all locale files
270
- 4. Report how many keys were removed
221
+ ## Pro Tips
271
222
 
272
- This is useful for:
223
+ ### Better Translations with Context
273
224
 
274
- - Keeping translation files clean and maintainable
275
- - Reducing bundle size by removing dead translations
276
- - Regular maintenance in CI/CD pipelines
225
+ ```javascript
226
+ // Generic Okay
227
+ context: 'Web application'
277
228
 
278
- ## 🔌 MCP Server Integration
229
+ // Specific Much better!
230
+ context: 'E-commerce for outdoor gear. Friendly tone. Target: adventurers.'
231
+ ```
279
232
 
280
- i18n Magic includes an MCP (Model Context Protocol) server that allows LLMs like Cursor to add missing translation keys directly to your translation files. This enables a seamless workflow where your AI assistant can identify and add missing translations while you code.
233
+ More context = better AI translations.
281
234
 
282
- ### Setting up the MCP Server
235
+ ### CI/CD: Auto-translate on PR
283
236
 
284
- 1. **Install i18n-magic** (if not already installed):
237
+ ```yaml
238
+ # .github/workflows/auto-translate.yml
239
+ on:
240
+ pull_request:
241
+ paths: ['locales/en/**/*.json']
285
242
 
286
- ```bash
287
- npm install -g @scoutello/i18n-magic
288
- # or locally in your project
289
- npm install @scoutello/i18n-magic
243
+ jobs:
244
+ translate:
245
+ steps:
246
+ - run: npx @scoutello/i18n-magic sync
247
+ - run: git commit -am "chore: auto-translate"
290
248
  ```
291
249
 
292
- 2. **Configure Cursor** (or other MCP-compatible tools):
250
+ English changes auto-translated committed. Zero manual work.
293
251
 
294
- Open Cursor settings and add this to your MCP configuration:
252
+ ### Namespace Strategy
295
253
 
296
- **For global installation:**
297
- ```json
298
- {
299
- "i18n-magic": {
300
- "command": "i18n-magic-mcp",
301
- "cwd": "/absolute/path/to/your/project"
254
+ - **<100 keys**: Single `common.json`
255
+ - **100-500 keys**: Split by feature (`auth`, `dashboard`)
256
+ - **500+ keys**: Feature-based with auto-assignment (see setup section)
257
+
258
+ ### Custom Storage Solutions
259
+
260
+ Store translations anywhere (S3, databases, CDNs):
261
+
262
+ ```javascript
263
+ // Example: S3 storage
264
+ const { S3Client, GetObjectCommand, PutObjectCommand } = require('@aws-sdk/client-s3')
265
+
266
+ const s3Client = new S3Client({
267
+ region: process.env.S3_REGION,
268
+ credentials: {
269
+ accessKeyId: process.env.S3_ACCESS_KEY,
270
+ secretAccessKey: process.env.S3_SECRET_KEY,
302
271
  }
272
+ })
273
+
274
+ module.exports = {
275
+ loadPath: async (locale, namespace) => {
276
+ const response = await s3Client.send(
277
+ new GetObjectCommand({
278
+ Bucket: 'my-translations-bucket',
279
+ Key: `locales/${locale}/${namespace}.json`,
280
+ })
281
+ )
282
+ const data = await response.Body.transformToString()
283
+ return JSON.parse(data)
284
+ },
285
+
286
+ savePath: async (locale, namespace, data) => {
287
+ await s3Client.send(
288
+ new PutObjectCommand({
289
+ Bucket: 'my-translations-bucket',
290
+ Key: `locales/${locale}/${namespace}.json`,
291
+ Body: JSON.stringify(data, null, 2),
292
+ ContentType: 'application/json',
293
+ })
294
+ )
295
+ },
296
+ // ... other config
303
297
  }
304
298
  ```
305
299
 
306
- **For local installation:**
300
+ ---
301
+
302
+ ## Troubleshooting
303
+
304
+ ### MCP Connection Error
305
+
306
+ **Error**: `MCP error -32000: Connection closed`
307
+
308
+ **Fix**: Use auto-detection (no `cwd` needed):
307
309
  ```json
308
310
  {
309
311
  "i18n-magic": {
310
312
  "command": "node",
311
- "args": ["./node_modules/@scoutello/i18n-magic/dist/mcp-server.js"],
312
- "cwd": "/absolute/path/to/your/project"
313
+ "args": ["./node_modules/@scoutello/i18n-magic/dist/mcp-server.js"]
313
314
  }
314
315
  }
315
316
  ```
316
317
 
317
- **⚠️ CRITICAL Configuration**:
318
- - Replace `/absolute/path/to/your/project` with **YOUR PROJECT DIRECTORY** containing `i18n-magic.js`
319
- - **DO NOT** use the i18n-magic package directory - use where YOU use translations
320
- - The `cwd` parameter must be an absolute path
321
- - If you get "Connection closed" error, verify your `cwd` points to the correct directory
322
-
323
- ### Troubleshooting MCP Setup
324
-
325
- **Error: "MCP error -32000: Connection closed"**
326
-
327
- This means the server couldn't find your configuration. Check:
328
-
329
- 1. ✅ `cwd` points to YOUR project directory (not the i18n-magic package)
330
- 2. ✅ `i18n-magic.js` exists in that directory
331
- 3. ✅ Paths are absolute
332
-
333
- Test your setup:
318
+ **Still broken?** Check `i18n-magic.js` exists in project root:
334
319
  ```bash
335
- # Navigate to your project
336
- cd /your/project/path
337
-
338
- # Verify config exists
339
320
  ls -la i18n-magic.js
340
-
341
- # Test the MCP server manually
342
- node ./node_modules/@scoutello/i18n-magic/dist/mcp-server.js
343
321
  ```
344
322
 
345
- You should see: `[i18n-magic MCP] Server started and ready to accept connections`
323
+ ### Translations Not Working
346
324
 
347
- ### How it works
325
+ **Problem**: Keys added but not translated.
326
+
327
+ **Fix**: Run sync!
328
+ ```bash
329
+ npx @scoutello/i18n-magic sync
330
+ ```
348
331
 
349
- **Workflow 1: Adding individual keys**
350
- 1. While coding, the LLM identifies a missing translation key
351
- 2. The LLM calls the `add_translation_key` tool to add it with an English value
352
- 3. The key is automatically added to the `en` locale (regardless of your `defaultLocale`)
353
- 4. Run `i18n-magic sync` to translate the key to all other configured locales
332
+ `add_translation_key` only adds English. `sync` translates to other languages.
354
333
 
355
- **Workflow 2: Batch checking missing keys**
356
- 1. The LLM calls `list_untranslated_keys` to get a complete overview
357
- 2. Review all missing keys grouped by namespace
358
- 3. Add keys using `add_translation_key` or run `i18n-magic scan` for batch processing
359
- 4. Run `i18n-magic sync` to translate all new keys
334
+ ### MCP Tools Not Appearing
360
335
 
361
- ### Available MCP Tools
336
+ 1. Restart Cursor after adding MCP config
337
+ 2. Check Settings → Features → MCP shows "i18n-magic" as Connected
338
+ 3. Test: Ask AI to *"search translations for 'password'"*
362
339
 
363
- **add_translation_key**: Add a new translation key with an English value
340
+ ---
364
341
 
365
- Parameters:
366
- - `key` (required): The translation key (e.g., "welcomeMessage")
367
- - `value` (required): The English text value
368
- - `namespace` (optional): Target namespace (defaults to your defaultNamespace)
342
+ ## Get Started Now
369
343
 
370
- Example:
371
- ```json
372
- {
373
- "key": "user.profileUpdated",
374
- "value": "Your profile has been updated successfully",
375
- "namespace": "common"
376
- }
377
- ```
344
+ 1. `npm install @scoutello/i18n-magic`
345
+ 2. Create `i18n-magic.js` config (see setup section)
346
+ 3. Add `OPENAI_API_KEY` to `.env`
347
+ 4. Configure MCP in Cursor
348
+ 5. Start coding. AI handles translations.
378
349
 
379
- **list_untranslated_keys**: List all translation keys used in the codebase that are not yet defined
350
+ **5 minutes to set up. Hours saved every week.**
380
351
 
381
- Parameters:
382
- - `namespace` (optional): Check a specific namespace only (defaults to all namespaces)
352
+ ### Links
383
353
 
384
- Example:
385
- ```json
386
- {}
387
- ```
354
+ - **MCP Details**: [MCP-SERVER.md](./MCP-SERVER.md)
355
+ - **Example App**: [example-app/](./example-app/)
356
+ - **GitHub**: [github.com/BjoernRave/i18n-magic](https://github.com/BjoernRave/i18n-magic)
357
+ - **NPM**: [@scoutello/i18n-magic](https://www.npmjs.com/package/@scoutello/i18n-magic)
388
358
 
389
- Response shows all missing keys grouped by namespace with counts and next steps.
359
+ ---
390
360
 
391
- For detailed setup instructions and troubleshooting, see [MCP-SERVER.md](./MCP-SERVER.md).
361
+ *Never context switch for translations again. 🌍*
@@ -59,13 +59,14 @@ export declare class TranslationError extends Error {
59
59
  constructor(message: string, locale?: string, namespace?: string, cause?: Error);
60
60
  }
61
61
  /**
62
- * Add a translation key with an English value to the locale files.
63
- * This function always adds to the "en" locale, and if the defaultLocale is different,
64
- * it will also translate and save to the defaultLocale right away.
62
+ * Add a translation key with a value in a specific language to the locale files.
63
+ * This function adds to the specified language locale, and will also translate
64
+ * and save to other locales if OpenAI is configured.
65
65
  */
66
- export declare const addTranslationKey: ({ key, value, config, }: {
66
+ export declare const addTranslationKey: ({ key, value, language, config, }: {
67
67
  key: string;
68
68
  value: string;
69
+ language?: string;
69
70
  config: Configuration;
70
71
  }) => Promise<{
71
72
  key: string;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAGhC,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAElE,eAAO,MAAM,UAAU,GAAU,kBAE9B;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,iBAkB9B,CAAA;AAED,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAE1D;AA0BD,eAAO,MAAM,YAAY,GAAU,oEAOhC;IACD,M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