DEV Community

Cover image for FREE! Translate your language JSON file to any languages.
Parvin Eyvazov
Parvin Eyvazov

Posted on • Updated on

FREE! Translate your language JSON file to any languages.

Hello everyone. It is my first time writing a post here. Please feel free to give any kind of feedback.

I created a package & CLI for translating JSON files and also objects (if you want to use it in the code) into different languages in an amazingly fast and FREE way. It uses Google Translate API for translation. Normally translate APIs are not FREE. But the json-translator is fully FREE to use. No need for any key configuration or something.
github.com/ParvinEyvazov/json-translator
(don't forget to leave a star⭐)
CLI usage

Language localization in both web and mobile applications is happening in the front-end generally. And in most cases, every language has a specific JSON file that contains all texts of an app. And according to the language that the user preferred, the app fetches specific text and shows it.

What was the problem?

When you want to add new language support to your application, you need to translate the whole of your values from your JSON file one by one and create a new JSON file to store them for this new language. And when you want to add multiple languages, it can become a nightmare for the person who will do this.

How does this package solve this problem?

By using json-translator, you don't need to create new files and translate the whole content manually. You just need to say the CLI that which language or languages that you want to add to your languages folder. And CLI will translate your whole content or values to these languages and create new files for them to store.


How to use it?

  • First, we need to install the package. (make sure Node is installed in your system) -g is for installing globally.
npm i -g @parvineyvazov/json-translator
Enter fullscreen mode Exit fullscreen mode

How to use CLI?

  • Run this command:
jsontt path/to/your/file.json
Enter fullscreen mode Exit fullscreen mode
  • Then select the language of your original JSON file. Also, you can select Automatic to detect your original language automatically.
  • Then select the languages that you want it to translate. You have to select them with a space bar.
  • BOOM! They are ready.

The result will be in the same folder as the original JSON file.

CLI usage

Also, this kind of usage is acceptable:

jsontt file.json
Enter fullscreen mode Exit fullscreen mode
jsontt folder/file.json
Enter fullscreen mode Exit fullscreen mode
jsontt "folder\file.json"
Enter fullscreen mode Exit fullscreen mode
jsontt "C:\folder1\folder\en.json"
Enter fullscreen mode Exit fullscreen mode

Supported languages

You can reach the supported languages from here.


What else?

You can also use json-translator as a package to translate your JSON objects and files in the code. But now, the package is not Browser compatible. You can use it only in node projects. For how to use in code, please read the official README file from here.

I hope this package will be helpful for your current and future projects to accelerate language processes.
Thanks for reading and have a wonderful day :)

Top comments (6)

Collapse
 
ilkeen profile image
Ilkin Mammadzada

It's way too easy to use. Thank, dude 💜

Collapse
 
cess11 profile image
PNS11

The fully free part means it is still constrained by the limits Google have in place regarding requests per unit of time, request size &c.

It's a wrapper around github.com/vitalets/google-transla... , which has support for proxies to circumvent such limits.

Collapse
 
datfake profile image
Dat Ngo

it's so helpful. Thanks

Collapse
 
oivoodoo profile image
Alexandr K

wonderful idea :)

Collapse
 
lamechehou97 profile image
Lameche

How i move inside git bash terminal i cant chose the language?

Collapse
 
parvineyvazov profile image
Parvin Eyvazov • Edited

Please, use "space" to choose "to" languages.