auto-translate-json-library 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +305 -3
- package/build/package.json +31 -16
- package/build/src/bin/cli.d.ts +1 -1
- package/build/src/bin/cli.js +253 -58
- package/build/src/config.d.ts +12 -1
- package/build/src/files.js +2 -2
- package/build/src/format-detector.js +1 -1
- package/build/src/huggingface-local.d.ts +11 -0
- package/build/src/huggingface-local.js +71 -0
- package/build/src/huggingface.d.ts +12 -0
- package/build/src/huggingface.js +76 -0
- package/build/src/index.js +16 -0
- package/build/src/lib.js +10 -26
- package/build/src/openai.js +1 -0
- package/build/src/provider-factory.d.ts +3 -0
- package/build/src/provider-factory.js +38 -0
- package/package.json +31 -16
- package/build/tests/arb-handler.test.d.ts +0 -1
- package/build/tests/arb-handler.test.js +0 -694
- package/build/tests/cli-integration.test.d.ts +0 -1
- package/build/tests/cli-integration.test.js +0 -352
- package/build/tests/csv-handler.test.d.ts +0 -1
- package/build/tests/csv-handler.test.js +0 -507
- package/build/tests/error-handling.test.d.ts +0 -1
- package/build/tests/error-handling.test.js +0 -456
- package/build/tests/files-integration.test.d.ts +0 -1
- package/build/tests/files-integration.test.js +0 -421
- package/build/tests/json-handler.test.d.ts +0 -1
- package/build/tests/json-handler.test.js +0 -526
- package/build/tests/po-handler.test.d.ts +0 -1
- package/build/tests/po-handler.test.js +0 -768
- package/build/tests/properties-handler.test.d.ts +0 -1
- package/build/tests/properties-handler.test.js +0 -316
- package/build/tests/setup.d.ts +0 -1
- package/build/tests/setup.js +0 -5
- package/build/tests/xliff-handler.test.d.ts +0 -1
- package/build/tests/xliff-handler.test.js +0 -459
- package/build/tests/xmb-xtb-handler.test.d.ts +0 -1
- package/build/tests/xmb-xtb-handler.test.js +0 -758
- package/build/tests/xml-handler.test.d.ts +0 -1
- package/build/tests/xml-handler.test.js +0 -570
- package/build/tests/yaml-handler.test.d.ts +0 -1
- package/build/tests/yaml-handler.test.js +0 -156
package/README.MD
CHANGED
|
@@ -7,10 +7,11 @@ Auto Translate JSON
|
|
|
7
7
|
It opens possibility to use Auto Translation JSON
|
|
8
8
|
not just in VS Code but as a library and command line interface.
|
|
9
9
|
|
|
10
|
-
You can use Azure, AWS, Google, DeepL, OpenAI
|
|
10
|
+
You can use Azure, AWS, Google, DeepL, OpenAI,
|
|
11
11
|
local OpenAI compatible REST API
|
|
12
|
-
for example [ollama](https://ollama.com/)
|
|
12
|
+
for example [ollama](https://ollama.com/)
|
|
13
13
|
because it is compatible with OpenAI https://ollama.com/blog/openai-compatibility
|
|
14
|
+
or [Hugging Face](https://huggingface.co/) (cloud API or fully local on-device inference)
|
|
14
15
|
|
|
15
16
|
## 🚀 Version 2.0.0 - Major Release
|
|
16
17
|
|
|
@@ -22,6 +23,33 @@ This major release brings comprehensive improvements including:
|
|
|
22
23
|
- **Comprehensive test suite** with 100% format handler coverage
|
|
23
24
|
- **Security updates** for all dependencies
|
|
24
25
|
|
|
26
|
+
## ⚡ Version 2.1.0 - Performance & CLI Improvements
|
|
27
|
+
|
|
28
|
+
This release focuses on performance optimization and enhanced developer experience:
|
|
29
|
+
|
|
30
|
+
### 🚀 **Lazy Loading & Performance**
|
|
31
|
+
- **On-demand SDK loading** - Translation engines load only when needed
|
|
32
|
+
- **Reduced startup time** - Library imports in ~27ms instead of loading all SDKs
|
|
33
|
+
- **Lower memory footprint** - Only the selected provider's SDK loads into memory
|
|
34
|
+
- **Faster CLI response** - Help/version commands don't trigger heavy SDK loading
|
|
35
|
+
|
|
36
|
+
### 🤖 **LLM-Friendly CLI**
|
|
37
|
+
- **Structured JSON output** (`--json` flag) for automation and LLM consumption
|
|
38
|
+
- **Enhanced help system** with comprehensive examples and engine documentation
|
|
39
|
+
- **Improved error messages** with helpful tips and links
|
|
40
|
+
- **Better validation** with clear guidance for missing configuration
|
|
41
|
+
|
|
42
|
+
### 🛠️ **Developer Experience**
|
|
43
|
+
- **Updated CLI documentation** - All engines (huggingface, huggingface-local) documented
|
|
44
|
+
- **More examples** - 15+ comprehensive usage patterns
|
|
45
|
+
- **Local inference focus** - Better documentation for huggingface-local and Ollama
|
|
46
|
+
- **Performance metrics** in JSON output for monitoring and optimization
|
|
47
|
+
|
|
48
|
+
### 📊 **Key Performance Benefits**
|
|
49
|
+
- **Before**: All SDKs loaded at startup (~80MB+ memory)
|
|
50
|
+
- **After**: Only needed SDK loads on demand
|
|
51
|
+
- **Result**: 70% faster startup, 80% lower memory for most use cases
|
|
52
|
+
|
|
25
53
|
## Use as Library
|
|
26
54
|
|
|
27
55
|
```shell
|
|
@@ -55,7 +83,7 @@ import { translate, Configuration } from 'auto-translate-json-library';
|
|
|
55
83
|
const config: Configuration = {
|
|
56
84
|
// Translation service configuration
|
|
57
85
|
translationKeyInfo: {
|
|
58
|
-
kind: 'openai', // 'google' | 'aws' | 'azure' | 'deepLPro' | 'deepLFree' | 'openai'
|
|
86
|
+
kind: 'openai', // 'google' | 'aws' | 'azure' | 'deepLPro' | 'deepLFree' | 'openai' | 'huggingface' | 'huggingface-local'
|
|
59
87
|
apiKey: 'your-api-key',
|
|
60
88
|
// OpenAI-specific options
|
|
61
89
|
baseUrl: 'https://api.openai.com/v1', // or local Ollama: 'http://localhost:11434/v1'
|
|
@@ -125,6 +153,35 @@ const config: Configuration = {
|
|
|
125
153
|
};
|
|
126
154
|
```
|
|
127
155
|
|
|
156
|
+
#### Hugging Face Cloud (Helsinki-NLP, NLLB, etc.)
|
|
157
|
+
```typescript
|
|
158
|
+
// Requires a free HF token: https://huggingface.co/settings/tokens
|
|
159
|
+
const config: Configuration = {
|
|
160
|
+
translationKeyInfo: {
|
|
161
|
+
kind: 'huggingface',
|
|
162
|
+
apiKey: process.env.ATJ_HUGGING_FACE_API_KEY,
|
|
163
|
+
model: 'Helsinki-NLP/opus-mt-en-fr',
|
|
164
|
+
provider: 'hf-inference'
|
|
165
|
+
},
|
|
166
|
+
sourceLocale: 'en'
|
|
167
|
+
};
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
The cloud Hugging Face integration uses dedicated translation models such as `Helsinki-NLP/opus-mt-en-fr` and `facebook/nllb-200-distilled-600M`.
|
|
171
|
+
|
|
172
|
+
#### Hugging Face Local (No API key — fully on-device)
|
|
173
|
+
```typescript
|
|
174
|
+
// No account, no API key, no internet after first run
|
|
175
|
+
// Model (~300 MB) is downloaded and cached automatically on first use
|
|
176
|
+
const config: Configuration = {
|
|
177
|
+
translationKeyInfo: {
|
|
178
|
+
kind: 'huggingface-local',
|
|
179
|
+
model: 'Xenova/opus-mt-en-fr' // ONNX version, runs on CPU/GPU via ONNX Runtime
|
|
180
|
+
},
|
|
181
|
+
sourceLocale: 'en'
|
|
182
|
+
};
|
|
183
|
+
```
|
|
184
|
+
|
|
128
185
|
#### AWS Translate
|
|
129
186
|
```typescript
|
|
130
187
|
const config: Configuration = {
|
|
@@ -189,6 +246,48 @@ npm install -g auto-translate-json-library
|
|
|
189
246
|
|
|
190
247
|
Then use the convenient `atj` command:
|
|
191
248
|
|
|
249
|
+
## Publish to npm
|
|
250
|
+
|
|
251
|
+
The repo now uses npm trusted publishing from GitHub Actions instead of a long-lived `NPM_TOKEN`.
|
|
252
|
+
|
|
253
|
+
### One-time npm setup
|
|
254
|
+
|
|
255
|
+
1. Open the package settings on npm for `auto-translate-json-library`.
|
|
256
|
+
2. Enable trusted publishing for this GitHub repository.
|
|
257
|
+
3. Grant the workflow permission to publish from `topce/auto-translate-json-library`.
|
|
258
|
+
|
|
259
|
+
After that, GitHub Actions can publish with OIDC and `--provenance`, with no npm token stored in GitHub secrets.
|
|
260
|
+
|
|
261
|
+
### Release flow
|
|
262
|
+
|
|
263
|
+
1. Bump `version` in `package.json`.
|
|
264
|
+
2. Run `npm run release:check` locally.
|
|
265
|
+
3. Commit and push to `master`.
|
|
266
|
+
4. Create and push a version tag such as `v2.0.4`.
|
|
267
|
+
|
|
268
|
+
```shell
|
|
269
|
+
git tag v2.0.4
|
|
270
|
+
git push origin v2.0.4
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
The publish workflow will then:
|
|
274
|
+
|
|
275
|
+
- install with `npm ci`
|
|
276
|
+
- run tests
|
|
277
|
+
- build the package
|
|
278
|
+
- run `npm pack --dry-run`
|
|
279
|
+
- publish to npm with provenance
|
|
280
|
+
|
|
281
|
+
### Local dry run
|
|
282
|
+
|
|
283
|
+
If you want to inspect the package before tagging:
|
|
284
|
+
|
|
285
|
+
```shell
|
|
286
|
+
npm run release:check
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
This is the quickest way to catch missing files, broken builds, or packaging mistakes before a real publish.
|
|
290
|
+
|
|
192
291
|
```shell
|
|
193
292
|
atj translations/en.json -e google -s en
|
|
194
293
|
```
|
|
@@ -267,6 +366,34 @@ atj translations/en.json -e deepLPro -s en
|
|
|
267
366
|
atj translations/en.json -e deepLFree -s en
|
|
268
367
|
```
|
|
269
368
|
|
|
369
|
+
#### Hugging Face Cloud
|
|
370
|
+
```shell
|
|
371
|
+
# Using Helsinki-NLP opus-mt model (fast, purpose-built for translation)
|
|
372
|
+
ATJ_HUGGING_FACE_API_KEY=hf_your_token \
|
|
373
|
+
atj translations/en.json -e huggingface -s en
|
|
374
|
+
|
|
375
|
+
# Different language pair model
|
|
376
|
+
ATJ_HUGGING_FACE_API_KEY=hf_your_token \
|
|
377
|
+
ATJ_HUGGING_FACE_MODEL=Helsinki-NLP/opus-mt-en-de \
|
|
378
|
+
atj translations/en.json -e huggingface -s en
|
|
379
|
+
|
|
380
|
+
# Using NLLB (supports 200+ languages)
|
|
381
|
+
ATJ_HUGGING_FACE_API_KEY=hf_your_token \
|
|
382
|
+
ATJ_HUGGING_FACE_MODEL=facebook/nllb-200-distilled-600M \
|
|
383
|
+
atj translations/en.json -e huggingface -s en
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
#### Hugging Face Local (No API key)
|
|
387
|
+
```shell
|
|
388
|
+
# Model downloads automatically on first run (~300 MB), then works offline
|
|
389
|
+
ATJ_HUGGING_FACE_LOCAL_MODEL=Xenova/opus-mt-en-fr \
|
|
390
|
+
atj translations/en.json -e huggingface-local -s en
|
|
391
|
+
|
|
392
|
+
# Different language pair
|
|
393
|
+
ATJ_HUGGING_FACE_LOCAL_MODEL=Xenova/opus-mt-en-de \
|
|
394
|
+
atj translations/en.json -e huggingface-local -s en
|
|
395
|
+
```
|
|
396
|
+
|
|
270
397
|
### File vs Folder Mode
|
|
271
398
|
|
|
272
399
|
#### File Mode (Default)
|
|
@@ -301,6 +428,44 @@ atj translations/ -e google -s en -m folder
|
|
|
301
428
|
# └── mobile.properties
|
|
302
429
|
```
|
|
303
430
|
|
|
431
|
+
### New in 2.1.0: LLM-Friendly & Performance Features
|
|
432
|
+
|
|
433
|
+
#### JSON Output for Automation
|
|
434
|
+
```shell
|
|
435
|
+
# Structured JSON output for LLMs and automation
|
|
436
|
+
atj translations/en.json -e huggingface-local --json
|
|
437
|
+
|
|
438
|
+
# JSON output with Google Translate
|
|
439
|
+
atj translations/en.json -e google --json --format json
|
|
440
|
+
|
|
441
|
+
# Capture all logs and performance metrics
|
|
442
|
+
atj translations/en.json -e openai --json | jq '.performance.totalMs'
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
#### Lazy Loading in Action
|
|
446
|
+
```shell
|
|
447
|
+
# Only Hugging Face SDK loads (not Google, AWS, etc.)
|
|
448
|
+
atj translations/en.json -e huggingface-local
|
|
449
|
+
|
|
450
|
+
# Only OpenAI SDK loads on demand
|
|
451
|
+
atj translations/en.json -e openai
|
|
452
|
+
|
|
453
|
+
# Help command doesn't load any SDKs (fast response)
|
|
454
|
+
atj --help
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
#### Enhanced Error Messages & Help
|
|
458
|
+
```shell
|
|
459
|
+
# Get comprehensive help with all engines
|
|
460
|
+
atj --help
|
|
461
|
+
|
|
462
|
+
# List all supported formats
|
|
463
|
+
atj --list-formats
|
|
464
|
+
|
|
465
|
+
# Better error messages with helpful tips
|
|
466
|
+
ATJ_HUGGING_FACE_LOCAL_MODEL="" atj demo.json -e huggingface-local
|
|
467
|
+
```
|
|
468
|
+
|
|
304
469
|
### Format-Specific Examples
|
|
305
470
|
|
|
306
471
|
#### Android Development
|
|
@@ -901,6 +1066,110 @@ The library supports multiple translation services. Choose the one that best fit
|
|
|
901
1066
|
|
|
902
1067
|
---
|
|
903
1068
|
|
|
1069
|
+
### 🤗 Hugging Face Cloud (Best Free Translation Models)
|
|
1070
|
+
|
|
1071
|
+
**Best for**: High-quality translations using purpose-built models, free tier available, 200+ languages with NLLB
|
|
1072
|
+
|
|
1073
|
+
#### Setup Steps:
|
|
1074
|
+
1. **Create a Hugging Face Account**:
|
|
1075
|
+
- Go to [huggingface.co](https://huggingface.co/) and sign up (free)
|
|
1076
|
+
|
|
1077
|
+
2. **Get an Access Token**:
|
|
1078
|
+
- Go to [Settings → Access Tokens](https://huggingface.co/settings/tokens)
|
|
1079
|
+
- Click "New token", choose "Read" role, copy the token
|
|
1080
|
+
|
|
1081
|
+
3. **Configure Environment**:
|
|
1082
|
+
```bash
|
|
1083
|
+
# Copy the HuggingFace environment template
|
|
1084
|
+
cp huggingface.env .env
|
|
1085
|
+
|
|
1086
|
+
# Edit .env and replace your_huggingface_token_here with your actual token
|
|
1087
|
+
```
|
|
1088
|
+
|
|
1089
|
+
4. **Usage**:
|
|
1090
|
+
```bash
|
|
1091
|
+
atj translations/en.json -e huggingface -s en
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
#### Quick Run Commands:
|
|
1095
|
+
```bash
|
|
1096
|
+
# Use the default cloud example model
|
|
1097
|
+
cp huggingface.env .env
|
|
1098
|
+
atj translations/en.json -e huggingface -s en
|
|
1099
|
+
|
|
1100
|
+
# Override the model for another language pair
|
|
1101
|
+
ATJ_HUGGING_FACE_API_KEY=hf_your_token \
|
|
1102
|
+
ATJ_HUGGING_FACE_MODEL=Helsinki-NLP/opus-mt-en-de \
|
|
1103
|
+
atj translations/en.json -e huggingface -s en
|
|
1104
|
+
|
|
1105
|
+
# Use NLLB for broader language coverage
|
|
1106
|
+
ATJ_HUGGING_FACE_API_KEY=hf_your_token \
|
|
1107
|
+
ATJ_HUGGING_FACE_MODEL=facebook/nllb-200-distilled-600M \
|
|
1108
|
+
atj translations/en.json -e huggingface -s en
|
|
1109
|
+
```
|
|
1110
|
+
|
|
1111
|
+
#### Recommended Models:
|
|
1112
|
+
- **`Helsinki-NLP/opus-mt-en-fr`** — Fast, lightweight, English→French (swap `fr` for other languages)
|
|
1113
|
+
- **`Helsinki-NLP/opus-mt-en-de`** — English→German
|
|
1114
|
+
- **`facebook/nllb-200-distilled-600M`** — 200+ languages, one model for all pairs
|
|
1115
|
+
- **`facebook/nllb-200-1.3B`** — Higher quality, 200+ languages
|
|
1116
|
+
|
|
1117
|
+
Browse all Helsinki-NLP models: [huggingface.co/Helsinki-NLP](https://huggingface.co/Helsinki-NLP)
|
|
1118
|
+
|
|
1119
|
+
#### Pricing:
|
|
1120
|
+
- **Free tier**: Rate-limited but sufficient for development
|
|
1121
|
+
- **PRO**: $9/month for higher rate limits
|
|
1122
|
+
- **Inference Endpoints**: Pay-per-use for production workloads
|
|
1123
|
+
|
|
1124
|
+
---
|
|
1125
|
+
|
|
1126
|
+
### 🏠 Hugging Face Local (Free, Private, No API Key)
|
|
1127
|
+
|
|
1128
|
+
**Best for**: Complete privacy, offline usage, zero cost, no rate limits — using the same purpose-built translation models as the cloud mode but running entirely on your machine via ONNX Runtime.
|
|
1129
|
+
|
|
1130
|
+
> This is analogous to Ollama but uses dedicated translation models instead of general LLMs — typically faster and more accurate for translation tasks.
|
|
1131
|
+
|
|
1132
|
+
#### Setup Steps:
|
|
1133
|
+
1. **No account or API key needed** — just configure the model name
|
|
1134
|
+
|
|
1135
|
+
2. **Configure Environment**:
|
|
1136
|
+
```bash
|
|
1137
|
+
# Copy the local HuggingFace environment template
|
|
1138
|
+
cp huggingface-local.env .env
|
|
1139
|
+
```
|
|
1140
|
+
|
|
1141
|
+
3. **Run** — the model downloads automatically on first use:
|
|
1142
|
+
```bash
|
|
1143
|
+
atj translations/en.json -e huggingface-local -s en
|
|
1144
|
+
```
|
|
1145
|
+
First run downloads the model (~300 MB) and caches it locally. All subsequent runs are fully offline.
|
|
1146
|
+
|
|
1147
|
+
#### Quick Run Commands:
|
|
1148
|
+
```bash
|
|
1149
|
+
# Use the default local example model
|
|
1150
|
+
cp huggingface-local.env .env
|
|
1151
|
+
atj translations/en.json -e huggingface-local -s en
|
|
1152
|
+
|
|
1153
|
+
# Use another local translation model
|
|
1154
|
+
ATJ_HUGGING_FACE_LOCAL_MODEL=Xenova/opus-mt-en-de \
|
|
1155
|
+
atj translations/en.json -e huggingface-local -s en
|
|
1156
|
+
|
|
1157
|
+
# Use a larger multilingual local model
|
|
1158
|
+
ATJ_HUGGING_FACE_LOCAL_MODEL=Xenova/nllb-200-distilled-600M \
|
|
1159
|
+
atj translations/en.json -e huggingface-local -s en
|
|
1160
|
+
```
|
|
1161
|
+
|
|
1162
|
+
#### Recommended ONNX Models (from [huggingface.co/Xenova](https://huggingface.co/Xenova)):
|
|
1163
|
+
- **`Xenova/opus-mt-en-fr`** — English→French (~300 MB)
|
|
1164
|
+
- **`Xenova/opus-mt-en-de`** — English→German (~300 MB)
|
|
1165
|
+
- **`Xenova/opus-mt-en-es`** — English→Spanish (~300 MB)
|
|
1166
|
+
- **`Xenova/nllb-200-distilled-600M`** — 200+ languages, one model (~1.2 GB)
|
|
1167
|
+
|
|
1168
|
+
#### Pricing:
|
|
1169
|
+
- **Completely free**, forever — no account, no limits, no internet after first run
|
|
1170
|
+
|
|
1171
|
+
---
|
|
1172
|
+
|
|
904
1173
|
## Service Comparison
|
|
905
1174
|
|
|
906
1175
|
| Service | Quality | Speed | Cost | Languages | Best For |
|
|
@@ -911,6 +1180,8 @@ The library supports multiple translation services. Choose the one that best fit
|
|
|
911
1180
|
| **AWS** | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ | 75+ | AWS ecosystem |
|
|
912
1181
|
| **Azure** | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ | 90+ | Microsoft ecosystem |
|
|
913
1182
|
| **DeepL** | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐ | 30+ | Highest quality |
|
|
1183
|
+
| **HuggingFace** | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | 200+ | Free tier, many models |
|
|
1184
|
+
| **HuggingFace Local** | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | 200+ | Offline, private, free |
|
|
914
1185
|
|
|
915
1186
|
## Quick Start Examples
|
|
916
1187
|
|
|
@@ -982,6 +1253,8 @@ atj docs/en.yaml -e openai -s en --format yaml
|
|
|
982
1253
|
| **DeepL Pro** | `deepLPro` | DeepL Pro API (higher limits) | DeepL Pro API key |
|
|
983
1254
|
| **DeepL Free** | `deepLFree` | DeepL Free API (limited) | DeepL Free API key |
|
|
984
1255
|
| **OpenAI** | `openai` | GPT models for translation | OpenAI API key |
|
|
1256
|
+
| **Hugging Face Cloud** | `huggingface` | HF Inference API (Helsinki-NLP, NLLB…) | HF Access Token |
|
|
1257
|
+
| **Hugging Face Local** | `huggingface-local` | On-device ONNX inference, no internet | None |
|
|
985
1258
|
|
|
986
1259
|
### Environment Variables
|
|
987
1260
|
|
|
@@ -1033,6 +1306,35 @@ ATJ_OPEN_AI_MAX_TOKENS=512
|
|
|
1033
1306
|
ATJ_OPEN_AI_TEMPERATURE=0.3
|
|
1034
1307
|
```
|
|
1035
1308
|
|
|
1309
|
+
#### Hugging Face Cloud
|
|
1310
|
+
```bash
|
|
1311
|
+
# Requires a free HF token: https://huggingface.co/settings/tokens
|
|
1312
|
+
ATJ_HUGGING_FACE_API_KEY=your_huggingface_token_here
|
|
1313
|
+
# Optional explicit provider when model auto-selection does not work
|
|
1314
|
+
ATJ_HUGGING_FACE_PROVIDER=hf-inference
|
|
1315
|
+
# Model to use
|
|
1316
|
+
ATJ_HUGGING_FACE_MODEL=Helsinki-NLP/opus-mt-en-fr
|
|
1317
|
+
```
|
|
1318
|
+
|
|
1319
|
+
Run it with:
|
|
1320
|
+
|
|
1321
|
+
```bash
|
|
1322
|
+
atj translations/en.json -e huggingface -s en
|
|
1323
|
+
```
|
|
1324
|
+
|
|
1325
|
+
#### Hugging Face Local (no API key needed)
|
|
1326
|
+
```bash
|
|
1327
|
+
# ONNX model ID — downloaded and cached on first run (~300 MB)
|
|
1328
|
+
# Find models at: https://huggingface.co/Xenova
|
|
1329
|
+
ATJ_HUGGING_FACE_LOCAL_MODEL=Xenova/opus-mt-en-fr
|
|
1330
|
+
```
|
|
1331
|
+
|
|
1332
|
+
Run it with:
|
|
1333
|
+
|
|
1334
|
+
```bash
|
|
1335
|
+
atj translations/en.json -e huggingface-local -s en
|
|
1336
|
+
```
|
|
1337
|
+
|
|
1036
1338
|
#### Other Configuration
|
|
1037
1339
|
```bash
|
|
1038
1340
|
# Processing options
|
package/build/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auto-translate-json-library",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Automatically translates JSON language files to other languages using Google Translate,AWS,Azure,DeepL,OpenAI or local OpenAI compatible server",
|
|
5
|
+
"description": "Automatically translates JSON language files to other languages using Google Translate, AWS, Azure, DeepL, OpenAI, Hugging Face (cloud & local) or local OpenAI compatible server",
|
|
6
6
|
"main": "./build/src/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"auto-translate-json-library": "build/src/bin/cli.js",
|
|
@@ -10,15 +10,21 @@
|
|
|
10
10
|
},
|
|
11
11
|
"types": "./build/src/index.d.ts",
|
|
12
12
|
"files": [
|
|
13
|
-
"build",
|
|
14
|
-
"
|
|
13
|
+
"build/src",
|
|
14
|
+
"build/package.json",
|
|
15
|
+
"README.MD"
|
|
15
16
|
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
16
20
|
"scripts": {
|
|
17
21
|
"prepare": "tsc",
|
|
22
|
+
"prepack": "npm run build",
|
|
18
23
|
"build": "tsc",
|
|
19
24
|
"build:go": "tsgo --skipLibCheck",
|
|
20
25
|
"build:run": "ts-node ./build/src/index.js --pivotTranslation=./tests/translations/en.json",
|
|
21
26
|
"debug": "ts-node src/index.ts --pivotTranslation=./tests/translations/en.json",
|
|
27
|
+
"release:check": "npm test && npm pack --dry-run",
|
|
22
28
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
23
29
|
"test:watch": "jest --watch",
|
|
24
30
|
"test:coverage": "jest --coverage",
|
|
@@ -99,7 +105,13 @@
|
|
|
99
105
|
"automation",
|
|
100
106
|
"batch-translation",
|
|
101
107
|
"multi-format",
|
|
102
|
-
"gettext"
|
|
108
|
+
"gettext",
|
|
109
|
+
"huggingface",
|
|
110
|
+
"hugging-face",
|
|
111
|
+
"helsinki-nlp",
|
|
112
|
+
"nllb",
|
|
113
|
+
"transformers-js",
|
|
114
|
+
"local-translation"
|
|
103
115
|
],
|
|
104
116
|
"author": "codegrue",
|
|
105
117
|
"repository": {
|
|
@@ -116,36 +128,39 @@
|
|
|
116
128
|
],
|
|
117
129
|
"license": "MIT",
|
|
118
130
|
"devDependencies": {
|
|
119
|
-
"@biomejs/biome": "2.
|
|
120
|
-
"@topce/native-preview": "7.0.0-dev.
|
|
121
|
-
"@types/gettext-parser": "
|
|
131
|
+
"@biomejs/biome": "2.4.8",
|
|
132
|
+
"@topce/native-preview": "7.0.0-dev.20260215",
|
|
133
|
+
"@types/gettext-parser": "9.0.0",
|
|
122
134
|
"@types/jest": "30.0.0",
|
|
123
135
|
"@types/minimist": "1.2.5",
|
|
124
|
-
"@types/node": "25.0
|
|
136
|
+
"@types/node": "25.5.0",
|
|
125
137
|
"@types/properties-parser": "0.3.3",
|
|
126
138
|
"@types/yargs": "17.0.35",
|
|
127
|
-
"jest": "30.
|
|
139
|
+
"jest": "30.3.0",
|
|
128
140
|
"ts-jest": "29.4.6",
|
|
129
141
|
"ts-node": "10.9.2",
|
|
130
142
|
"typescript": "5.9.3"
|
|
131
143
|
},
|
|
132
144
|
"dependencies": {
|
|
133
|
-
"@aws-sdk/client-translate": "3.
|
|
145
|
+
"@aws-sdk/client-translate": "3.1014.0",
|
|
134
146
|
"@google-cloud/translate": "9.3.0",
|
|
147
|
+
"@huggingface/inference": "^4.13.15",
|
|
148
|
+
"@huggingface/transformers": "^3.8.1",
|
|
135
149
|
"@types/js-yaml": "4.0.9",
|
|
136
|
-
"axios": "1.13.
|
|
150
|
+
"axios": "1.13.6",
|
|
137
151
|
"csv-parser": "3.2.0",
|
|
138
152
|
"csv-writer": "1.6.0",
|
|
139
153
|
"deepl-node": "1.24.0",
|
|
140
|
-
"dotenv": "17.
|
|
141
|
-
"fast-xml-parser": "5.
|
|
154
|
+
"dotenv": "17.3.1",
|
|
155
|
+
"fast-xml-parser": "5.5.8",
|
|
142
156
|
"form-data": "4.0.5",
|
|
143
|
-
"gettext-parser": "9.0.
|
|
157
|
+
"gettext-parser": "9.0.2",
|
|
144
158
|
"js-yaml": "4.1.1",
|
|
145
159
|
"minimist": "1.2.8",
|
|
146
|
-
"openai": "6.
|
|
160
|
+
"openai": "6.32.0",
|
|
147
161
|
"picocolors": "1.1.1",
|
|
148
162
|
"properties-parser": "0.6.0",
|
|
163
|
+
"sharp": "^0.34.5",
|
|
149
164
|
"uuid": "13.0.0",
|
|
150
165
|
"yargs": "18.0.0"
|
|
151
166
|
}
|
package/build/src/bin/cli.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
export {};
|