GithubHelp home page GithubHelp logo

madeinshinea / json-deepl-translate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saigesp/json-translate

1.0 0.0 0.0 57 KB

Translate json files with deepl API

License: GNU Lesser General Public License v2.1

Python 100.00%

json-deepl-translate's Introduction

json-deepl-translate

Translate json files with deepl API

Usually multi-language projects developed with a javascript framework (Angular, Vue...) base their translations on json files with different nesting levels. This small project allows you to generate new files for other languages while keeping the same structure.

  • Works with Python3
python json_translate /path/to/file/en_US.json --locale es --output es_ES.json --indent 4 --sleep 0.5

See more options with python json_translate --help

Supported languages

You can check the supported languages at this link: DeepL Translate Text Request Parameters (parameters source_lang and target_lang)

Install

  1. Create virtual environment

  2. Install dependencies:

pip install -r requirements.txt
  1. Create an .env file with:
DEEPL_AUTH_KEY=your-key-here

You can get a free deepl developer account in https://www.deepl.com/pro-checkout/account (Credit card needed)

Usage

  1. Execute the command with the file path and the language you want to generate
python json_translate /home/user/my_project/locales/en_US.json --locale ES --output es_ES.json

The script will create an es_ES.json file in the same folder as the source file.

Optional parameters

-l, --locale    Language target to translate. Defaults to "en"
-o, --output    Output file name. Defaults to "en.json
-s, --sleep     Sleep time between API calls. Defaults to 0.01s
-i, --indent    Output file indentation spaces. Defaults to 2
--skip          Keys to skip (they won't be translated)

Example file

Translate the example file /tests/data/en_US.json to spanish:

python json_translate tests/data/en_US.json --locale ES --output es_ES.json --skip lorem ipsum

API usage

You can check your API usage with

curl -H "Authorization: DeepL-Auth-Key YOUR-API-KEY-HERE" https://api-free.deepl.com/v2/usage

Contributing

See the contributing guide for detailed instructions on how to get started.

Tests

Run tests with:

python -m unittest discover

License

This repository is available under GNU LESSER GENERAL PUBLIC LICENSE v2.1 (LGPL). See details.

json-deepl-translate's People

Contributors

saigesp avatar madeinshinea avatar juliusjacobitz avatar

Stargazers

 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.