codegrue / auto-translate-json

Automatically translates JSON language files to other languages using Google Translate
https://marketplace.visualstudio.com/items?itemName=JeffJorczak.auto-translate-json
Other
32 stars 9 forks source link

Auto Translate JSON

Adds a menu item to JSON files to automatically translate them into other languages using Google Translate, Aws Translate, Azure Translate, DeepL or OpenAI.

How it works

demo

When localizing an application, if you have a folder called something like translations, languages, or i18n that contains JSON files for each language, you can use this extension to right click on your primary language file and automatically create additional translations. It uses the Google/AWS/Azure Translate API to perform the translations, and you must have your own API key to make the calls.

Just create empty files with the locale names as filenames and this extension will generate their translations. For example, if you want French, create a file fr.json. Right click on en.json, pick "Auto Translate JSON" and voilà, you have a version in French.

Features

Supported languages

Requirements

Since translation services are not free, you must provide your own API key.

For Google API key you need to provide just API key. Luckily Google gives a decent amount of translations in a trial period. Go here to set up your account and request a key: https://console.developers.google.com/apis/library/translate.googleapis.com

For AWS you need to provide your access key and secret key. Go here to set up your account and request an access key and secret key and region to use: https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/

For Azure you need to provide your subscription key and region. Go here to set up your account and request a subscription key: https://azure.microsoft.com/en-us/free/

For DeepL you need to provide your authentication API key. Go here to set up your account and request an API key:https://www.deepl.com/pro-api?cta=header-pro-api/

For OpenAI you need to provide just API key.Go here to set up your account and request a key: API key:https://platform.openai.com/

Getting Started

  1. Request a Google/AWS/Azure/DeepL/OpenAI Translate API key

  2. Install this extension

  3. Go to VSCode Settings>Extensions>Auto Translate JSON

    settings

  4. Enter your Google/AWS/Azure API key / access key / subscription key / region

  5. (optional) Change the Source Locale setting if you don't want English

  6. Create empty files for each locale you want to translate into. Locale should correspond to the language code used by the translation service. For example, if you want French, create a file fr.json.If you use Azure and want to translate into Serbian , create a file sr-Cyrl.json for Serbian Cyrillic translation or sr-Latn.json for Serbian Latin translation.If you use AWS or Google and want to translate into Serbian , create a file sr.json for Serbian translation.

    files

  7. Right click the source .json file (en.json by default) and pick "Auto Translate JSON"

  8. At the prompt decide if you want to preserve previously translated values (i.e. not reprocess)

    preserve-existing

  9. At the prompt decide if you want to keep extra translations

    keep-existing

  10. Verify your language files have been updated

Extension Settings

This extension contributes the following settings (Menu>Preferences>Settings):

Google

AWS

Azure

DeepL Free

DeepL Pro

Open AI

Open AI Local server

Mode

Start delimiter

End delimiter

Ignore prefix

Limitations

Prices

https://cloud.google.com/translate/pricing

https://aws.amazon.com/translate/pricing/

https://azure.microsoft.com/en-us/pricing/details/cognitive-services/translator/

https://www.deepl.com/pro?cta=header-prices

https://openai.com/pricing

WARNING

Keep your keys safe!