mololab / json-translator Goto Github PK
View Code? Open in Web Editor NEWjsontt ๐ก - FREE simple CLI to translate your json files into other languages โ Check Readme โ
Home Page: https://mololab.org/jsontt/npm
License: MIT License
jsontt ๐ก - FREE simple CLI to translate your json files into other languages โ Check Readme โ
Home Page: https://mololab.org/jsontt/npm
License: MIT License
Hi! I would like to request a new feature which would take as input multiple file, or a repo and then recursively go through all the files and perform the translation.
something like:
jsontt .
or
jsontt ./folder/*
or
jsontt ./folder-x
Happy to help achieve this.
Hello, I'm trying to translate an object where the value is HTML generated by Tiptap editor.
It works more or less well when I have regular text. Problems start when I am trying to add an image - the script translates the image URL.
How can I ignore all URLs? Maybe regex or smth like this?
Hi, I want to give a different name to the output files, for example below, is this possible?
jsontt your/path/to/file.json --translator google --from en --to fr-my-custom-name.json
I'm trying to use json-translator with a JSON that shows that the process is done, but without any translations. So, I hope to get help with debugging, but I don't have experience with this kind of structure to run and debug the CLI.
Can anyone help me with a launch.json to run TypeScript watch while running it in VS Code for debugging?
Translation error happens while using Libre Translate, and Argos Translate.
I guess it is bc of the "Too Many Request" error from the server.
It outputted JSON files for my 8,000+ translations, but they are impartial.
English as input, French and Spanish as output.
For the French one, at one point, it stopped translating and everything thereafter is simply "--".
Note all the proper translations at the top, and then nothing for the rest of it:
It said it completed it though.
For the Spanish one, the entire file is all just "--". Zero translations.
am getting a bad request error after trying to convert a json to multiple langs
Hello,
I want to use the following script in my CI/CD and not use suffix in my file names :
jsontt ./locales/en.json --module google2 --from en --to ar fr es de it ru --fallback yes --concurrencylimit 10
but the prompt ask for the filename so the script won't continue without validate manually, and empty value doesn't work.
How can I execute this script without filename validation please ?
Thank you.
When I translating json object its not translating in cmd its showing for request body302 moved permanently and bad request
I'm try to launch the app from sources.
When running:
./bin/jsontt some-file.json
... app fails with the following error:
/home/dev/json-translator/dist/json-translator.cjs.development.js:1589
if (global.source === exports.Sources.LibreTranslate) {
^
TypeError: Cannot read properties of undefined (reading 'LibreTranslate')
at getLanguages (/home/dev/json-translator/dist/json-translator.cjs.development.js:1589:41)
at getFromChoices (/home/dev/json-translator/dist/json-translator.cjs.development.js:1293:34)
at getLanguageChoices (/home/dev/json-translator/dist/json-translator.cjs.development.js:1283:22)
at Object.<anonymous> (/home/dev/json-translator/dist/json-translator.cjs.development.js:1218:40)
at Module._compile (node:internal/modules/cjs/loader:1198:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
at Module.load (node:internal/modules/cjs/loader:1076:32)
at Function.Module._load (node:internal/modules/cjs/loader:911:12)
at Module.require (node:internal/modules/cjs/loader:1100:19)
at require (node:internal/modules/cjs/helpers:119:18)
at Object.<anonymous> (/home/dev/json-translator/dist/index.js:7:20)
at Module._compile (node:internal/modules/cjs/loader:1198:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
at Module.load (node:internal/modules/cjs/loader:1076:32)
at Function.Module._load (node:internal/modules/cjs/loader:911:12)
at Module.require (node:internal/modules/cjs/loader:1100:19)
Node.js v18.17.1
Hi there, thank you for your cool app. Is it possible to translate .JSONL files with it? I tried to make it, but get an error.
Hey there!
I use ngx-translate to represent translations and was wondering if there was a way to ignore interpolated values.
For example:
{
"app.welcome": "Welcome {{name}}",
}
Right now it translates both "Welcome" and "name" to the target language. The goal would be for it to only translate "welcome".
Data to be sent:
{
"data": {
"name": "heuristic Ratione quaerat consectetur magnam fugiat placeat",
"description": "<p>- Guarantee the product as in the real picture</p><p>- All products are the same as in the pictures.</p><p>- Guarantee that you won't be disappointed</p><p>- The product is made of good quality materials, meticulously sewn.</p><p>- Flexible balance with our feet.</p><p>- Products manufactured according to international standards, using grade A materials, are durable, not easily broken</p><p>- Goes with every outfit, every occasion.</p>",
"variants": [
{
"id": 67,
"price": 300,
"unit": "1 gram",
"stock": 999
}
]
},
"target": "th",
"source": "en"
}
With this dataset, the library goes into an infinite loop with the following error:
at C:\Users\blah\strapi\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:1340:47
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)Translation error: TypeError: Cannot assign to read only property '10' of string '{"name":"heuristic Ratione quaerat consectetur magnam fugiat placeat","description":"<p>- Guarantee the product as in the real picture</p><p>- All products are the same as in the pictures.</p><p>- Guarantee that you won't be disappointed</p><p>- The product is made of good quality materials, meticulously sewn.</p><p>- Flexible balance with our feet.</p><p>- Products manufactured according to international standards, using grade A materials, are durable, not easily broken</p><p>- Goes with every outfit, every occasion.</p>","variants":[{"id":67,"price":300,"unit":"1 gram","stock":999}]}'
How do I solve it? Thank you
Is it possible to set an API Key for Google instead of using its free endpoint?
{
"phone_number_logs": [
{
"event": "ASSIGN",
"area_code": "267",
"phone_number": "3086228",
"created_at": "2019-06-18T05:25:54.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "267",
"phone_number": "3086228",
"created_at": "2019-07-22T05:35:29.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "215",
"phone_number": "5838511",
"created_at": "2019-08-07T18:16:34.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "215",
"phone_number": "5838511",
"created_at": "2019-10-06T05:34:37.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "215",
"phone_number": "4477756",
"created_at": "2019-11-24T18:26:17.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "215",
"phone_number": "4477756",
"created_at": "2019-12-03T05:37:42.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "856",
"phone_number": "3387208",
"created_at": "2019-12-05T14:30:35.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "856",
"phone_number": "3387208",
"created_at": "2020-02-19T05:47:53.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "856",
"phone_number": "4850554",
"created_at": "2020-04-01T19:00:43.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "856",
"phone_number": "4850554",
"created_at": "2020-05-04T10:43:30.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "856",
"phone_number": "9003221",
"created_at": "2020-06-02T13:24:11.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "856",
"phone_number": "9003221",
"created_at": "2020-07-06T10:41:52.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "856",
"phone_number": "4389942",
"created_at": "2020-08-01T20:20:27.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "856",
"phone_number": "4389942",
"created_at": "2020-09-03T10:44:37.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "856",
"phone_number": "9005621",
"created_at": "2020-11-03T12:42:22.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "856",
"phone_number": "9005621",
"created_at": "2020-12-31T10:41:45.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "267",
"phone_number": "6824404",
"created_at": "2020-12-31T13:44:56.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "267",
"phone_number": "6824404",
"created_at": "2021-11-05T10:47:36.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "609",
"phone_number": "2835519",
"created_at": "2021-11-11T14:40:16.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "609",
"phone_number": "2835519",
"created_at": "2021-11-19T10:42:27.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "267",
"phone_number": "7664258",
"created_at": "2022-05-04T03:05:58.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "267",
"phone_number": "7664258",
"created_at": "2022-05-12T10:39:52.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "267",
"phone_number": "5295675",
"created_at": "2022-06-04T10:31:17.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "267",
"phone_number": "5295675",
"created_at": "2022-08-04T10:37:47.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "267",
"phone_number": "7410421",
"created_at": "2023-10-09T02:31:32.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "267",
"phone_number": "7410421",
"created_at": "2023-10-17T10:32:34.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "267",
"phone_number": "6592158",
"created_at": "2023-11-25T13:46:20.000+00:00"
},
{
"event": "UNASSIGN",
"area_code": "267",
"phone_number": "6592158",
"created_at": "2023-12-03T10:32:27.000+00:00"
},
{
"event": "ASSIGN",
"area_code": "267",
"phone_number": "8455109",
"created_at": "2023-12-09T19:57:05.000+00:00"
}
],
"phone_number": [
{
"area_code": "267",
"phone_number": "8455109"
}
]
jsontt ru.json --translator bing --from ru --to tt
[tt]: the Languages to translate into is not available
supported Languages: https://github.com/mololab/json-translator/blob/master/docs/LANGUAGES.md
Hi. I was trying to translate a certain json file from English to Korean but I have faced into a problem and it seems to it cannot translate in some sentence or a word. I have tried all three translators possible, and the problem was:
undefined:63
"quest.crystals.description":"This planet has a unique ecosystem with biomes comprised of hot temperatures permeated from large lava lakes at its core, to cooler
in JSON at position 10080ken
at JSON.parse ()
at _callee2$ (C:\Users\user\AppData\Roaming\npm\node_modules@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:1412:26)
at tryCatch (C:\Users\user\AppData\Roaming\npm\node_modules@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:116:40)
at Generator.invoke [as _invoke] (C:\Users\user\AppData\Roaming\npm\node_modules@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:347:22)
at Generator.next (C:\Users\user\AppData\Roaming\npm\node_modules@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:172:21)
at asyncGeneratorStep (C:\Users\user\AppData\Roaming\npm\node_modules@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:16:24)
at _next (C:\Users\user\AppData\Roaming\npm\node_modules@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:38:9)
is there anything I can do? Thank you.
Sorry this is my very first time to using github and issuing so if you need more infomation, just let me know.
When translating bigger JSON files, Google API response times get higher. I am planning to fix that issue by using the proxy.
(I would appreciate it if anybody can be a contributor to that problem.)
with example:
import * as translator from '@parvineyvazov/json-translator';
translator.translateWord('Home sweet home!', translator.languages.English, translator.languages.Chinese_Simplified).then((value) => {
console.log(value);
});
RangeError: Maximum call stack size exceeded
Exception in PromiseRejectCallback:
C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:327
reject(error);
^
RangeError: Maximum call stack size exceeded
C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:138
var record = tryCatch(innerFn, self, context);
^
RangeError: Maximum call stack size exceeded
at Generator.<anonymous> (C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:138:22)
at Generator.next (C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:82:21)
at asyncGeneratorStep (C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:324:24)
at _next (C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:343:9)
at C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:348:7
at new Promise (<anonymous>)
at C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:340:12
at plaintranslate (C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\src\core\core.ts:9:37)
at _callee$ (C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\src\core\core.ts:45:16)
at tryCatch (C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:57:17)
at Generator.<anonymous> (C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:138:22)
at Generator.next (C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:82:21)
at asyncGeneratorStep (C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:324:24)
at _next (C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:343:9)
at C:\Users\LiuJjiang\Desktop\a\node_modules\@parvineyvazov\json-translator\dist\json-translator.cjs.development.js:348:7
at new Promise (<anonymous>)
hello it would be great if this library add a GUI so anyone can (even non experianced people) can modify the jsons
witth gui
an i18n keys json manager
Could you please tell how to create jsontt CLI to use ?
Why does this have so many issues on what are seemingly simple words to translate?
I picked English as my source and Spanish/French as my destination languages.
It can't translate things like "Company Name" or even "Notifications", "Run", "Start Date", etc.
These aren't highly technical terms or anything ... is there something I'm missing or is this just a limitation?
The languages are not exported from the index file so when trying to get the languages from the translator instance, TypeScript won't find them.
Also, there are languages from google translate that are not listed in the supported languages, it would be awesome if you could update them.
Hello sir, i get this error
jsontt /files/en.json
'jsontt' is not recognized as an internal or external command,
operable program or batch file.
First I want to say you've done amazing work with the README/CLI/API. Really impressive stuff! Well documented, great code and fantastic features.
However there's some shortcomings.
When using the CLI it's pretty easy to get rate limited. blocked. I wasn't aware of this as it wasn't mentioned on the README. I tried to translate a faulty file, got rate limited and subsequently couldn't continue to use this amazing tool without finding a proxy list or VPN. Even after finding a working VPN I wasn't able to fully translate my file without hitting the rate limit leaving me with an incomplete JSON and not much in the way of options.
I'm wondering if it's possible to circumvent getting rate limited by adding a delay in between requests?
You could add a delay parameter that would accept milliseconds. I don't mind waiting longer for my translations if it means I don't have to mess around with finding proxy lists/vpns.
Example:
jsontt en.json -T google -f en -t es --delay 500
What are your thoughts about this?
source json files here:
https://github.com/KnowageLabs/Knowage-Server/tree/master/knowage-vue/src/i18n/en_US
pls help me to solve this
# jsontt knowage/messages.json
? From which language? English
? To which language | languages? (Can select more than one with space bar) Czech
, French, German
ยฐ Translating. Please wait. 27 of 6474 translated.
<--- Last few GCs --->
[2541:0x5ab56d0] 114407 ms: Mark-sweep 1808.2 (2079.1) -> 1782.2 (2063.7) MB, 222.3 / 0.2 ms (average mu = 0.373, current mu = 0.369) allocation failure scavenge might not succeed
[2541:0x5ab56d0] 114743 ms: Mark-sweep 1804.2 (2078.4) -> 1777.8 (2062.5) MB, 212.2 / 0.2 ms (average mu = 0.370, current mu = 0.368) allocation failure scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0xb09c10 node::Abort() [jsontt cli]
2: 0xa1c193 node::FatalError(char const*, char const*) [jsontt cli]
3: 0xcf8dbe v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [jsontt cli]
4: 0xcf9137 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [jsontt cli]
5: 0xeb09d5 [jsontt cli]
6: 0xeb14b6 [jsontt cli]
7: 0xebf9de [jsontt cli]
8: 0xec0420 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [jsontt cli]
9: 0xec339e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [jsontt cli]
10: 0xe848da v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [jsontt cli]
11: 0x11fd626 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [jsontt cli]
12: 0x15f2099 [jsontt cli]
Aborted (core dumped)
Is it possible to sync translation files?
Like if I were to add new values to en.json, could this library sync the new values with translations to the other files?
If not, regard this as a feature request.
Hi,
With Google and Bing, there are a lot of limitations and it's too slow. To avoid network issues with Libre Translate, is there an option to setup the IP/port of my own Libre Translate?
Best Regards,
LeChuck
This is a great project, I have personally experienced it, it helps me complete work faster than before, but today I want to give suggestions to the development team to add an undetectable feature. .ai into the project to convert all the json text translated by google or A.I in this tool to a more literal and understandable target language using the undetectable.ai feature? If it is added it will be easier for everyone to understand the translated content, thank you
Translation: Bing
CLI: Yes
Version: 1.6.3
It could have a delay for each request, if you have the option for the dev to put it would be great
BingTimeout: 8e3
GoogleTimeout: 5e3
...
o Translating. Please wait. 89 of 428 translated.Translation error: HTTPError: Response code 429 (Too Many Requests)
at Request.<anonymous> (C:\Users\lw\AppData\Roaming\nvm\v18.14.1\node_modules\@parvineyvazov\json-translator\node_modules\bing-translate-api\node_modules\got\dist\source\as-promise\index.js:118:42)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_NON_2XX_3XX_RESPONSE',
timings: {
start: 1678404337629,
socket: 1678404337629,
lookup: 1678404337629,
connect: 1678404337647,
secureConnect: 1678404337715,
upload: 1678404337715,
response: 1678404337878,
end: 1678404337879,
error: undefined,
abort: undefined,
phases: {
wait: 0,
dns: 0,
tcp: 18,
tls: 68,
request: 0,
firstByte: 163,
download: 1,
total: 250
}
}
}
Hi
Thanks for your translator. Does a way to translate only some key : value instead of the whole file ?
Thanks
How to avoid overwriting all fields? I just want to update missing or empty fields.
I come across this issue while translating en.json to any language. I have make ssl check off already using command, npm config set strict-ssl false.
Hi, firstly great work. I am trying to use sample usage 5 (multiple language) on js for a very simple short json. It gives me an error:
Translation error: TypeError: Cannot read properties of undefined (reading 'length') at _callee$ (translate/node_modules/@parvineyvazov/json-translator/dist/json-translator.cjs.development.js:513:36).
I fixed the issue by adding a ? to the given line
if (!(global.proxyList?.length > 0 && global.proxyIndex != -1)) {
.
But couldn't understand why global.proxylist is undefined. Any recommendations on how to proceed? Thanks
Wow! I'm really excited by this tool! It is amazing!
What do you think of idea to add more cli options like:
--from-lang=en
- to specify current language--target-langs=fr,cn
- to specify target languages--translator=google
- to specify translation serviceit would be nice that instead of -- when a string is untranslated to replace with original language string and not the "--"
Is it possible to add automatically ignoring null value?
error while translating "Best Sellers" using google. Assigned "--" instead of exit from cli.
Does anything other than the CLI actually work for this? Even that is broken and doesnt parse valid html.
"--translator" option does not actually set translation service, the default service always used.
Translating. Please wait.(node:78632) UnhandledPromiseRejectionWarning: RequestError: read ETIMEDOUT
at ClientRequest. (/Users/Eugene/node_modules/got/source/request-as-event-emitter.js:178:14)
at Object.onceWrapper (events.js:520:26)
at ClientRequest.emit (events.js:412:35)
at ClientRequest.origin.emit (/Users/Eugene/node_modules/@szmarczak/http-timer/source/index.js:37:11)
at TLSSocket.socketErrorListener (_http_client.js:475:9)
at TLSSocket.emit (events.js:400:28)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
(Use node --trace-warnings ...
to show where the warning was created)
(node:78632) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:78632) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.