Translate the values in a JSON file, preserving the structure and keys. You need a deepl API key to use this program.
Create a file test.json
{
"foo" : {
"bar" : "Hello, world!"
}
}
Translate the file to French:
export KEY=YOUR-DEEPL-KEY
python -m venv .venv # Create a virtual env
source .venv/bin/activate # Activate the virtual env
(.venv) pip install -r requirements.txt # Install dependencies
(.venv) python translate.py test.json fr -k $KEY
Prints
{
"foo": {
"bar": "Bonjour à tous !"
}
}
The translation is printed to stdout. Use a redirection operator to print it to a file.
python translate.py test.json fr -k $KEY > test-fr.json