leolabs / json-autotranslate

Translate a folder of JSON files containing translations into multiple languages.
MIT License
137 stars 40 forks source link

how can create al locales i18n folders? #68

Open johnfelipe opened 2 years ago

johnfelipe commented 2 years ago

i have en folder, and i need all languages options in locales folder...

johnfelipe commented 2 years ago
cd locales/
mkdir -p af sq ar eu bg be ca hr cs da nl eo et fo fi fr gl de el iw hu is Eskimo ga it ja ko lv lt mk mt no pl pt ro ru gd sr sr sk sl es sv tr uk

and next

root@ubuntu21:~/json-autotranslate/locales# npx json-autotranslate -i locales -s azure -c xxxxxxxxx,eastus -m i18next

An error has occurred:
ENOENT: no such file or directory, scandir '/root/json-autotranslate/locales/locales'
Error: ENOENT: no such file or directory, scandir '/root/json-autotranslate/locales/locales'
    at Object.readdirSync (node:fs:1405:3)
    at Object.exports.getAvailableLanguages (/root/json-autotranslate/node_modules/json-autotranslate/lib/util/file-system.js:38:31)
    at /root/json-autotranslate/node_modules/json-autotranslate/lib/index.js:122:56
    at step (/root/json-autotranslate/node_modules/json-autotranslate/lib/index.js:68:23)
    at Object.next (/root/json-autotranslate/node_modules/json-autotranslate/lib/index.js:49:53)
    at /root/json-autotranslate/node_modules/json-autotranslate/lib/index.js:43:71
    at new Promise (<anonymous>)
    at __awaiter (/root/json-autotranslate/node_modules/json-autotranslate/lib/index.js:39:12)
    at translate (/root/json-autotranslate/node_modules/json-autotranslate/lib/index.js:115:12)
    at Object.<anonymous> (/root/json-autotranslate/node_modules/json-autotranslate/lib/index.js:345:1)

how solve?

johnfelipe commented 2 years ago
root@ubuntu21:~/json-autotranslate# cd locales/
root@ubuntu21:~/json-autotranslate/locales# mkdir -p af sq ar eu bg be ca hr cs da nl eo et fo fi fr gl de el iw hu is Eskimo ga it ja ko lv lt mk mt no pl pt ro ru gd sr sr sk sl es sv tr uk
root@ubuntu21:~/json-autotranslate/locales# cd ..
root@ubuntu21:~/json-autotranslate# npx json-autotranslate -i locales -s azure -c xxxxxxxxxxx,eastus -m i18next
Found 44 target language(s):
-> Eskimo, af, ar, be, bg, ca, cs, da, de, el, eo, es, et, eu, fi, fo, fr, ga, gd, gl, hr, hu, is, it, iw, ja, ko, lt, lv, mk, mt, nl, no, pl, pt, ro, ru, sk, sl, sq, sr, sv, tr, uk

🏭 Loading source files...
├── admin.json (key-based)
├── common.json (key-based)
├── editor.json (key-based)
├── social.json (key-based)
├── user.json (key-based)
└── Done

✨ Initializing Azure...
└── Done

🔍 Looking for key-value inconsistencies in source files...
└── No inconsistencies found

🔍 Looking for invalid keys in source files...
└── No invalid keys found

🙈 Azure doesn't support Eskimo. Skipping this language.

💬 Translating strings from en to af...
├── Translating admin.json (0 changes from cache) (+330)
├── Translating common.json (0 changes from cache) (+62)
├── Translating editor.json (0 changes from cache) (+558)
├── Translating social.json (0 changes from cache) (+156)
├── Translating user.json (0 changes from cache) (+253)
└── All strings have been translated.

💬 Translating strings from en to ar...
├── Translating admin.json (0 changes from cache) (+330)
├── Translating common.json (0 changes from cache) (+62)
├── Translating editor.json (0 changes from cache) (+558)
├── Translating social.json (0 changes from cache) (+156)
├── Translating user.json (0 changes from cache) (+253)
└── All strings have been translated.

🙈 Azure doesn't support be. Skipping this language.

💬 Translating strings from en to bg...
├── Translating admin.json (0 changes from cache) (+330)
├── Translating common.json (0 changes from cache) (+62)
├── Translating editor.json (0 changes from cache) (+558)
├── Translating social.json (0 changes from cache) (+156)
├── Translating user.json (0 changes from cache) (+253)
└── All strings have been translated.

💬 Translating strings from en to ca...
├── Translating admin.json (0 changes from cache) (+330)
├── Translating common.json (0 changes from cache) (+62)
├── Translating editor.json (0 changes from cache) (+558)
├── Translating social.json (0 changes from cache) (+156)
├── Translating user.json (0 changes from cache) (+253)
└── All strings have been translated.

💬 Translating strings from en to cs...
├── Translating admin.json (0 changes from cache) (+330)
├── Translating common.json (0 changes from cache) (+62)
├── Translating editor.json (0 changes from cache) (+558)
├── Translating social.json (0 changes from cache) (+156)
├── Translating user.json (0 changes from cache) (+253)
└── All strings have been translated.

💬 Translating strings from en to da...
├── Translating admin.json (0 changes from cache) (+330)
├── Translating common.json (0 changes from cache) (+62)
├── Translating editor.json (0 changes from cache) (+558)
├── Translating social.json (0 changes from cache) (+156)
├── Translating user.json (0 changes from cache) (+253)
└── All strings have been translated.

💬 Translating strings from en to de...
├── Translating admin.json (0 changes from cache) (+330)
├── Translating common.json (0 changes from cache) (+62)
├── Translating editor.json (0 changes from cache) (+558)
├── Translating social.json (0 changes from cache) (+156)
├── Translating user.json (0 changes from cache) (+253)
└── All strings have been translated.

💬 Translating strings from en to el...
├── Translating admin.json (0 changes from cache) (+330)
├── Translating common.json (0 changes from cache) (+62)
├── Translating editor.json (0 changes from cache) (+558)
├── Translating social.json (0 changes from cache) (+156)
├── Translating user.json (0 changes from cache) (+253)
└── All strings have been translated.

🙈 Azure doesn't support eo. Skipping this language.

💬 Translating strings from en to es...
├── Translating admin.json (0 changes from cache) (+330)
├── Translating common.json (0 changes from cache) (+62)
├── Translating editor.json (0 changes from cache)
An error has occurred:
Azure Translation failed: {"error":{"code":429001,"message":"The server rejected the request because the client has exceeded request limits."}}
Error: Azure Translation failed: {"error":{"code":429001,"message":"The server rejected the request because the client has exceeded request limits."}}
    at AzureTranslator.<anonymous> (/root/json-autotranslate/node_modules/json-autotranslate/lib/services/azure-translator.js:128:35)
    at step (/root/json-autotranslate/node_modules/json-autotranslate/lib/services/azure-translator.js:33:23)
    at Object.next (/root/json-autotranslate/node_modules/json-autotranslate/lib/services/azure-translator.js:14:53)
    at fulfilled (/root/json-autotranslate/node_modules/json-autotranslate/lib/services/azure-translator.js:5:58)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

how prevent that exceed request limits?

leolabs commented 2 years ago

Currently, json-autotranslate doesn't have support for handling this, but you should be able to just run the command multiple times because it will skip the items you already translated :)