โจ Sponsored by fotogram.ai - Transform Your Selfies into Masterpieces with AI โจ
โจ https://fotogram.ai โจ
๐ AI / FREE JSON & YAML TRANSLATOR ๐
This package will provide you to translate your JSON/YAML files or JSON objects into different languages FREE.
Translation Module | Support | FREE |
---|---|---|
Google Translate | โ | โ
FREE |
Google Translate 2 | โ | โ
FREE |
Microsoft Bing Translate | โ | โ
FREE |
Libre Translate | โ | โ
FREE |
Argos Translate | โ | โ
FREE |
DeepL Translate | โ | require API KEY (DEEPL_API_KEY as env) optional API URL (DEEPL_API_URL as env) |
gpt-4o | โ | require API KEY (OPENAI_API_KEY as env) |
gpt-3.5-turbo | โ | require API KEY (OPENAI_API_KEY as env) |
gpt-4 | โ | require API KEY (OPENAI_API_KEY as env) |
gpt-4o-mini | โ | require API KEY (OPENAI_API_KEY as env) |
Translation Module | Support | FREE |
---|---|---|
Google Translate | โ | โ
FREE |
Google Translate 2 | โ | โ
FREE |
Microsoft Bing Translate | โ | โ
FREE |
Libre Translate | โ | โ
FREE |
Argos Translate | โ | โ
FREE |
DeepL Translate | โ | require API KEY (DEEPL_API_KEY as env) optional API URL (DEEPL_API_URL as env) |
gpt-4o | โ | require API KEY (OPENAI_API_KEY as env) |
gpt-3.5-turbo | โ | require API KEY (OPENAI_API_KEY as env) |
gpt-4 | โ | require API KEY (OPENAI_API_KEY as env) |
gpt-4o-mini | โ | require API KEY (OPENAI_API_KEY as env) |
Browser support will come soon...
npm i @parvineyvazov/json-translator
npm i -g @parvineyvazov/json-translator
jsontt <your/path/to/file.json>
or
jsontt <your/path/to/file.yaml/yml>
[path]
: Required JSON/YAML file path <your/path/to/file.json>
[path]
: optional proxy list txt file path <your/path/to/proxy_list.txt>
-V, --version output the version number
-m, --module <Module> specify translation module
-f, --from <Language> from language
-t, --to <Languages...> to translates
-n, --name <string> optional โต | output filename
-fb, --fallback <string> optional โต | fallback logic,
try other translation modules on fail | yes, no | default: no
-cl, --concurrencylimit <number> optional โต | set max concurrency limit
(higher faster, but easy to get banned) | default: 3
-h, --help display help for command
Translate a JSON file using Google Translate:
jsontt <your/path/to/file.json> --module google --from en --to ar fr zh-CN
jsontt <your/path/to/file.json> --module google --from en --to ar fr zh-CN --name myFiles
jsontt <your/path/to/file.json> --module google --from en --to ar fr zh-CN --name myFiles --fallback yes
jsontt <your/path/to/file.json> --module google --from en --to ar fr zh-CN --name myFiles --fallback yes --concurrencylimit 10
jsontt file.json
jsontt folder/file.json
jsontt "folder\file.json"
jsontt "C:\folder1\folder\en.json"
jsontt file.json proxy.txt
Result will be in the same folder as the original JSON/YAML file.
jsontt -h
jsontt --help
For JavaScript
const translator = require('@parvineyvazov/json-translator');
For TypeScript:
import * as translator from '@parvineyvazov/json-translator';
// Let`s translate `Home sweet home!` string from English to Chinese
const my_str = await translator.translateWord(
'Home sweet home!',
translator.languages.English,
translator.languages.Chinese_Simplified
);
// my_str: ๅฎถ๏ผ็่็ๅฎถ๏ผ
For JavaScript
const translator = require('@parvineyvazov/json-translator');
For TypeScript:
import * as translator from '@parvineyvazov/json-translator';
/*
Let`s translate our deep object from English to Spanish
*/
const en_lang: translator.translatedObject = {
login: {
title: 'Login {{name}}',
email: 'Please, enter your email',
failure: 'Failed',
},
homepage: {
welcoming: 'Welcome!',
title: 'Live long, live healthily!',
},
profile: {
edit_screen: {
edit: 'Edit your informations',
edit_age: 'Edit your age',
number_editor: [
{
title: 'Edit number 1',
button: 'Edit 1',
},
{
title: 'Edit number 2',
button: 'Edit 2',
},
],
},
},
};
/*
FOR JavaScript don`t use translator.translatedObject (No need to remark its type)
*/
let es_lang = await translator.translateObject(
en_lang,
translator.languages.English,
translator.languages.Spanish
);
/*
es_lang:
{
"login": {
"title": "Acceso {{name}}",
"email": "Por favor introduzca su correo electrรณnico",
"failure": "Fallida"
},
"homepage": {
"welcoming": "ยกBienvenidas!",
"title": "ยกVive mucho tiempo, vivo saludable!"
},
"profile": {
"edit_screen": {
"edit": "Edita tus informaciones",
"edit_age": "Editar tu edad",
"number_editor": [
{
"title": "Editar nรบmero 1",
"button": "Editar 1"
},
{
"title": "Editar nรบmero 2",
"button": "Editar 2"
}
]
}
}
}
*/
For JavaScript
const translator = require('@parvineyvazov/json-translator');
For TypeScript:
import * as translator from '@parvineyvazov/json-translator';
/*
Let`s translate our object from English to French, Georgian and Japanese in the same time:
*/
const en_lang: translator.translatedObject = {
login: {
title: 'Login',
email: 'Please, enter your email',
failure: 'Failed',
},
edit_screen: {
edit: 'Edit your informations',
number_editor: [
{
title: 'Edit number 1',
button: 'Edit 1',
},
],
},
};
/*
FOR JavaScript don`t use translator.translatedObject (No need to remark its type)
*/
const [french, georgian, japanese] = (await translator.translateObject(
en_lang,
translator.languages.Automatic,
[
translator.languages.French,
translator.languages.Georgian,
translator.languages.Japanese,
]
)) as Array<translator.translatedObject>; // FOR JAVASCRIPT YOU DO NOT NEED TO SPECIFY THE TYPE
/*
french:
{
"login": {
"title": "Connexion",
"email": "S'il vous plaรฎt, entrez votre email",
"failure": "Manquรฉe"
},
"edit_screen": {
"edit": "Modifier vos informations",
"number_editor": [
{
"title": "Modifier le numรฉro 1",
"button": "รditer 1"
}
]
}
}
georgian:
{
"login": {
"title": "แฒจแแกแแแ",
"email": "แแแฎแแแ, แจแแแงแแแแแ แแฅแแแแ แแ",
"failure": "แแชแแแแแแ"
},
"edit_screen": {
"edit": "แแฅแแแแ แแแคแแ แแแชแแแแ แ แแแแฅแขแแ แแแ",
"number_editor": [
{
"title": "แ แแแแฅแขแแ แแแแก แแแแแ แ 1",
"button": "แ แแแแฅแขแแ แแแ 1"
}
]
}
}
japanese:
{
"login": {
"title": "ใญใฐใคใณ",
"email": "ใใชใใฎใกใผใซใขใใฌในใๅ
ฅๅใใฆใใ ใใ",
"failure": "ๅคฑๆใใ"
},
"edit_screen": {
"edit": "ใใชใใฎๆ
ๅ ฑใ็ทจ้ใใพใ",
"number_editor": [
{
"title": "็ชๅท1ใ็ทจ้ใใพใ",
"button": "็ทจ้1ใ็ทจ้ใใพใ"
}
]
}
}
*/
For JavaScript
const translator = require('@parvineyvazov/json-translator');
For TypeScript:
import * as translator from '@parvineyvazov/json-translator';
/*
Let`s translate our json file into another language and save it into the same folder of en.json
*/
let path = 'C:/files/en.json'; // PATH OF YOUR JSON FILE (includes file name)
await translator.translateFile(path, translator.languages.English, [
translator.languages.German,
]);
โโ files
โโโ en.json
โโโ de.json
For JavaScript
const translator = require('@parvineyvazov/json-translator');
For TypeScript:
import * as translator from '@parvineyvazov/json-translator';
/*
Let`s translate our json file into multiple languages and save them into the same folder of en.json
*/
let path = 'C:/files/en.json'; // PATH OF YOUR JSON FILE (includes file name)
await translator.translateFile(path, translator.languages.English, [
translator.languages.Cebuano,
translator.languages.French,
translator.languages.German,
translator.languages.Hungarian,
translator.languages.Japanese,
]);
โโ files
โโโ en.json
โโโ ceb.json
โโโ fr.json
โโโ de.json
โโโ hu.json
โโโ ja.json
To ignore words on translation use {{word}}
OR {word}
style on your object.
{
"one": "Welcome {{name}}",
"two": "Welcome {name}",
"three": "I am {name} {{surname}}"
}
...translating to spanish
{
"one": "Bienvenido {{name}}",
"two": "Bienvenido {name}",
"three": "Soy {name} {{surname}}"
}
jsontt also ignores the URL
in the text which means sometimes translations ruin the URL in the given string while translating that string. It prevents such cases by ignoring URLs in the string while translating.
{
"text": "this is a puppy https://shorturl.at/lvPY5"
}
...translating to german
{
"text": "das ist ein welpe https://shorturl.at/lvPY5"
}
git clone https://github.com/mololab/json-translator.git
yarn
Show the magic:
Go to file src/cli/cli.ts
Go to file src/modules/functions.ts
Go to file src/core/json_object.ts
Go to file src/core/json_file.ts
Go to file src/core/ignorer.ts
Check CLI locally
For checking CLI locally we need to link
the package using npm
npm link
Or you can run the whole steps using make
make run-only-cli
Make sure your terminal has admin access while running these commands to prevent any access issues.
:heavy_check_mark: Translate a word | sentence
:heavy_check_mark: Translate JSON object
:heavy_check_mark: Translate deep JSON object
:heavy_check_mark: Multi language translate for JSON object
:heavy_check_mark: Translate JSON file
:heavy_check_mark: Translate deep JSON file
:heavy_check_mark: Multi language translate for JSON file
:heavy_check_mark: CLI support
:heavy_check_mark: Safe translation (Checking undefined, long, or empty values)
:heavy_check_mark: Queue support for big translations
:heavy_check_mark: Informing the user about the translation process (number of completed ones, the total number of lines and etc.)
:heavy_check_mark: Ignore value words in translation (such as ignore {{name}} OR {name} on translation)
:heavy_check_mark: Libre Translate option (CLI)
:heavy_check_mark: Argos Translate option (CLI)
:heavy_check_mark: Bing Translate option (CLI)
:heavy_check_mark: Ignore URL translation on given string
:heavy_check_mark: CLI options for languages & source selection
:heavy_check_mark: Define output file names on CLI (optional command for CLI)
:heavy_check_mark: YAML file Translate
:heavy_check_mark: Fallback Translation (try new module on fail)
:heavy_check_mark: Can set the concurrency limit manually
[ ] Libre Translate option (in code package)
[ ] Argos Translate option (in code package)
[ ] Bing Translate option (in code package)
[ ] Openrouter Translate module
[ ] Cohere Translate module
[ ] Anthropic/Claude Translate module
[ ] Together AI Translate module
[ ] llamacpp Translate module
[ ] Google Gemini API Translate module
[ ] Groq support - Full list as new Translate modules
:heavy_check_mark: ChatGPT support
[ ] Sync translation
[ ] Browser support
[ ] Translation Option for own LibreTranslate instance
[ ] Make "--" dynamically adjustable (placeholder of not translated ones).
@parvineyvazov/json-translator will be available under the MIT license.