Git Product home page Git Product logo

mololab / json-translator Goto Github PK

View Code? Open in Web Editor NEW
416.0 10.0 48.0 9.06 MB

jsontt ๐Ÿ’ก - FREE simple CLI to translate your json files into other languages โœ… Check Readme โœŒ

Home Page: https://mololab.org/jsontt/npm

License: MIT License

TypeScript 99.22% Makefile 0.41% JavaScript 0.37%
json translate-api translate json-translate google-translate-api free-json-translate translation language typescript javascript i18n cli nodejs bing-translate

json-translator's Introduction

jsontt logo

๐Ÿš€ FREE JSON/YAML TRANSLATOR ๐Ÿ†“

npm downloads
version minified size minzipped size

This package will provide you to translate your JSON/YAML files or JSON objects into different languages FREE.

Types of usages ๐Ÿ‘€

  • CLI (Supports Google Translate, Google Translate 2 (Other way), Bing Microsoft Translate, Libre Translate, Argos Translate, DeepL Translate)

  • In code (Node.js) as a package (Supports only Google Translate)

Browser support will come soon...

Supported languages

โœ… Install

npm i @parvineyvazov/json-translator
  • OR you can install it globally (in case of using CLI)
npm i -g @parvineyvazov/json-translator

-----------------------------------------------------

1. ๐Ÿ’ซ CLI Usage

jsontt <your/path/to/file.json>
or
jsontt <your/path/to/file.yaml/yml>

How to use it? (video below)

IMAGE ALT TEXT HERE

Arguments

  • [path]: Required JSON/YAML file path <your/path/to/file.json>
  • [path]: optional proxy list txt file path <your/path/to/proxy_list.txt>

Options

  -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

Examples

Translate a JSON file using Google Translate:

jsontt <your/path/to/file.json> --module google --from en --to ar fr zh-CN
  • with output name
jsontt <your/path/to/file.json> --module google --from en --to ar fr zh-CN --name myFiles
  • with fallback logic (try other possible translation modules on fail)
jsontt <your/path/to/file.json> --module google --from en --to ar fr zh-CN --name myFiles --fallback yes
  • set concurrency limit (higher faster, but easy to get banned | default: 3)
jsontt <your/path/to/file.json> --module google --from en --to ar fr zh-CN --name myFiles --fallback yes --concurrencylimit 10

other usage examples

  • translate (json/yaml)
jsontt file.json
jsontt folder/file.json
jsontt "folder\file.json"
jsontt "C:\folder1\folder\en.json"
  • with proxy (only Google Translate module)
jsontt file.json proxy.txt

Result will be in the same folder as the original JSON/YAML file.


  • help
jsontt -h
jsontt --help

-----------------------------------------------------

2. ๐Ÿ’ฅ Package Usage

1. Translate a word | sentence

  • Import the library to your code.

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: ๅฎถ๏ผŒ็”œ่œœ็š„ๅฎถ๏ผ

2. Translate JSON object (supports deep objects)

  • Import the library to your code

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"
                    }
                  ]
                }
              }
            }
*/

3. Translate JSON object into Multiple languages (supports deep objects)

  • Import the library to your code

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ใ‚’็ทจ้›†ใ—ใพใ™"
      }
    ]
  }
}
*/

4. Translate JSON file (supports deep objects)

  • Import the library to your code.

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

5. Translate JSON file into Multiple languages (supports deep objects)

  • Import the library to your code.

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

6. Ignore words

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.

    • You don't especially need to do anything for it, it ignores them automatically.
{
  "text": "this is a puppy https://shorturl.at/lvPY5"
}

...translating to german

{
  "text": "das ist ein welpe https://shorturl.at/lvPY5"
}

-----------------------------------------------------

How to contribute?

  • Clone it
git clone https://github.com/mololab/json-translator.git
yarn
  • Show the magic:

    • Update CLI

      Go to file src/cli/cli.ts

    • Update translation

      Go to file src/modules/functions.ts

    • Update JSON operations(deep dive, send translation request)

      Go to file src/core/json_object.ts

    • Update JSON file read/write operations

      Go to file src/core/json_file.ts

    • Update ignoring values in translation (map/unmap)

      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.

-----------------------------------------------------

๐Ÿž Roadmap๐Ÿ

โœ”๏ธ Translate a word | sentence


  • for JSON objects

โœ”๏ธ Translate JSON object

โœ”๏ธ Translate deep JSON object

โœ”๏ธ Multi language translate for JSON object

  • Translate JSON object with extracting OR filtering some of its fields

  • for JSON files

โœ”๏ธ Translate JSON file

โœ”๏ธ Translate deep JSON file

โœ”๏ธ Multi language translate for JSON file

  • Translate JSON file with extracting OR filtering some of its fields

  • General

โœ”๏ธ CLI support

โœ”๏ธ Safe translation (Checking undefined, long, or empty values)

โœ”๏ธ Queue support for big translations

โœ”๏ธ Informing the user about the translation process (number of completed ones, the total number of lines and etc.)

โœ”๏ธ Ignore value words in translation (such as ignore {{name}} OR {name} on translation)

โœ”๏ธ Libre Translate option (CLI)

โœ”๏ธ Argos Translate option (CLI)

โœ”๏ธ Bing Translate option (CLI)

โœ”๏ธ Ignore URL translation on given string

โœ”๏ธ CLI options for langs & source selection

โœ”๏ธ Define output file names on cli (optional command for cli)

โœ”๏ธ YAML file Translate

โœ”๏ธ Fallback Translation (try new module on fail)

โœ”๏ธ Can set concurrency limit manually

  • Libre Translate option (in code package)

  • Argos Translate option (in code package)

  • Bing Translate option (in code package)

  • ChatGPT support

  • Sync translation

  • Browser support

  • Translation Option for own LibreTranslate instance

  • Make "--" dynamic adjustable (placeholder of not translated ones).

License

@parvineyvazov/json-translator will be available under the MIT license.

json-translator's People

Contributors

abolfazlakbarzadeh avatar fathiguemri avatar javix64 avatar myshkouski avatar parvineyvazov avatar rrmdn avatar samplayz2007 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

json-translator's Issues

27 of 6474 translated BUG issue

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)

Error While Translating: Assigned "--"

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?

image

Hello, I need suggestions for this project

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

Any way to ignore interpolated values

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".

Rate Limiting

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?

Set API Key

Is it possible to set an API Key for Google instead of using its free endpoint?

an error when translate words

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>)

TypeScript support

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.

'jsontt' is not recognized

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.

How to rename for output file?

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

At some point it just gives up?

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:

image

It said it completed it though.

image

For the Spanish one, the entire file is all just "--". Zero translations.

image

Sync translation files

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.

Slow translate on bigger JSON files

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.)

Too Many Requests

Hi, I have some issue using jsontt CLI, i have json with 5k char, and i want to translate into all language in this library (but for the screenshoot i only translate into afrikaans) , but it says Too Many Requests

how to solve this problem?
Screenshot from 2022-11-07 19-28-36

Debugging with VSCODE

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?

Add cli options for specify in/out language

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 service

translate only key : value

Hi

Thanks for your translator. Does a way to translate only some key : value instead of the whole file ?

Thanks

bad request error

am getting a bad request error after trying to convert a json to multiple langs

[FEATURE REQUEST] Translate recursively all files in a repo

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.

302 moved permanetly

When I translating json object its not translating in cmd its showing for request body302 moved permanently and bad request

Too many requests

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
    }
  }
}

App not working when built from sources

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

ID TypeError: Cannot assign to read only property '10' of string

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

Setup my own LibreTranslate instance

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

English to Korean translation problem

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.

Ignore urls in translation

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?

TypeError: Cannot read properties of undefined (reading 'length')

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

.JSONL files translating

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.

Problem with json

Hello, i love your package and i want to use it in my code, but when i try to translate a json i have these errors
image

Execute script without --name

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.

What is wrong?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.