Code Monkey home page Code Monkey logo

auto-translate-json's Introduction

Auto Translate JSON

Adds a menu item to JSON files to automatically translate them into other languages using Google Translate.

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 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 wallah, you have a version in French.

Features

  • Option to keep existing translations, to cut down on data processing when adding new terms
  • Option to keep extra translations, if one language has additional unique terms
  • Supports nested JSON elements
  • Supports named arguments such as: "Zip code {zip} is in {city}, {state}."
  • processes all files simultaneously
  • For a list of supported languages see https://cloud.google.com/translate/docs/languages

Requirements

Since translation services are not free, you must provide your own Google 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

Getting Started

  1. Request a Google Translate API key

  2. Install this extension

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

    settings

  4. Enter your Google API API key

  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

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

  • auto-translate-json.sourceLocale: A failsafe to prevent processing the wrong file. Defaults to "en" for english. You can change this to any valid two letter locale code you wish to use.
  • auto-translate-json.googleApiKey: Enter your Google API key in this setting.

Limitations

  • all files need to be in the same folder. This does not support structures where each language is in it's own subfolder.

auto-translate-json's People

Contributors

codegrue avatar dependabot[bot] avatar

Watchers

 avatar  avatar

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.