-
Notifications
You must be signed in to change notification settings - Fork 69
xliffmerge autotranslate feature
Starting with version 0.7.0 you can use xliffmerge to fully automatically translate all messages. For translation the Google Cloud Translation API is used.
Google Translate is not a free service. To use it, you need an account (first year for free) and you have to create an API Key.
Information about free usage of Google Cloud Platform can be found here: Google Cloud Platform FAQ.
The details to create an API KEY are described here: Create an API key for your Google Cloud Platform Console project.
The auto translate feature must be enabled explicitly by setting the value autotranslate
to true
in the config file xliffmerge.json
.
To be allowed to use the Google Cloud Translate API service, you also need a valid API KEY. There are 3 possibilities to configure:
- Set
apikey
in the configuration file (should be avoided because of the risk to reveal it). - Set
apikeyfile
in the configuration file pointing to a file that contains your api key. - Set ENV VAR
API_KEY_FILE
pointing to a file that contains your api key.
You should put your key into a file like googleTranslateApiKey.txt
.
Then add this file to .gitignore
to avoid publishing it by mistake.
Then set apikeyfile
to point to this file.
{ "xliffmergeOptions": { ... "autotranslate": true, "apikeyfile: "/users/me/.secrets/googleTranslateApiKey.txt", ... } }
Alternatively you can use the ENV VAR API_KEY_FILE
and do not configure it in the config file:
export API_KEY_FILE=/users/me/.secrets/googleTranslateApiKey.txt
If you don't want to autotranslate all your languages you can alternatively set autotranslate
to the list of languages you want to translate:
{ "xliffmergeOptions": { ... "autotranslate": ["fr", "ru"], ... } }
There is nothing else to do.
From now on whenever you run xliffmerge
it will detect all untranslated units in the language files and will translate them.
Of course, automatic translation is far away from perfection.
So every translated unit will get status translated
to show that there might be something to do.
Your translation tool (e.g. TinyTranslator) should have a chance to filter for that.
You can correct some non perfect translations manually then.