locai 2.1.0 → 2.1.2
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/LICENSE +21 -0
- package/README.md +38 -898
- package/dist/core/orchestrator.js +0 -1
- package/dist/services/translation-service.js +1 -1
- package/package.json +11 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ahmet Enes Dur
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,928 +1,68 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Locai
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**The Universal AI Localization Engine.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Locai brings human-quality AI localization to **any project** (Next.js, Flutter, Android, iOS, Python) and **any file format** with a single command. It fits right into your workflow, whether you're a solo dev or an enterprise team.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## 🚀 Quick Start
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- **ZERO Config:** Automatically detects your project type (Next.js, Vue, Flutter) and file structure.
|
|
12
|
-
- **Universal Support:** Works with standard web frameworks, mobile apps (Flutter, React Native), and backend systems (Django, Spring).
|
|
13
|
-
|
|
14
|
-
**Multi-Format Support**
|
|
15
|
-
|
|
16
|
-
- **JSON (.json)**: Default for web apps (i18next, react-intl).
|
|
17
|
-
- **YAML (.yaml/.yml)**: Concise config-style locales (Rails, refined DX).
|
|
18
|
-
- **Gettext (.po/.pot)**: Industry standard for PHP/WordPress/Python.
|
|
19
|
-
- **Properties (.properties)**: Java/Spring Boot and legacy systems.
|
|
20
|
-
- **ARB (.arb)**: Flutter application resource bundles.
|
|
21
|
-
|
|
22
|
-
**AI-Powered Translation**
|
|
23
|
-
|
|
24
|
-
- Support for 5 AI providers: OpenAI (GPT-4o), Gemini, DeepSeek, Dashscope, XAI
|
|
25
|
-
- **Context-Aware:** Detects if content is technical, marketing, legal, or UI and adjusts tone.
|
|
26
|
-
- **Smart Sync:** Only translates changed or new keys (SHA-256 change detection).
|
|
27
|
-
- **Vector Memory:** "Infinite Memory" reuses previous translations for 100% consistency and cost savings.
|
|
28
|
-
|
|
29
|
-
**Quality & Performance**
|
|
30
|
-
|
|
31
|
-
- **Robust Validation:** Checks placeholders (`{name}`), HTML tags, and quote balancing.
|
|
32
|
-
- **Style Guard:** Enforces tone (formal/informal) and conventions (Oxford comma).
|
|
33
|
-
- **Parallel Processing:** Fast execution with configurable concurrency and rate limiting.
|
|
34
|
-
- **Interactive Review:** TUI for reviewing low-confidence translations before saving.
|
|
35
|
-
- Automated validation and fixing of placeholders, HTML tags, and length
|
|
36
|
-
- Quality confidence scoring with interactive review workflow
|
|
37
|
-
- **Style Guard:** Tone verification and style guide enforcement (Oxford comma, sentence case)
|
|
38
|
-
- "Infinite Memory" (Vector Cache) for semantic recycling of translations
|
|
39
|
-
- Glossary management for consistent brand terminology
|
|
40
|
-
|
|
41
|
-
**Developer Experience**
|
|
42
|
-
|
|
43
|
-
- Real-time progress tracking with ETA
|
|
44
|
-
- Comprehensive configuration validation
|
|
45
|
-
- Debug mode with performance diagnostics
|
|
46
|
-
- Graceful shutdown with state preservation
|
|
47
|
-
- Interactive terminal UI for translation review
|
|
48
|
-
|
|
49
|
-
## Quick Start
|
|
50
|
-
|
|
51
|
-
### Installation
|
|
9
|
+
Translate your project in seconds without installing anything:
|
|
52
10
|
|
|
53
11
|
```bash
|
|
54
|
-
#
|
|
12
|
+
# Translates your ./locales from English to Turkish, Spanish, and German
|
|
55
13
|
npx locai translate --source en --targets tr,es,de
|
|
56
|
-
|
|
57
|
-
# Or install globally
|
|
58
|
-
npm install -g locai
|
|
59
|
-
locai translate
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### Prerequisites
|
|
63
|
-
|
|
64
|
-
- **Node.js** >= 14.13.0 (v18+ recommended for ESM)
|
|
65
|
-
- At least one AI provider API key
|
|
66
|
-
|
|
67
|
-
## Configuration
|
|
68
|
-
|
|
69
|
-
The tool uses `c12` for configuration loading, supporting `.js`, `.ts`, and `.json` files.
|
|
70
|
-
|
|
71
|
-
### 1. Zero-Install Usage (Recommended for `npx`)
|
|
72
|
-
|
|
73
|
-
If you are running the tool via `npx` and don't want to install it as a dependency, use a standard `localize.config.js` file.
|
|
74
|
-
|
|
75
|
-
```javascript
|
|
76
|
-
// localize.config.js
|
|
77
|
-
export default {
|
|
78
|
-
source: "en",
|
|
79
|
-
targets: ["tr", "es", "de"],
|
|
80
|
-
apiProvider: "openai",
|
|
81
|
-
localesDir: "./locales",
|
|
82
|
-
|
|
83
|
-
// Optional: API specific settings
|
|
84
|
-
apiConfig: {
|
|
85
|
-
openai: {
|
|
86
|
-
model: "gpt-4",
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### 2. TypeScript Usage (Enhanced)
|
|
93
|
-
|
|
94
|
-
If you have installed the package (`pnpm add -D locai`), you can use the `defineConfig` helper for full type safety.
|
|
95
|
-
|
|
96
|
-
```typescript
|
|
97
|
-
// localize.config.ts
|
|
98
|
-
import { defineConfig } from "locai";
|
|
99
|
-
|
|
100
|
-
export default defineConfig({
|
|
101
|
-
source: "en",
|
|
102
|
-
targets: ["tr", "es", "de"],
|
|
103
|
-
apiProvider: "openai",
|
|
104
|
-
|
|
105
|
-
// Optional: Override auto-detection
|
|
106
|
-
localesDir: "./src/locales",
|
|
107
|
-
fileOperations: {
|
|
108
|
-
format: "yaml", // 'json', 'yaml', 'po', 'properties', 'arb', 'auto'
|
|
109
|
-
fileStructure: "flat", // 'flat' (en.json) or 'nested' (en/common.json)
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### 3. Setup API Keys
|
|
115
|
-
|
|
116
|
-
Create a `.env` file with your provider credentials:
|
|
117
|
-
|
|
118
|
-
```env
|
|
119
|
-
OPENAI_API_KEY=sk-...
|
|
120
|
-
GEMINI_API_KEY=AIza...
|
|
121
|
-
DEEPSEEK_API_KEY=sk-...
|
|
122
|
-
DASHSCOPE_API_KEY=sk-...
|
|
123
|
-
XAI_API_KEY=xai-...
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
**Note:** You only need one provider to get started. The tool will use the available providers.
|
|
127
|
-
|
|
128
|
-
## Usage
|
|
129
|
-
|
|
130
|
-
### Basic Commands
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
# Validate configuration
|
|
134
|
-
locai validate-config
|
|
135
|
-
|
|
136
|
-
# Translate with config settings
|
|
137
|
-
locai
|
|
138
|
-
|
|
139
|
-
# Override target languages
|
|
140
|
-
locai -t tr,es,de
|
|
141
|
-
|
|
142
|
-
# Force update existing translations
|
|
143
|
-
locai translate --force
|
|
144
|
-
|
|
145
|
-
# Fix translation issues
|
|
146
|
-
locai fix
|
|
147
|
-
|
|
148
|
-
# Enable confidence scoring (0-1 scale)
|
|
149
|
-
locai translate --min-confidence 0.8 --save-review-queue
|
|
150
|
-
|
|
151
|
-
# Interactive review of low-confidence translations
|
|
152
|
-
locai review
|
|
153
|
-
|
|
154
|
-
# Export review queue
|
|
155
|
-
locai review --export json
|
|
156
|
-
locai review --export csv
|
|
157
|
-
|
|
158
|
-
# Debug mode
|
|
159
|
-
locai --debug
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### Smart Synchronization
|
|
163
|
-
|
|
164
|
-
The tool uses SHA-256 hashing to detect changes:
|
|
165
|
-
|
|
166
|
-
**First run:**
|
|
167
|
-
|
|
168
|
-
```bash
|
|
169
|
-
locai
|
|
170
|
-
# First run - will process all keys
|
|
171
|
-
# Translates all 500 keys across 13 languages
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
**Subsequent runs:**
|
|
175
|
-
|
|
176
|
-
```bash
|
|
177
|
-
locai
|
|
178
|
-
# Sync Analysis:
|
|
179
|
-
# New keys: 3
|
|
180
|
-
# Modified keys: 1
|
|
181
|
-
# Deleted keys: 2
|
|
182
|
-
# Only processes 4 keys instead of 500
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
**Smart Behavior:**
|
|
186
|
-
|
|
187
|
-
- **New keys** - Translated automatically
|
|
188
|
-
- **Modified keys** - Re-translated with context
|
|
189
|
-
- **Deleted keys** - Removed from all target files
|
|
190
|
-
- **Unchanged keys** - Skipped for performance
|
|
191
|
-
|
|
192
|
-
### Config Validation
|
|
193
|
-
|
|
194
|
-
Validate your configuration before running translations:
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
# Quick validation
|
|
198
|
-
locai validate-config
|
|
199
|
-
|
|
200
|
-
# Show warnings too
|
|
201
|
-
locai validate-config --show-warnings
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
**Example Output:**
|
|
205
|
-
|
|
206
|
-
```
|
|
207
|
-
Validating configuration...
|
|
208
|
-
|
|
209
|
-
Configuration is valid!
|
|
210
|
-
|
|
211
|
-
Configuration Summary:
|
|
212
|
-
Source: en
|
|
213
|
-
Targets: 13 languages (tr, de, es, fr, hi...)
|
|
214
|
-
API Provider: openai
|
|
215
|
-
Concurrency: 1 parallel operations
|
|
216
|
-
Cache: Enabled
|
|
217
|
-
Context Detection: AI-powered
|
|
218
|
-
Fallback Chain: openai → dashscope → deepseek
|
|
219
|
-
|
|
220
|
-
Your configuration is ready to use.
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
**Validation covers 60+ settings:**
|
|
224
|
-
|
|
225
|
-
- Required fields (source, targets, localesDir)
|
|
226
|
-
- API provider names and configurations
|
|
227
|
-
- Performance settings (concurrency, cache, rate limits)
|
|
228
|
-
- Retry options and timeouts
|
|
229
|
-
- Context detection settings
|
|
230
|
-
- Quality check rules
|
|
231
|
-
- Length control modes
|
|
232
|
-
- Logical consistency (e.g., initialDelay < maxDelay)
|
|
233
|
-
|
|
234
|
-
### Enhanced Error Messages
|
|
235
|
-
|
|
236
|
-
Context-aware errors with actionable solutions and error codes (API 1xxx, Config 2xxx, File 3xxx, Validation 4xxx, Translation 5xxx). Use `--debug` for detailed diagnostics.
|
|
237
|
-
|
|
238
|
-
### Command Reference
|
|
239
|
-
|
|
240
|
-
<details>
|
|
241
|
-
<summary>All Options</summary>
|
|
242
|
-
|
|
243
|
-
#### Global Options
|
|
244
|
-
|
|
245
|
-
| Option | Description | Default |
|
|
246
|
-
| --------------- | -------------------- | ------------------- |
|
|
247
|
-
| `-s, --source` | Source language | `config.source` |
|
|
248
|
-
| `-t, --targets` | Target languages | `config.targets` |
|
|
249
|
-
| `--localesDir` | Locales directory | `config.localesDir` |
|
|
250
|
-
| `--debug` | Enable debug mode | `false` |
|
|
251
|
-
| `--verbose` | Detailed diagnostics | `false` |
|
|
252
|
-
|
|
253
|
-
#### Commands
|
|
254
|
-
|
|
255
|
-
| Command | Description |
|
|
256
|
-
| ----------------- | ------------------------------------------ |
|
|
257
|
-
| `translate` | Translate missing strings |
|
|
258
|
-
| `fix` | Fix issues in existing translations |
|
|
259
|
-
| `review` | Interactive review of low-confidence items |
|
|
260
|
-
| `analyze` | Analyze context patterns |
|
|
261
|
-
| `validate-config` | Validate configuration file |
|
|
262
|
-
| `advanced` | Advanced configuration options |
|
|
263
|
-
|
|
264
|
-
#### Translation Options
|
|
265
|
-
|
|
266
|
-
| Option | Description | Default |
|
|
267
|
-
| --------------------- | -------------------------------- | -------- |
|
|
268
|
-
| `--provider` | AI provider | `openai` |
|
|
269
|
-
| `--concurrency` | Concurrent translations | `1` |
|
|
270
|
-
| `--force` | Update existing | `false` |
|
|
271
|
-
| `--length` | Length control mode | `smart` |
|
|
272
|
-
| `--stats` | Show detailed stats | `false` |
|
|
273
|
-
| `--min-confidence` | Minimum confidence threshold 0-1 | `0.0` |
|
|
274
|
-
| `--save-review-queue` | Save low-confidence items | `false` |
|
|
275
|
-
|
|
276
|
-
#### Review Options
|
|
277
|
-
|
|
278
|
-
| Option | Description | Values |
|
|
279
|
-
| ---------- | ---------------------------------- | ----------- |
|
|
280
|
-
| `--export` | Export review queue to file format | `json, csv` |
|
|
281
|
-
|
|
282
|
-
</details>
|
|
283
|
-
|
|
284
|
-
## Providers & Performance
|
|
285
|
-
|
|
286
|
-
| Provider | Model | RPM | Concurrency | Context Window |
|
|
287
|
-
| ------------- | -------------------- | ---- | ----------- | -------------- |
|
|
288
|
-
| **OpenAI** | gpt-4o | 1000 | 15 | 16K tokens |
|
|
289
|
-
| **Gemini** | gemini-2.0-flash-exp | 500 | 12 | 16K tokens |
|
|
290
|
-
| **XAI** | grok-4 | 300 | 10 | 8K tokens |
|
|
291
|
-
| **Dashscope** | qwen-plus | 200 | 8 | 8K tokens |
|
|
292
|
-
| **DeepSeek** | deepseek-chat | 200 | 8 | 8K tokens |
|
|
293
|
-
|
|
294
|
-
### Quality Assurance
|
|
295
|
-
|
|
296
|
-
| Feature | Description |
|
|
297
|
-
| -------------------------- | ----------------------------------------------------------------- |
|
|
298
|
-
| **Placeholder Validation** | Preserves `{variable}` patterns exactly |
|
|
299
|
-
| **HTML Preservation** | Maintains `<tag>` structure and attributes |
|
|
300
|
-
| **Quote Balance Check** | Detects and auto-fixes unbalanced quotes to prevent JSON errors |
|
|
301
|
-
| **Length Control** | 5 modes with language-specific rules |
|
|
302
|
-
| **Context Detection** | AI-powered categorization (technical, marketing, legal, DeFi, UI) |
|
|
303
|
-
| **Confidence Scoring** | Multi-factor quality scoring (0-1 scale) with review queue |
|
|
304
|
-
| **Tone Verification** | AI auditing of translation tone (e.g., ensuring "professional") |
|
|
305
|
-
| **Style Enforcement** | Checks for conventions like Oxford comma and sentence case |
|
|
306
|
-
| **Glossary Management** | Consistent brand terminology across all translations |
|
|
307
|
-
|
|
308
|
-
### Glossary/Terminology Management
|
|
309
|
-
|
|
310
|
-
Ensure consistent brand terminology and technical terms across all your translations.
|
|
311
|
-
|
|
312
|
-
#### Key Features
|
|
313
|
-
|
|
314
|
-
- **Brand Consistency**: Keep product names, features, and brand terms consistent
|
|
315
|
-
- **Technical Terms**: Preserve technical acronyms like API, SDK, OAuth unchanged
|
|
316
|
-
- **Language-Specific**: Define different translations per target language
|
|
317
|
-
- **Case Sensitivity**: Control exact case matching for specific terms
|
|
318
|
-
- **Format Preservation**: Maintain capitalization from source text
|
|
319
|
-
|
|
320
|
-
### Quote Balance Validation
|
|
321
|
-
|
|
322
|
-
Automatically detects and fixes unbalanced quotation marks to prevent JSON parse errors. Supports single quotes (`'`), double quotes (`"`), French guillemets (`«»`), and German quotes (`„"`).
|
|
323
|
-
|
|
324
|
-
**Example:**
|
|
325
|
-
|
|
326
|
-
```json
|
|
327
|
-
// Invalid - missing closing quote
|
|
328
|
-
"part2": "'Go to stats page"
|
|
329
|
-
|
|
330
|
-
// Auto-fixed
|
|
331
|
-
"part2": "'Go to stats page'"
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
#### Configuration
|
|
335
|
-
|
|
336
|
-
Configure in `localize.config.js`:
|
|
337
|
-
|
|
338
|
-
```javascript
|
|
339
|
-
glossary: {
|
|
340
|
-
enabled: true,
|
|
341
|
-
caseSensitive: false, // Default case matching
|
|
342
|
-
preserveFormatting: true, // Maintain source capitalization
|
|
343
|
-
glossary: {
|
|
344
|
-
// Simple: Keep term unchanged in all languages
|
|
345
|
-
"API": "API",
|
|
346
|
-
"SDK": "SDK",
|
|
347
|
-
"OAuth": "OAuth",
|
|
348
|
-
|
|
349
|
-
// Case-sensitive matching
|
|
350
|
-
"DeFi": {
|
|
351
|
-
translation: "DeFi",
|
|
352
|
-
caseSensitive: true
|
|
353
|
-
},
|
|
354
|
-
|
|
355
|
-
// Language-specific translations
|
|
356
|
-
"Dashboard": {
|
|
357
|
-
"en": "Dashboard",
|
|
358
|
-
"tr": "Kontrol Paneli",
|
|
359
|
-
"de": "Dashboard",
|
|
360
|
-
"es": "Panel de Control",
|
|
361
|
-
"fr": "Tableau de Bord"
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
14
|
```
|
|
366
15
|
|
|
367
|
-
|
|
16
|
+
## 📖 Documentation
|
|
368
17
|
|
|
369
|
-
|
|
18
|
+
Everything you need to know to master Locai.
|
|
370
19
|
|
|
371
|
-
|
|
372
|
-
import { readFileSync } from "fs";
|
|
20
|
+
### [Getting Started](./docs/getting-started.md)
|
|
373
21
|
|
|
374
|
-
|
|
22
|
+
Introduction, installation options, and setting up your API keys.
|
|
375
23
|
|
|
376
|
-
|
|
377
|
-
glossary: {
|
|
378
|
-
enabled: true,
|
|
379
|
-
glossary: glossaryData,
|
|
380
|
-
},
|
|
381
|
-
};
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
#### How It Works
|
|
385
|
-
|
|
386
|
-
1. **Protection Phase**: Terms are replaced with tokens before translation
|
|
387
|
-
2. **Translation**: AI translates text with protected terms as placeholders
|
|
388
|
-
3. **Restoration**: Tokens are replaced with correct translations
|
|
389
|
-
|
|
390
|
-
#### Example
|
|
391
|
-
|
|
392
|
-
**Source (en.json)**:
|
|
393
|
-
|
|
394
|
-
```json
|
|
395
|
-
{
|
|
396
|
-
"welcome": "Welcome to our API Dashboard",
|
|
397
|
-
"defi": "DeFi staking available"
|
|
398
|
-
}
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
**Without Glossary**:
|
|
402
|
-
|
|
403
|
-
```json
|
|
404
|
-
// tr.json - API and Dashboard might be inconsistently translated
|
|
405
|
-
{
|
|
406
|
-
"welcome": "API Gösterge Paneline Hoş Geldiniz",
|
|
407
|
-
"defi": "DeFi stake etme mevcut"
|
|
408
|
-
}
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
**With Glossary**:
|
|
24
|
+
### [Configuration Guide](./docs/configuration.md)
|
|
412
25
|
|
|
413
|
-
|
|
414
|
-
// tr.json - Consistent terminology guaranteed
|
|
415
|
-
{
|
|
416
|
-
"welcome": "API Kontrol Paneli'ne Hoş Geldiniz",
|
|
417
|
-
"defi": "DeFi stake etme mevcut"
|
|
418
|
-
}
|
|
419
|
-
```
|
|
26
|
+
Detailed guide on `localize.config.ts`, supported file formats (`json`, `yaml`, `po`, `arb`), and advanced settings.
|
|
420
27
|
|
|
421
|
-
|
|
28
|
+
### [CLI Reference](./docs/cli-reference.md)
|
|
422
29
|
|
|
423
|
-
|
|
424
|
-
2. **Technical Acronyms**: Include API, SDK, JSON, REST, GraphQL, etc.
|
|
425
|
-
3. **Industry Terms**: Add domain-specific terminology (DeFi, NFT, Web3, etc.)
|
|
426
|
-
4. **UI Components**: Define consistent translations for Dashboard, Settings, Profile, etc.
|
|
427
|
-
5. **Start Small**: Begin with 10-20 critical terms, expand as needed
|
|
30
|
+
Master the command line. Learn about `translate`, `fix`, `review`, and `analyze`.
|
|
428
31
|
|
|
429
|
-
|
|
430
|
-
| **Auto-Fix** | Corrects common issues automatically |
|
|
32
|
+
### [Providers](./docs/providers.md)
|
|
431
33
|
|
|
432
|
-
|
|
34
|
+
Choose the right brain for your localization. Compare OpenAI, Gemini, DeepSeek, and more.
|
|
433
35
|
|
|
434
|
-
|
|
36
|
+
### [Core Concepts](./docs/concepts.md)
|
|
435
37
|
|
|
436
|
-
|
|
437
|
-
- **Quality Checks** (30%): Placeholder, HTML, length, punctuation validation
|
|
438
|
-
- **Category Weight** (15%): Context-specific adjustments
|
|
439
|
-
- **Language Pair** (10%): Source-target language complexity
|
|
440
|
-
- **Provider Reliability** (5%): Historical provider performance
|
|
38
|
+
Deep dive into Locai's intelligent features. We didn't just wrap an API; we built a localization engine.
|
|
441
39
|
|
|
442
|
-
**
|
|
443
|
-
|
|
444
|
-
- **
|
|
445
|
-
- **
|
|
446
|
-
- **
|
|
447
|
-
- **
|
|
448
|
-
|
|
449
|
-
**Interactive Review
|
|
450
|
-
|
|
451
|
-
```bash
|
|
452
|
-
# Enable confidence scoring
|
|
453
|
-
locai translate --min-confidence 0.8 --save-review-queue
|
|
454
|
-
|
|
455
|
-
# Start interactive review
|
|
456
|
-
locai review
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
**Review Interface:**
|
|
460
|
-
|
|
461
|
-
```
|
|
462
|
-
[1/3] Translation Review
|
|
463
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
464
|
-
Key: app.navigation.home
|
|
465
|
-
Language: tr
|
|
466
|
-
Confidence: 0.82 (medium)
|
|
467
|
-
Category: ui
|
|
468
|
-
|
|
469
|
-
Source:
|
|
470
|
-
"Home"
|
|
471
|
-
|
|
472
|
-
Translation:
|
|
473
|
-
"Ana Sayfa"
|
|
474
|
-
|
|
475
|
-
Actions:
|
|
476
|
-
[A] Accept [E] Edit [R] Reject [S] Skip
|
|
477
|
-
[N] Next [Q] Quit [?] Help
|
|
478
|
-
|
|
479
|
-
Your choice:
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
**Export Review Queue:**
|
|
483
|
-
|
|
484
|
-
```bash
|
|
485
|
-
# Export to JSON
|
|
486
|
-
locai review --export json
|
|
487
|
-
|
|
488
|
-
# Export to CSV for spreadsheet tools
|
|
489
|
-
locai review --export csv
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
### Progress Tracking
|
|
493
|
-
|
|
494
|
-
```bash
|
|
495
|
-
⠋ [tr] [█████═════════] 50.0% | 250/500 items | OK 240 | ERR 10 | ETA: 25s
|
|
496
|
-
```
|
|
40
|
+
- **Infinite Memory**: Vector-based caching. We "remember" every translation. If you translate the same (or similar) sentence again, we fetch it from local cache instantly. Zero cost, 100% consistency.
|
|
41
|
+
- **Smart Sync**: We hash every key. Locai only translates **new** or **modified** keys. If you have 1000 keys and change 5, we only send 5 to the AI.
|
|
42
|
+
- **Context Awareness**: Locai analyzes your content. It knows if a string is for a **Button** (keep it short), **Marketing** (make it punchy), or **Legal** (be precise).
|
|
43
|
+
- **Glossary & Brand Safety**: Define immutable terms (like "Locai", "API", "SaaS"). We guarantee they are never translated or corrupted.
|
|
44
|
+
- **Auto-Fix Engine**: Did the AI forget a closing quote? Or mess up a `{placeholder}`? Locai detects these syntax errors and fixes them automatically before saving.
|
|
45
|
+
- **Multi-Provider Fallback**: OpenAI down? Rate limit hit? Locai automatically switches to Gemini, DeepSeek, or other configured providers without breaking the build.
|
|
46
|
+
- **Confidence Scoring**: Every translation gets a score (0-1). Low confidence translations are flagged for your review.
|
|
47
|
+
- **Interactive Review**: A built-in Terminal UI (TUI) to manually approve or edit translations that need attention.
|
|
497
48
|
|
|
498
|
-
|
|
49
|
+
### [Development Guide](./docs/development.md)
|
|
499
50
|
|
|
500
|
-
|
|
501
|
-
- Visual progress bar with completion percentage
|
|
502
|
-
- Success/error counters (OK/ERR)
|
|
503
|
-
- Estimated time remaining (ETA)
|
|
504
|
-
- Language indicator for current target
|
|
505
|
-
- Items per second processing speed
|
|
506
|
-
|
|
507
|
-
### Infinite Memory (Vector Cache)
|
|
508
|
-
|
|
509
|
-
The tool includes a vector-based semantic cache ("Infinite Memory") that goes beyond simple key-value pairs.
|
|
510
|
-
|
|
511
|
-
**How it works:**
|
|
512
|
-
|
|
513
|
-
1. **Exact Match (Similarity > 98%)**:
|
|
514
|
-
If you translate a sentence that is identical (or nearly identical) to a previous translation, the tool reuses the previous result instantly. This saves AI costs and ensures 100% consistency.
|
|
515
|
-
2. **Semantic Match (Similarity > 85%)**:
|
|
516
|
-
If a new sentence is _similar_ to a previous one (e.g., "Hello world" vs "Hello there world"), the previous translation is retrieved and passed to the AI as context.
|
|
517
|
-
> _Context Prompt:_ "Previously, a similar phrase 'Hello world' was translated as 'Hola mundo'. Please maintain consistency."
|
|
518
|
-
|
|
519
|
-
**Configuration:**
|
|
520
|
-
|
|
521
|
-
```javascript
|
|
522
|
-
vectorMemory: {
|
|
523
|
-
enabled: true,
|
|
524
|
-
// Use directly if similarity > 98%
|
|
525
|
-
exactMatchThreshold: 0.98,
|
|
526
|
-
// Use as context if similarity > 85%
|
|
527
|
-
similarityThreshold: 0.85,
|
|
528
|
-
// Uses local filesystem (no external DB required)
|
|
529
|
-
vectorDbPath: "./.localize-cache/vector-memory",
|
|
530
|
-
}
|
|
531
|
-
```
|
|
532
|
-
|
|
533
|
-
**Benefits:**
|
|
534
|
-
|
|
535
|
-
- **Cost Reduction**: Reduces AI calls for repetitive content.
|
|
536
|
-
- **Consistency**: Ensures similar terminology is used across different parts of the app.
|
|
537
|
-
- **Privacy**: Runs entirely locally using `vectra` (stores embeddings in `.localize-cache`).
|
|
538
|
-
|
|
539
|
-
## Development
|
|
540
|
-
|
|
541
|
-
```bash
|
|
542
|
-
# Install dependencies
|
|
543
|
-
pnpm install
|
|
544
|
-
|
|
545
|
-
# Build the project (TypeScript -> JavaScript)
|
|
546
|
-
pnpm build
|
|
547
|
-
|
|
548
|
-
# Run CLI locally (Development)
|
|
549
|
-
pnpm dev
|
|
550
|
-
|
|
551
|
-
# Run CLI locally (Production/Compiled)
|
|
552
|
-
pnpm start
|
|
553
|
-
|
|
554
|
-
# Format with Prettier
|
|
555
|
-
pnpm format
|
|
556
|
-
pnpm format:check
|
|
557
|
-
```
|
|
558
|
-
|
|
559
|
-
### Project Structure
|
|
560
|
-
|
|
561
|
-
```
|
|
562
|
-
src/
|
|
563
|
-
├── commands/ # CLI commands (translate, fix, review, analyze)
|
|
564
|
-
│ ├── translator.ts # Translation command
|
|
565
|
-
│ └── review.ts # Interactive review TUI
|
|
566
|
-
├── core/ # Core orchestration and processing
|
|
567
|
-
│ ├── orchestrator.ts # Main translation engine
|
|
568
|
-
│ ├── pipeline/ # Pipeline steps (Validation -> Cache -> Translation -> Quality)
|
|
569
|
-
│ ├── provider-factory.ts # AI provider management
|
|
570
|
-
│ ├── fallback-provider.ts # Fallback logic wrapper
|
|
571
|
-
│ └── context-processor.ts # Context detection
|
|
572
|
-
├── services/ # Business logic services
|
|
573
|
-
│ └── translation-service.ts # High-level translation logic
|
|
574
|
-
├── providers/ # AI provider implementations
|
|
575
|
-
│ ├── base-provider.ts # Base with confidence extraction
|
|
576
|
-
│ ├── openai.ts
|
|
577
|
-
│ ├── gemini.ts
|
|
578
|
-
│ └── ...
|
|
579
|
-
└── utils/ # Utilities (cache, rate-limit, quality)
|
|
580
|
-
├── confidence-scorer.ts # Quality confidence scoring
|
|
581
|
-
└── quality/ # Quality validation modules
|
|
582
|
-
```
|
|
583
|
-
|
|
584
|
-
## Advanced Configuration
|
|
585
|
-
|
|
586
|
-
<details>
|
|
587
|
-
<summary>Complete Configuration Reference</summary>
|
|
588
|
-
|
|
589
|
-
### Full Options
|
|
590
|
-
|
|
591
|
-
```javascript
|
|
592
|
-
/**
|
|
593
|
-
* Localization Tool Configuration
|
|
594
|
-
* Version: 2.1.0
|
|
595
|
-
*
|
|
596
|
-
* This configuration file controls all aspects of the localization tool
|
|
597
|
-
* including API providers, performance settings, and quality controls.
|
|
598
|
-
*/
|
|
599
|
-
|
|
600
|
-
export default {
|
|
601
|
-
// ===== BASIC CONFIGURATION =====
|
|
602
|
-
version: "2.1.0", // Configuration version
|
|
603
|
-
localesDir: "./locales", // Directory where locale JSON files are stored
|
|
604
|
-
source: "en", // Source language code (ISO 639-1)
|
|
605
|
-
targets: ["tr", "de", "es", "fr", "hi", "ja", "pl", "ru", "th", "uk", "vi", "yo", "zh"],
|
|
606
|
-
|
|
607
|
-
// ===== API PROVIDER CONFIGURATION =====
|
|
608
|
-
apiProvider: "openai", // Primary provider: openai, dashscope, deepseek, gemini, xai
|
|
609
|
-
useFallback: true, // Enable automatic fallback to other providers
|
|
610
|
-
fallbackOrder: ["openai", "dashscope", "deepseek", "gemini", "xai"], // Provider fallback chain
|
|
611
|
-
|
|
612
|
-
// Individual provider configurations
|
|
613
|
-
apiConfig: {
|
|
614
|
-
deepseek: {
|
|
615
|
-
model: "deepseek-chat", // Model name
|
|
616
|
-
temperature: 0.1, // Creativity level (0.0-1.0)
|
|
617
|
-
maxTokens: 2000, // Maximum tokens per request
|
|
618
|
-
},
|
|
619
|
-
openai: {
|
|
620
|
-
model: "gpt-4o", // Latest optimized model
|
|
621
|
-
temperature: 0.3,
|
|
622
|
-
maxTokens: 2000,
|
|
623
|
-
},
|
|
624
|
-
gemini: {
|
|
625
|
-
model: "gemini-2.0-flash-exp", // Latest Gemini model
|
|
626
|
-
temperature: 0.3,
|
|
627
|
-
maxTokens: 2000,
|
|
628
|
-
},
|
|
629
|
-
dashscope: {
|
|
630
|
-
model: "qwen-plus",
|
|
631
|
-
temperature: 0.3,
|
|
632
|
-
maxTokens: 2000,
|
|
633
|
-
},
|
|
634
|
-
xai: {
|
|
635
|
-
model: "grok-4",
|
|
636
|
-
temperature: 0.3,
|
|
637
|
-
maxTokens: 2000,
|
|
638
|
-
},
|
|
639
|
-
},
|
|
640
|
-
|
|
641
|
-
// ===== PERFORMANCE OPTIMIZATION =====
|
|
642
|
-
concurrencyLimit: 1, // Maximum parallel translations (optimized for stability)
|
|
643
|
-
cacheEnabled: true, // Enable translation caching
|
|
644
|
-
cacheTTL: 24 * 60 * 60 * 1000, // Cache time-to-live (24 hours)
|
|
645
|
-
cacheSize: 2000, // Maximum cached items
|
|
646
|
-
updateAgeOnGet: true, // Update cache age when accessed (LRU behavior)
|
|
647
|
-
allowStaleCache: true, // Allow returning stale cache while refreshing
|
|
648
|
-
staleWhileRevalidate: true, // Serve stale content while revalidating in background
|
|
649
|
-
|
|
650
|
-
// Progress Tracker Options
|
|
651
|
-
progressOptions: {
|
|
652
|
-
logToConsole: true, // Show progress in console
|
|
653
|
-
logFrequency: 1, // Update frequency (every N items)
|
|
654
|
-
},
|
|
655
|
-
|
|
656
|
-
// Rate Limiter Configuration (Speed Optimized)
|
|
657
|
-
rateLimiter: {
|
|
658
|
-
enabled: true,
|
|
659
|
-
providerLimits: {
|
|
660
|
-
openai: { rpm: 1000, concurrency: 15 }, // Aggressive limits for OpenAI
|
|
661
|
-
deepseek: { rpm: 200, concurrency: 8 },
|
|
662
|
-
gemini: { rpm: 500, concurrency: 12 }, // High-performance settings
|
|
663
|
-
dashscope: { rpm: 200, concurrency: 8 },
|
|
664
|
-
xai: { rpm: 300, concurrency: 10 },
|
|
665
|
-
},
|
|
666
|
-
queueStrategy: "fifo", // First-in-first-out for maximum speed
|
|
667
|
-
adaptiveThrottling: false, // Disabled for consistent high performance
|
|
668
|
-
queueTimeout: 10000, // Fast timeout (10 seconds)
|
|
669
|
-
},
|
|
670
|
-
|
|
671
|
-
// ===== ERROR HANDLING & RELIABILITY =====
|
|
672
|
-
retryOptions: {
|
|
673
|
-
maxRetries: 2, // Global retry attempts
|
|
674
|
-
initialDelay: 1000, // Initial delay before retry (ms)
|
|
675
|
-
maxDelay: 10000, // Maximum delay cap (ms)
|
|
676
|
-
jitter: true, // Add randomization to retry delays
|
|
677
|
-
retryableErrors: ["rate_limit", "timeout", "network", "server", "unknown"],
|
|
678
|
-
perProviderRetry: {
|
|
679
|
-
dashscope: { maxRetries: 3 }, // Provider-specific retry settings
|
|
680
|
-
openai: { maxRetries: 2 },
|
|
681
|
-
},
|
|
682
|
-
},
|
|
683
|
-
|
|
684
|
-
// ===== CONTEXT-AWARE TRANSLATION =====
|
|
685
|
-
context: {
|
|
686
|
-
enabled: true, // Enable context detection
|
|
687
|
-
useAI: true, // Use AI for context analysis
|
|
688
|
-
aiProvider: "openai", // AI provider for context analysis
|
|
689
|
-
minTextLength: 50, // Minimum text length for AI analysis
|
|
690
|
-
allowNewCategories: true, // Allow AI to suggest new categories
|
|
691
|
-
debug: false, // Enable detailed context analysis logs
|
|
692
|
-
|
|
693
|
-
// AI Analysis Configuration
|
|
694
|
-
analysisOptions: {
|
|
695
|
-
model: "gpt-4o", // OpenAI model for context analysis
|
|
696
|
-
temperature: 0.2, // Lower temperature for consistent analysis
|
|
697
|
-
maxTokens: 1000, // Tokens for analysis
|
|
698
|
-
},
|
|
699
|
-
|
|
700
|
-
// Detection Thresholds
|
|
701
|
-
detection: {
|
|
702
|
-
threshold: 2, // Minimum keyword matches for category
|
|
703
|
-
minConfidence: 0.6, // Minimum confidence score (0.0-1.0)
|
|
704
|
-
},
|
|
705
|
-
|
|
706
|
-
// Content Categories with Keywords and Prompts
|
|
707
|
-
categories: {
|
|
708
|
-
technical: {
|
|
709
|
-
keywords: [
|
|
710
|
-
"API",
|
|
711
|
-
"backend",
|
|
712
|
-
"database",
|
|
713
|
-
"server",
|
|
714
|
-
"endpoint",
|
|
715
|
-
"function",
|
|
716
|
-
"method",
|
|
717
|
-
"class",
|
|
718
|
-
"object",
|
|
719
|
-
"variable",
|
|
720
|
-
],
|
|
721
|
-
prompt: "Preserve technical terms and variable names",
|
|
722
|
-
weight: 1.3,
|
|
723
|
-
},
|
|
724
|
-
defi: {
|
|
725
|
-
keywords: [
|
|
726
|
-
"DeFi",
|
|
727
|
-
"staking",
|
|
728
|
-
"yield",
|
|
729
|
-
"liquidity",
|
|
730
|
-
"token",
|
|
731
|
-
"blockchain",
|
|
732
|
-
"crypto",
|
|
733
|
-
"wallet",
|
|
734
|
-
"smart contract",
|
|
735
|
-
],
|
|
736
|
-
prompt: "Keep DeFi terms in English",
|
|
737
|
-
weight: 1.2,
|
|
738
|
-
},
|
|
739
|
-
marketing: {
|
|
740
|
-
keywords: [
|
|
741
|
-
"brand",
|
|
742
|
-
"campaign",
|
|
743
|
-
"customer",
|
|
744
|
-
"audience",
|
|
745
|
-
"promotion",
|
|
746
|
-
"value",
|
|
747
|
-
"benefit",
|
|
748
|
-
"feature",
|
|
749
|
-
],
|
|
750
|
-
prompt: "Use persuasive and engaging language appropriate for marketing content",
|
|
751
|
-
weight: 1.1,
|
|
752
|
-
},
|
|
753
|
-
legal: {
|
|
754
|
-
keywords: [
|
|
755
|
-
"terms",
|
|
756
|
-
"conditions",
|
|
757
|
-
"privacy",
|
|
758
|
-
"policy",
|
|
759
|
-
"agreement",
|
|
760
|
-
"compliance",
|
|
761
|
-
"regulation",
|
|
762
|
-
"law",
|
|
763
|
-
],
|
|
764
|
-
prompt: "Maintain formal tone and precise legal terminology",
|
|
765
|
-
weight: 1.4,
|
|
766
|
-
},
|
|
767
|
-
ui: {
|
|
768
|
-
keywords: [
|
|
769
|
-
"button",
|
|
770
|
-
"click",
|
|
771
|
-
"menu",
|
|
772
|
-
"screen",
|
|
773
|
-
"page",
|
|
774
|
-
"view",
|
|
775
|
-
"interface",
|
|
776
|
-
"select",
|
|
777
|
-
"tap",
|
|
778
|
-
],
|
|
779
|
-
prompt: "Keep UI terms consistent and clear, maintain proper formatting for UI elements",
|
|
780
|
-
weight: 1.2,
|
|
781
|
-
},
|
|
782
|
-
},
|
|
783
|
-
|
|
784
|
-
// Fallback for unmatched content
|
|
785
|
-
fallback: {
|
|
786
|
-
category: "general",
|
|
787
|
-
prompt: "Provide a natural translation",
|
|
788
|
-
},
|
|
789
|
-
},
|
|
790
|
-
|
|
791
|
-
// ===== QUALITY ASSURANCE =====
|
|
792
|
-
qualityChecks: {
|
|
793
|
-
enabled: true, // Enable quality validation
|
|
794
|
-
rules: {
|
|
795
|
-
placeholderConsistency: true, // Validate {{placeholders}}
|
|
796
|
-
htmlTagsConsistency: true, // Preserve <HTML> tags
|
|
797
|
-
punctuationCheck: true, // Check punctuation consistency
|
|
798
|
-
quoteBalanceCheck: true, // Detect and fix unbalanced quotes
|
|
799
|
-
lengthValidation: true, // Validate translation length
|
|
800
|
-
sanitizeOutput: true, // Clean AI artifacts
|
|
801
|
-
markdownPreservation: true, // Preserve markdown formatting
|
|
802
|
-
specialCharacters: true, // Maintain special characters
|
|
803
|
-
codeBlockPreservation: true, // Preserve code blocks
|
|
804
|
-
},
|
|
805
|
-
autoFix: true, // Automatically fix detected issues
|
|
806
|
-
},
|
|
807
|
-
|
|
808
|
-
// ===== STYLE GUIDE =====
|
|
809
|
-
styleGuide: {
|
|
810
|
-
formality: "neutral", // Options: formal, neutral, informal
|
|
811
|
-
toneOfVoice: "professional", // Options: professional, friendly, casual, technical
|
|
812
|
-
conventions: {
|
|
813
|
-
useOxfordComma: true, // Use Oxford comma in lists
|
|
814
|
-
useSentenceCase: true, // Use sentence case for headings
|
|
815
|
-
},
|
|
816
|
-
},
|
|
817
|
-
|
|
818
|
-
// ===== LENGTH CONTROL =====
|
|
819
|
-
lengthControl: {
|
|
820
|
-
mode: "smart", // Options: strict, flexible, exact, relaxed, smart
|
|
821
|
-
rules: {
|
|
822
|
-
strict: 0.1, // 10% deviation allowed
|
|
823
|
-
flexible: 0.3, // 30% deviation allowed
|
|
824
|
-
exact: 0.05, // 5% deviation allowed
|
|
825
|
-
relaxed: 0.5, // 50% deviation allowed
|
|
826
|
-
smart: {
|
|
827
|
-
default: 0.15, // Default tolerance
|
|
828
|
-
// Language-specific rules
|
|
829
|
-
byLanguage: {
|
|
830
|
-
ja: { max: 0.35, min: -0.2 }, // Japanese: +35% / -20%
|
|
831
|
-
zh: { max: 0.35, min: -0.2 }, // Chinese: +35% / -20%
|
|
832
|
-
th: { max: 0.3, min: -0.15 }, // Thai: +30% / -15%
|
|
833
|
-
vi: { max: 0.25, min: -0.15 }, // Vietnamese: +25% / -15%
|
|
834
|
-
hi: { max: 0.2, min: -0.1 }, // Hindi: +20% / -10%
|
|
835
|
-
ru: { max: 0.25, min: -0.15 }, // Russian: +25% / -15%
|
|
836
|
-
uk: { max: 0.25, min: -0.15 }, // Ukrainian: +25% / -15%
|
|
837
|
-
pl: { max: 0.2, min: -0.1 }, // Polish: +20% / -10%
|
|
838
|
-
de: { max: 0.15, min: -0.1 }, // German: +15% / -10%
|
|
839
|
-
fr: { max: 0.15, min: -0.1 }, // French: +15% / -10%
|
|
840
|
-
es: { max: 0.15, min: -0.1 }, // Spanish: +15% / -10%
|
|
841
|
-
tr: { max: 0.15, min: -0.1 }, // Turkish: +15% / -10%
|
|
842
|
-
},
|
|
843
|
-
// Context-specific rules
|
|
844
|
-
byContext: {
|
|
845
|
-
technical: { max: 0.2, min: -0.1 }, // Technical: +20% / -10%
|
|
846
|
-
marketing: { max: 0.3, min: -0.15 }, // Marketing: +30% / -15%
|
|
847
|
-
legal: { max: 0.1, min: -0.05 }, // Legal: +10% / -5%
|
|
848
|
-
general: { max: 0.15, min: -0.1 }, // General: +15% / -10%
|
|
849
|
-
},
|
|
850
|
-
},
|
|
851
|
-
},
|
|
852
|
-
},
|
|
853
|
-
|
|
854
|
-
// ===== LOGGING & DIAGNOSTICS =====
|
|
855
|
-
logging: {
|
|
856
|
-
verbose: false, // Disable verbose logging for cleaner output
|
|
857
|
-
diagnosticsLevel: "minimal", // Options: minimal, normal, detailed
|
|
858
|
-
outputFormat: "pretty", // Options: pretty, json, minimal
|
|
859
|
-
saveErrorLogs: true, // Save error logs to file
|
|
860
|
-
logDirectory: "./logs", // Directory for log files
|
|
861
|
-
includeTimestamps: true, // Include timestamps in logs
|
|
862
|
-
logRotation: {
|
|
863
|
-
enabled: true, // Enable log rotation
|
|
864
|
-
maxFiles: 5, // Maximum log files to keep
|
|
865
|
-
maxSize: "10MB", // Maximum log file size
|
|
866
|
-
},
|
|
867
|
-
},
|
|
868
|
-
|
|
869
|
-
// ===== FILE OPERATIONS =====
|
|
870
|
-
fileOperations: {
|
|
871
|
-
backupFiles: true, // Create backups of existing files before overwriting
|
|
872
|
-
backupDir: "./backups", // Directory for backup files
|
|
873
|
-
atomic: true, // Use atomic writes to prevent corruption
|
|
874
|
-
createMissingDirs: true, // Automatically create missing directories
|
|
875
|
-
},
|
|
876
|
-
|
|
877
|
-
// ===== SYNCHRONIZATION =====
|
|
878
|
-
syncOptions: {
|
|
879
|
-
enabled: true, // Enable sync features
|
|
880
|
-
removeDeletedKeys: true, // Remove deleted keys from target files
|
|
881
|
-
retranslateModified: true, // Re-translate modified keys
|
|
882
|
-
stateTracking: {
|
|
883
|
-
enabled: true, // Enable state tracking for change detection
|
|
884
|
-
stateFileName: "localization.state.json", // State file name
|
|
885
|
-
stateDir: ".localize-cache", // Directory for state files
|
|
886
|
-
},
|
|
887
|
-
},
|
|
888
|
-
|
|
889
|
-
// ===== ADVANCED SETTINGS =====
|
|
890
|
-
advanced: {
|
|
891
|
-
timeoutMs: 15000, // Request timeout (15 seconds)
|
|
892
|
-
maxKeyLength: 10000, // Maximum key length for translation
|
|
893
|
-
maxBatchSize: 30, // Maximum batch size for operations
|
|
894
|
-
autoOptimize: true, // Auto-optimize settings for hardware
|
|
895
|
-
debug: false, // Enable debug mode
|
|
896
|
-
},
|
|
897
|
-
|
|
898
|
-
// ===== QUALITY CONFIDENCE SCORING =====
|
|
899
|
-
confidenceScoring: {
|
|
900
|
-
enabled: false, // Enable confidence scoring for translations
|
|
901
|
-
minConfidence: 0.7, // Minimum confidence threshold (0-1)
|
|
902
|
-
saveReviewQueue: false, // Save low-confidence items for manual review
|
|
903
|
-
autoApproveThreshold: 0.9, // Auto-approve translations above this score
|
|
904
|
-
reviewThreshold: 0.7, // Flag for review below this score
|
|
905
|
-
rejectThreshold: 0.5, // Auto-reject translations below this score
|
|
906
|
-
},
|
|
907
|
-
};
|
|
908
|
-
```
|
|
51
|
+
Contributing to Locai? Learn how to build, test, and run the project locally.
|
|
909
52
|
|
|
910
|
-
|
|
53
|
+
## ✨ Why Locai?
|
|
911
54
|
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
| **Quality** | `qualityChecks`, `lengthControl` | Validation rules and auto-fixing |
|
|
917
|
-
| **Sync** | `syncOptions.removeDeletedKeys` | Smart synchronization behavior |
|
|
918
|
-
| **Providers** | `apiConfig`, `fallbackOrder` | AI provider settings and fallback chain |
|
|
55
|
+
- **Framework Agnostic**: Works with Next.js, Flutter, Django, and more.
|
|
56
|
+
- **Context Aware**: Knows the difference between "Home" (House) and "Home" (Page).
|
|
57
|
+
- **Cost Efficient**: Smart caching and incremental updates save ~90% of AI costs.
|
|
58
|
+
- **Developer Friendly**: TypeScript config, type safety, and great error messages.
|
|
919
59
|
|
|
920
|
-
|
|
60
|
+
## 🤝 Community & Contributing
|
|
921
61
|
|
|
922
|
-
|
|
62
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
923
63
|
|
|
924
|
-
|
|
64
|
+
This project is governed by a [Code of Conduct](CODE_OF_CONDUCT.md) to ensure a welcoming environment for everyone.
|
|
925
65
|
|
|
926
|
-
|
|
66
|
+
## 📄 License
|
|
927
67
|
|
|
928
|
-
[
|
|
68
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -222,7 +222,6 @@ class Orchestrator {
|
|
|
222
222
|
if (this.advanced.debug) {
|
|
223
223
|
log(`Processing ${items.length} items with concurrency limit ${this.concurrencyLimit}`, true);
|
|
224
224
|
}
|
|
225
|
-
console.log(""); // Empty line for progress bar
|
|
226
225
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
227
226
|
const allPromises = [];
|
|
228
227
|
for (const chunk of chunks) {
|
|
@@ -386,7 +386,7 @@ class TranslationService {
|
|
|
386
386
|
globalStats.details[category].samples++;
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
|
-
savedMessage =
|
|
389
|
+
savedMessage = `Translations saved: ${safeTargetLang}.json`;
|
|
390
390
|
}
|
|
391
391
|
globalStats.languages[safeTargetLang].timeMs = Date.now() - langStartTime;
|
|
392
392
|
return { status: finalStatus, savedMessage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "locai",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/core/orchestrator.js",
|
|
6
6
|
"directories": {
|
|
@@ -37,8 +37,16 @@
|
|
|
37
37
|
"email": "ahmetenesdur@gmail.com",
|
|
38
38
|
"url": "https://github.com/ahmetenesdur"
|
|
39
39
|
},
|
|
40
|
-
"license": "
|
|
41
|
-
"description": "CLI
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"description": "Global, AI-Powered Translation CLI for every project.",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/ahmetenesdur/localization-tool.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/ahmetenesdur/localization-tool/issues"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/ahmetenesdur/localization-tool#readme",
|
|
42
50
|
"engines": {
|
|
43
51
|
"node": ">=14.13.0"
|
|
44
52
|
},
|