From ec56bd5a4a397e393d7b5726c3988fc0d38d7270 Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Thu, 25 May 2023 22:36:01 +0200 Subject: [PATCH] [tools] Updated translate script docs, added lt to Google Translate Signed-off-by: Alexander Borsuk --- docs/TRANSLATIONS.md | 23 ++++++++++++++++++++--- tools/unix/translate_categories.sh | 6 +++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docs/TRANSLATIONS.md b/docs/TRANSLATIONS.md index ec754987a7..e88fe47e6e 100644 --- a/docs/TRANSLATIONS.md +++ b/docs/TRANSLATIONS.md @@ -50,11 +50,28 @@ There are many more other options, e.g. print various translation statistics, va Check `tools/python/strings_utils.py -h` to see all of them. In some cases automatically translated strings are better than no translation at all. -There is a script to automate given string's translation into multiple languages. -Please [install Translate Shell](https://www.soimort.org/translate-shell/#installation) first to be able to run it. +There are two scripts to automate given string's translation into multiple languages. +Please [install Translate Shell](https://www.soimort.org/translate-shell/#installation) first to be able to run them. + +### DeepL + Google Translate fallback + +The first one uses free DeepL API where possible and provides a significantly better quality translations. +It requires registering a [DeepL account](https://www.deepl.com/pro#developer) and [getting API key](https://www.deepl.com/account/summary). +You may be asked for a credit card for verification, but it won't be charged. ```bash -# This generates translations in categories.txt format +export DEEPL_FREE_API_KEY= +# Generates translations in both categories.txt and strings.txt formats at the same time. +tools/python/translate.py English text to translate here +``` + +### Google Translate only + +The second one is not recommended, it uses Google API and sometimes translations are incorrect. +Also it does not support European Portuguese (pt or pt-PT), and always generates Brazil Portuguese. + +```bash +# Generates translations in categories.txt format tools/unix/translate_categories.sh "Route" # Translations in strings.txt format DELIM=" = " tools/unix/translate_categories.sh "Route" diff --git a/tools/unix/translate_categories.sh b/tools/unix/translate_categories.sh index 06c0017300..362412e47e 100755 --- a/tools/unix/translate_categories.sh +++ b/tools/unix/translate_categories.sh @@ -9,6 +9,10 @@ set -euo pipefail +echo "!!! This script is outdated, please use a better quality DeepL translations script" +echo "!!! tools/python/translate.py" +echo "" + DELIM=${DELIM:-:} case $# in @@ -27,7 +31,7 @@ esac # Note: default Google engine doesn't properly support European Portuguese (pt-PT) # and always produces Brazilian translations. Need to use Deepl. -LANGUAGES=( en ar be bg ca cs da de el es et eu fa 'fi' fr he hu id it ja ko mr nb nl pl pt pt-BR ro ru sk sv sw th tr uk vi zh-CN zh-TW ) +LANGUAGES=( en ar be bg ca cs da de el es et eu fa 'fi' fr he hu id it ja ko lt mr nb nl pl pt pt-BR ro ru sk sv sw th tr uk vi zh-CN zh-TW ) for lang in "${LANGUAGES[@]}"; do # -no-bidi fixes wrong characters order for RTL languages.