auto-translate-json-library 2.3.1 → 2.4.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.
@@ -1,171 +1,2 @@
1
1
  import { translate } from "./lib.js";
2
2
  export { translate };
3
- const config = {};
4
- setDefaultConfiguration();
5
- console.log(config);
6
- try {
7
- setConfigurationFromEnvironment();
8
- }
9
- catch (error) {
10
- console.log(config);
11
- console.log(error);
12
- }
13
- try {
14
- setConfigurationFromCLI();
15
- }
16
- catch (error) {
17
- console.log(config);
18
- console.log(error);
19
- }
20
- import { config as dotenvConfig } from "dotenv";
21
- import minimist from "minimist";
22
- function setConfigurationFromCLI() {
23
- const argv = minimist(process.argv.slice(2));
24
- if (argv === undefined) {
25
- console.log("No arguments provided in CLI");
26
- return;
27
- }
28
- if (argv.mode === "file") {
29
- config.mode = "file";
30
- }
31
- else if (argv.mode === "folder") {
32
- config.mode = "folder";
33
- }
34
- if (argv.startDelimiter !== undefined) {
35
- config.startDelimiter = argv.startDelimiter;
36
- }
37
- if (argv.endDelimiter !== undefined) {
38
- config.endDelimiter = argv.endDelimiter;
39
- }
40
- if (argv.keepExtraTranslations === "keep") {
41
- config.keepExtraTranslations = "keep";
42
- }
43
- else if (argv.keepExtraTranslations === "remove") {
44
- config.keepExtraTranslations = "remove";
45
- }
46
- if (argv.keepTranslations === "keep") {
47
- config.keepTranslations = "keep";
48
- }
49
- else if (argv.keepTranslations === "retranslate") {
50
- config.keepTranslations = "retranslate";
51
- }
52
- if (argv.sourceLocale !== undefined) {
53
- config.sourceLocale = argv.sourceLocale;
54
- }
55
- if (argv.ignorePrefix !== undefined) {
56
- config.ignorePrefix = argv.ignorePrefix;
57
- }
58
- if (argv.pivotTranslation !== undefined) {
59
- translate(argv.pivotTranslation, config);
60
- }
61
- else {
62
- console.log(argv);
63
- console.log("Please provide a pivot translation");
64
- }
65
- }
66
- function setDefaultConfiguration() {
67
- config.mode = "file";
68
- config.startDelimiter = "{";
69
- config.endDelimiter = "}";
70
- config.keepExtraTranslations = "keep";
71
- config.keepTranslations = "keep";
72
- config.sourceLocale = "en";
73
- config.ignorePrefix = "";
74
- }
75
- function setConfigurationFromEnvironment() {
76
- dotenvConfig();
77
- if (process.env.ATJ_GOOGLE_API_KEY) {
78
- config.translationKeyInfo = {
79
- kind: "google",
80
- apiKey: process.env.ATJ_GOOGLE_API_KEY,
81
- };
82
- }
83
- if (process.env.ATJ_AWS_ACCESS_KEY_ID &&
84
- process.env.ATJ_AWS_SECRET_ACCESS_KEY &&
85
- process.env.ATJ_AWS_REGION) {
86
- config.translationKeyInfo = {
87
- kind: "aws",
88
- accessKeyId: process.env.ATJ_AWS_ACCESS_KEY_ID,
89
- secretAccessKey: process.env.ATJ_AWS_SECRET_ACCESS_KEY,
90
- region: process.env.ATJ_AWS_REGION,
91
- };
92
- }
93
- if (process.env.ATJ_AZURE_SECRET_KEY && process.env.ATJ_AZURE_REGION) {
94
- config.translationKeyInfo = {
95
- kind: "azure",
96
- secretKey: process.env.ATJ_AZURE_SECRET_KEY,
97
- region: process.env.ATJ_AZURE_REGION,
98
- };
99
- }
100
- if (process.env.ATJ_DEEPL_PRO_SECRET_KEY) {
101
- config.translationKeyInfo = {
102
- kind: "deepLPro",
103
- secretKey: process.env.ATJ_DEEPL_PRO_SECRET_KEY,
104
- };
105
- }
106
- if (process.env.ATJ_DEEPL_FREE_SECRET_KEY) {
107
- config.translationKeyInfo = {
108
- kind: "deepLFree",
109
- secretKey: process.env.ATJ_DEEPL_FREE_SECRET_KEY,
110
- };
111
- }
112
- if (process.env.ATJ_OPEN_AI_SECRET_KEY) {
113
- config.translationKeyInfo = {
114
- kind: "openai",
115
- apiKey: process.env.ATJ_OPEN_AI_SECRET_KEY,
116
- baseUrl: process.env.ATJ_OPEN_AI_BASE_URL ?? "https://api.openai.com/v1",
117
- model: process.env.ATJ_OPEN_AI_MODEL ?? "gpt-3.5-turbo",
118
- maxTokens: Number(process.env.ATJ_OPEN_AI_MAX_TOKENS ?? "256"),
119
- temperature: Number(process.env.ATJ_OPEN_AI_TEMPERATURE ?? "0.7"),
120
- topP: Number(process.env.ATJ_OPEN_AI_TOP_P ?? "0.9"),
121
- n: Number(process.env.ATJ_OPEN_AI_N ?? "1"),
122
- frequencyPenalty: Number(process.env.ATJ_OPEN_AI_FREQUENCY_PENALTY ?? "0"),
123
- presencePenalty: Number(process.env.ATJ_OPEN_AI_PRESENCE_PENALTY ?? "0"),
124
- };
125
- }
126
- // Hugging Face cloud mode (requires API key)
127
- if (process.env.ATJ_HUGGING_FACE_API_KEY) {
128
- config.translationKeyInfo = {
129
- kind: "huggingface",
130
- apiKey: process.env.ATJ_HUGGING_FACE_API_KEY,
131
- model: process.env.ATJ_HUGGING_FACE_MODEL ?? "Helsinki-NLP/opus-mt-en-fr",
132
- provider: process.env.ATJ_HUGGING_FACE_PROVIDER,
133
- };
134
- }
135
- // Hugging Face local mode (no API key, ONNX on-device — takes priority)
136
- if (process.env.ATJ_HUGGING_FACE_LOCAL_MODEL) {
137
- config.translationKeyInfo = {
138
- kind: "huggingface-local",
139
- model: process.env.ATJ_HUGGING_FACE_LOCAL_MODEL,
140
- };
141
- }
142
- if (process.env.ATJ_START_DELIMITER) {
143
- config.startDelimiter = process.env.ATJ_START_DELIMITER;
144
- }
145
- if (process.env.ATJ_END_DELIMITER) {
146
- config.endDelimiter = process.env.ATJ_END_DELIMITER;
147
- }
148
- if (process.env.ATJ_END_DELIMITER) {
149
- config.endDelimiter = process.env.ATJ_END_DELIMITER;
150
- }
151
- if (process.env.ATJ_MODE &&
152
- (process.env.ATJ_MODE === "file" || process.env.ATJ_MODE === "folder")) {
153
- config.mode = process.env.ATJ_MODE;
154
- }
155
- if (process.env.ATJ_SOURCE_LOCALE) {
156
- config.sourceLocale = process.env.ATJ_SOURCE_LOCALE;
157
- }
158
- if (process.env.ATJ_KEEP_TRANSLATIONS &&
159
- (process.env.ATJ_KEEP_TRANSLATIONS === "keep" ||
160
- process.env.ATJ_KEEP_TRANSLATIONS === "retranslate")) {
161
- config.keepTranslations = process.env.ATJ_KEEP_TRANSLATIONS;
162
- }
163
- if (process.env.ATJ_KEEP_EXTRA_TRANSLATIONS &&
164
- (process.env.ATJ_KEEP_EXTRA_TRANSLATIONS === "keep" ||
165
- process.env.ATJ_KEEP_EXTRA_TRANSLATIONS === "remove")) {
166
- config.keepExtraTranslations = process.env.ATJ_KEEP_EXTRA_TRANSLATIONS;
167
- }
168
- if (process.env.ATJ_IGNORE_PREFIX && process.env.ATJ_IGNORE_PREFIX !== "") {
169
- config.ignorePrefix = process.env.ATJ_IGNORE_PREFIX;
170
- }
171
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-translate-json-library",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "type": "module",
5
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",
@@ -11,29 +11,39 @@
11
11
  "types": "./build/src/index.d.ts",
12
12
  "files": [
13
13
  "build/src",
14
- "build/package.json",
15
- "README.MD"
14
+ "README.MD",
15
+ "CHANGELOG.md",
16
+ "LICENSE"
16
17
  ],
18
+ "engines": {
19
+ "node": ">=22.0.0"
20
+ },
21
+ "homepage": "https://github.com/topce/auto-translate-json-library#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/topce/auto-translate-json-library/issues"
24
+ },
17
25
  "publishConfig": {
18
26
  "access": "public"
19
27
  },
20
28
  "scripts": {
21
- "prepare": "tsc",
29
+ "prepare": "npm run build",
22
30
  "prepack": "npm run build",
23
- "build": "tsc",
24
- "build:go": "tsgo --skipLibCheck",
25
- "build:run": "ts-node ./build/src/index.js --pivotTranslation=./tests/translations/en.json",
26
- "debug": "ts-node src/index.ts --pivotTranslation=./tests/translations/en.json",
27
- "release:check": "npm test && npm pack --dry-run",
31
+ "clean": "node -e \"require('node:fs').rmSync('build',{recursive:true,force:true})\"",
32
+ "build": "npm run clean && tsc",
33
+ "build:run": "node ./build/src/bin/cli.js --pivotTranslation=./tests/translations/en.json",
34
+ "debug": "npm run build && node ./build/src/bin/cli.js --pivotTranslation=./tests/translations/en.json",
35
+ "release:check": "npm run lint && npm run build && npm test && npm pack --dry-run",
36
+ "prepublishOnly": "npm run build && npm test",
37
+ "pretest": "npm run build",
28
38
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
29
- "test:watch": "jest --watch",
30
- "test:coverage": "jest --coverage",
39
+ "test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
40
+ "test:coverage": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
31
41
  "lint": "biome check ./src --max-diagnostics 1000",
32
42
  "lint-fix": "biome check ./src --write",
33
43
  "lint-fix-all": "biome check --write --unsafe ./src",
34
44
  "format": "biome format ./src",
35
45
  "format-fix": "biome format ./src --write",
36
- "start": "ts-node src/index.ts"
46
+ "start": "node ./build/src/bin/cli.js"
37
47
  },
38
48
  "keywords": [
39
49
  "translate",
@@ -128,40 +138,42 @@
128
138
  ],
129
139
  "license": "MIT",
130
140
  "devDependencies": {
131
- "@biomejs/biome": "2.5.6",
132
- "@topce/native-preview": "7.0.3",
141
+ "@biomejs/biome": "2.6.9",
142
+ "@swc/core": "1.16.22",
143
+ "@swc/jest": "0.2.39",
133
144
  "@types/gettext-parser": "9.0.0",
134
145
  "@types/jest": "30.0.0",
135
146
  "@types/minimist": "1.2.5",
136
- "@types/node": "26.1.2",
147
+ "@types/node": "26.6.11",
137
148
  "@types/properties-parser": "0.3.3",
138
149
  "@types/yargs": "17.0.35",
139
- "jest": "30.4.2",
140
- "ts-jest": "29.4.12",
141
- "ts-node": "10.9.2",
142
- "typescript": "6.0.3"
150
+ "jest": "30.5.2",
151
+ "typescript": "7.0.2"
143
152
  },
144
153
  "dependencies": {
145
- "@aws-sdk/client-translate": "3.1100.0",
146
- "@google-cloud/translate": "9.4.2",
147
- "@huggingface/inference": "^4.13.24",
148
- "@huggingface/transformers": "^4.2.0",
149
- "@types/js-yaml": "4.0.9",
150
- "axios": "1.19.0",
154
+ "@aws-sdk/client-translate": "3.1179.0",
155
+ "@google-cloud/translate": "10.3.0",
156
+ "@huggingface/inference": "^4.13.33",
157
+ "@huggingface/transformers": "^4.3.2",
158
+ "axios": "1.21.1",
151
159
  "csv-parser": "3.2.1",
152
160
  "csv-writer": "1.6.0",
153
- "deepl-node": "1.27.0",
154
- "dotenv": "17.4.2",
155
- "fast-xml-parser": "5.10.1",
161
+ "deepl-node": "2.0.0",
162
+ "dotenv": "18.0.10",
163
+ "fast-xml-parser": "5.12.1",
156
164
  "form-data": "4.0.6",
157
- "gettext-parser": "9.1.1",
158
- "js-yaml": "4.3.1",
165
+ "gettext-parser": "10.0.0",
166
+ "js-yaml": "5.5.0",
159
167
  "minimist": "1.2.8",
160
- "openai": "7.3.0",
168
+ "openai": "7.65.0",
161
169
  "picocolors": "1.1.1",
162
170
  "properties-parser": "0.6.0",
163
- "sharp": "^0.35.3",
164
- "uuid": "14.0.1",
165
- "yargs": "18.1.0"
171
+ "sharp": "^0.35.6",
172
+ "uuid": "14.0.3",
173
+ "yargs": "18.2.0"
174
+ },
175
+ "overrides": {
176
+ "glob": "^14.0.6",
177
+ "minimatch": "^11.0.9"
166
178
  }
167
179
  }
@@ -1,167 +0,0 @@
1
- {
2
- "name": "auto-translate-json-library",
3
- "version": "2.3.1",
4
- "type": "module",
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
- "main": "./build/src/index.js",
7
- "bin": {
8
- "auto-translate-json-library": "./build/src/bin/cli.js",
9
- "atj": "./build/src/bin/cli.js"
10
- },
11
- "types": "./build/src/index.d.ts",
12
- "files": [
13
- "build/src",
14
- "build/package.json",
15
- "README.MD"
16
- ],
17
- "publishConfig": {
18
- "access": "public"
19
- },
20
- "scripts": {
21
- "prepare": "tsc",
22
- "prepack": "npm run build",
23
- "build": "tsc",
24
- "build:go": "tsgo --skipLibCheck",
25
- "build:run": "ts-node ./build/src/index.js --pivotTranslation=./tests/translations/en.json",
26
- "debug": "ts-node src/index.ts --pivotTranslation=./tests/translations/en.json",
27
- "release:check": "npm test && npm pack --dry-run",
28
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
29
- "test:watch": "jest --watch",
30
- "test:coverage": "jest --coverage",
31
- "lint": "biome check ./src --max-diagnostics 1000",
32
- "lint-fix": "biome check ./src --write",
33
- "lint-fix-all": "biome check --write --unsafe ./src",
34
- "format": "biome format ./src",
35
- "format-fix": "biome format ./src --write",
36
- "start": "ts-node src/index.ts"
37
- },
38
- "keywords": [
39
- "translate",
40
- "translation",
41
- "i18n",
42
- "internationalization",
43
- "localization",
44
- "language",
45
- "json",
46
- "xml",
47
- "yaml",
48
- "yml",
49
- "properties",
50
- "csv",
51
- "tsv",
52
- "arb",
53
- "po",
54
- "pot",
55
- "xliff",
56
- "xlf",
57
- "xmb",
58
- "xtb",
59
- "android-xml",
60
- "ios-xml",
61
- "flutter",
62
- "angular",
63
- "ngx-translate",
64
- "transloco",
65
- "auto-translate-json",
66
- "google-translate",
67
- "aws-translate",
68
- "azure-translator",
69
- "deepl",
70
- "deepl-pro",
71
- "deepl-free",
72
- "openai",
73
- "gpt-4",
74
- "gpt-4.1-mini",
75
- "deepseek",
76
- "ollama",
77
- "qwen2.5",
78
- "gemma2",
79
- "llama3.1",
80
- "local-ai",
81
- "openai-compatible",
82
- "jan",
83
- "jan-ai",
84
- "lm-studio",
85
- "lmstudio",
86
- "text-generation-webui",
87
- "oobabooga",
88
- "vllm",
89
- "llamacpp",
90
- "llama-cpp",
91
- "koboldai",
92
- "kobold",
93
- "localai",
94
- "fastchat",
95
- "xinference",
96
- "mlx",
97
- "mlx-lm",
98
- "candle",
99
- "ctransformers",
100
- "exllama",
101
- "exllamav2",
102
- "gpt4all",
103
- "cli",
104
- "command-line",
105
- "automation",
106
- "batch-translation",
107
- "multi-format",
108
- "gettext",
109
- "huggingface",
110
- "hugging-face",
111
- "helsinki-nlp",
112
- "nllb",
113
- "transformers-js",
114
- "local-translation"
115
- ],
116
- "author": "codegrue",
117
- "repository": {
118
- "type": "git",
119
- "url": "git+https://github.com/topce/auto-translate-json-library.git"
120
- },
121
- "contributors": [
122
- "codegrue",
123
- "gajo357",
124
- "topce",
125
- "BenGMiles",
126
- "stonega",
127
- "alexei-petru"
128
- ],
129
- "license": "MIT",
130
- "devDependencies": {
131
- "@biomejs/biome": "2.5.6",
132
- "@topce/native-preview": "7.0.3",
133
- "@types/gettext-parser": "9.0.0",
134
- "@types/jest": "30.0.0",
135
- "@types/minimist": "1.2.5",
136
- "@types/node": "26.1.2",
137
- "@types/properties-parser": "0.3.3",
138
- "@types/yargs": "17.0.35",
139
- "jest": "30.4.2",
140
- "ts-jest": "29.4.12",
141
- "ts-node": "10.9.2",
142
- "typescript": "6.0.3"
143
- },
144
- "dependencies": {
145
- "@aws-sdk/client-translate": "3.1100.0",
146
- "@google-cloud/translate": "9.4.2",
147
- "@huggingface/inference": "^4.13.24",
148
- "@huggingface/transformers": "^4.2.0",
149
- "@types/js-yaml": "4.0.9",
150
- "axios": "1.19.0",
151
- "csv-parser": "3.2.1",
152
- "csv-writer": "1.6.0",
153
- "deepl-node": "1.27.0",
154
- "dotenv": "17.4.2",
155
- "fast-xml-parser": "5.10.1",
156
- "form-data": "4.0.6",
157
- "gettext-parser": "9.1.1",
158
- "js-yaml": "4.3.1",
159
- "minimist": "1.2.8",
160
- "openai": "7.3.0",
161
- "picocolors": "1.1.1",
162
- "properties-parser": "0.6.0",
163
- "sharp": "^0.35.3",
164
- "uuid": "14.0.1",
165
- "yargs": "18.1.0"
166
- }
167
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,170 +0,0 @@
1
- import { config as dotenvConfig } from "dotenv";
2
- import minimist from "minimist";
3
- import { translate } from "./lib.js";
4
- const config = {};
5
- setDefaultConfiguration();
6
- console.log(config);
7
- try {
8
- setConfigurationFromEnvironment();
9
- }
10
- catch (error) {
11
- console.log(config);
12
- console.log(error);
13
- }
14
- try {
15
- setConfigurationFromCLI();
16
- }
17
- catch (error) {
18
- console.log(config);
19
- console.log(error);
20
- }
21
- function setConfigurationFromCLI() {
22
- const argv = minimist(process.argv.slice(2));
23
- if (argv === undefined) {
24
- console.log("No arguments provided in CLI");
25
- return;
26
- }
27
- if (argv.mode === "file") {
28
- config.mode = "file";
29
- }
30
- else if (argv.mode === "folder") {
31
- config.mode = "folder";
32
- }
33
- if (argv.startDelimiter !== undefined) {
34
- config.startDelimiter = argv.startDelimiter;
35
- }
36
- if (argv.endDelimiter !== undefined) {
37
- config.endDelimiter = argv.endDelimiter;
38
- }
39
- if (argv.keepExtraTranslations === "keep") {
40
- config.keepExtraTranslations = "keep";
41
- }
42
- else if (argv.keepExtraTranslations === "remove") {
43
- config.keepExtraTranslations = "remove";
44
- }
45
- if (argv.keepTranslations === "keep") {
46
- config.keepTranslations = "keep";
47
- }
48
- else if (argv.keepTranslations === "retranslate") {
49
- config.keepTranslations = "retranslate";
50
- }
51
- if (argv.sourceLocale !== undefined) {
52
- config.sourceLocale = argv.sourceLocale;
53
- }
54
- if (argv.ignorePrefix !== undefined) {
55
- config.ignorePrefix = argv.ignorePrefix;
56
- }
57
- if (argv.pivotTranslation !== undefined) {
58
- translate(argv.pivotTranslation, config);
59
- }
60
- else {
61
- console.log(argv);
62
- console.log("Please provide a pivot translation");
63
- }
64
- }
65
- function setDefaultConfiguration() {
66
- config.mode = "file";
67
- config.startDelimiter = "{";
68
- config.endDelimiter = "}";
69
- config.keepExtraTranslations = "keep";
70
- config.keepTranslations = "keep";
71
- config.sourceLocale = "en";
72
- config.ignorePrefix = "";
73
- }
74
- function setConfigurationFromEnvironment() {
75
- dotenvConfig();
76
- if (process.env.ATJ_GOOGLE_API_KEY) {
77
- config.translationKeyInfo = {
78
- kind: "google",
79
- apiKey: process.env.ATJ_GOOGLE_API_KEY,
80
- };
81
- }
82
- if (process.env.ATJ_AWS_ACCESS_KEY_ID &&
83
- process.env.ATJ_AWS_SECRET_ACCESS_KEY &&
84
- process.env.ATJ_AWS_REGION) {
85
- config.translationKeyInfo = {
86
- kind: "aws",
87
- accessKeyId: process.env.ATJ_AWS_ACCESS_KEY_ID,
88
- secretAccessKey: process.env.ATJ_AWS_SECRET_ACCESS_KEY,
89
- region: process.env.ATJ_AWS_REGION,
90
- };
91
- }
92
- if (process.env.ATJ_AZURE_SECRET_KEY && process.env.ATJ_AZURE_REGION) {
93
- config.translationKeyInfo = {
94
- kind: "azure",
95
- secretKey: process.env.ATJ_AZURE_SECRET_KEY,
96
- region: process.env.ATJ_AZURE_REGION,
97
- };
98
- }
99
- if (process.env.ATJ_DEEPL_PRO_SECRET_KEY) {
100
- config.translationKeyInfo = {
101
- kind: "deepLPro",
102
- secretKey: process.env.ATJ_DEEPL_PRO_SECRET_KEY,
103
- };
104
- }
105
- if (process.env.ATJ_DEEPL_FREE_SECRET_KEY) {
106
- config.translationKeyInfo = {
107
- kind: "deepLFree",
108
- secretKey: process.env.ATJ_DEEPL_FREE_SECRET_KEY,
109
- };
110
- }
111
- if (process.env.ATJ_OPEN_AI_SECRET_KEY) {
112
- config.translationKeyInfo = {
113
- kind: "openai",
114
- apiKey: process.env.ATJ_OPEN_AI_SECRET_KEY,
115
- baseUrl: process.env.ATJ_OPEN_AI_BASE_URL ?? "https://api.openai.com/v1",
116
- model: process.env.ATJ_OPEN_AI_MODEL ?? "gpt-3.5-turbo",
117
- maxTokens: Number(process.env.ATJ_OPEN_AI_MAX_TOKENS ?? "256"),
118
- temperature: Number(process.env.ATJ_OPEN_AI_TEMPERATURE ?? "0.7"),
119
- topP: Number(process.env.ATJ_OPEN_AI_TOP_P ?? "0.9"),
120
- n: Number(process.env.ATJ_OPEN_AI_N ?? "1"),
121
- frequencyPenalty: Number(process.env.ATJ_OPEN_AI_FREQUENCY_PENALTY ?? "0"),
122
- presencePenalty: Number(process.env.ATJ_OPEN_AI_PRESENCE_PENALTY ?? "0"),
123
- };
124
- }
125
- // Hugging Face cloud mode (requires API key)
126
- if (process.env.ATJ_HUGGING_FACE_API_KEY) {
127
- config.translationKeyInfo = {
128
- kind: "huggingface",
129
- apiKey: process.env.ATJ_HUGGING_FACE_API_KEY,
130
- model: process.env.ATJ_HUGGING_FACE_MODEL ?? "Helsinki-NLP/opus-mt-en-fr",
131
- provider: process.env.ATJ_HUGGING_FACE_PROVIDER,
132
- };
133
- }
134
- // Hugging Face local mode (no API key, ONNX on-device — takes priority)
135
- if (process.env.ATJ_HUGGING_FACE_LOCAL_MODEL) {
136
- config.translationKeyInfo = {
137
- kind: "huggingface-local",
138
- model: process.env.ATJ_HUGGING_FACE_LOCAL_MODEL,
139
- };
140
- }
141
- if (process.env.ATJ_START_DELIMITER) {
142
- config.startDelimiter = process.env.ATJ_START_DELIMITER;
143
- }
144
- if (process.env.ATJ_END_DELIMITER) {
145
- config.endDelimiter = process.env.ATJ_END_DELIMITER;
146
- }
147
- if (process.env.ATJ_END_DELIMITER) {
148
- config.endDelimiter = process.env.ATJ_END_DELIMITER;
149
- }
150
- if (process.env.ATJ_MODE &&
151
- (process.env.ATJ_MODE === "file" || process.env.ATJ_MODE === "folder")) {
152
- config.mode = process.env.ATJ_MODE;
153
- }
154
- if (process.env.ATJ_SOURCE_LOCALE) {
155
- config.sourceLocale = process.env.ATJ_SOURCE_LOCALE;
156
- }
157
- if (process.env.ATJ_KEEP_TRANSLATIONS &&
158
- (process.env.ATJ_KEEP_TRANSLATIONS === "keep" ||
159
- process.env.ATJ_KEEP_TRANSLATIONS === "retranslate")) {
160
- config.keepTranslations = process.env.ATJ_KEEP_TRANSLATIONS;
161
- }
162
- if (process.env.ATJ_KEEP_EXTRA_TRANSLATIONS &&
163
- (process.env.ATJ_KEEP_EXTRA_TRANSLATIONS === "keep" ||
164
- process.env.ATJ_KEEP_EXTRA_TRANSLATIONS === "remove")) {
165
- config.keepExtraTranslations = process.env.ATJ_KEEP_EXTRA_TRANSLATIONS;
166
- }
167
- if (process.env.ATJ_IGNORE_PREFIX && process.env.ATJ_IGNORE_PREFIX !== "") {
168
- config.ignorePrefix = process.env.ATJ_IGNORE_PREFIX;
169
- }
170
- }