The Translation files application handles CRUD operations for the translations of a specific resource in a specific project.
Return the requested translations in the given language (if it exists). The translation is returned as a serialized string (JSON format). If the GET parameter
file is specified, then the translations are downloaded in the corresponding file format.
Additionally, you can specify the mode of the downloaded file with the GET parameter mode. The available modes are:
default: to get a response that will include all translated strings in the response.
reviewed: to get a response that will include reviewed strings in the translation language. All other strings will either be empty or in the source language depending on the file format.
translator: to get a response suitable for use in translating offline.
Some file formats will take untranslated entries and fill them in with source strings. So if you use one of the modes mentioned above, you'll get a file where the untranslated strings won't be empty. There are several modes that you can use to bypass this:
onlytranslated: the response will include the translated strings and the untranslated ones will be returned empty.
onlyreviewed: the response will include the reviewed strings and the rest (translated or not) will be returned empty.
Note: These two modes above only apply to the following file formats: Apple strings, Chrome I18N, HTML, Java Properties, Joomla (ini), JSON Key-Value, Microsoft Word (alpha), Mozilla properties, Plain Text (txt), RequireJS format, and Windows JSON (resjson), GETTEXT (PO).
sourceastranslation: the response will include the translated strings and the untranslated ones will be filled with the corresponding source strings.
Note: This mode is only supported for the following formats: Android, KEYVALUEJSON, PO, Properties (Java Properties), QT, SRT, Stringsdict, and YML.
For all other file formats, use the mode
translator to get a file that leaves the untranslated entries empty. For some formats such as Java .properties, the downloaded file will have the source string in the comment so the translator can translate the file faster.
$ curl -i -L --user api:<token> -X GET "https://www.transifex.com/api/2/project/transifex/resource/core/translation/pt_BR/?mode=reviewed&file"
And to get translations in an XLIFF file, use the
file parameter and set it to
xliff (note that getting XLIFF files through the API is supported only on the Enterprise plan):
$ curl -i -L --user api:<token> -X GET "https://www.transifex.com/api/2/project/transifex/resource/core/translation/pt_BR/?file=xliff"
Create or update the translations for a specified language. Either the translation is JSON encoded or the request has multipart/form-encode as content type and the file is attached. If you're using JSON, the JSON data must be a dictionary with the key being the word "content" and the value being the content of the file.
When updating translations, either via the API or other ways, translators are only allowed to modify unreviewed strings and reviewers are allowed to modify both unreviewed and reviewed strings. If a translator tries to modify reviewed strings, the API call just skips those modifications and only updates the unreviewed phrases.
Also, note that in the case of file formats such as Gettext, where having an empty translation means the entity is untranslated, the importer skips those empty translations.
$ curl -i -L --user api:<token> -F file=@pt_BR/django.po -X PUT https://www.transifex.com/api/2/project/transifex/resource/core/translation/pt_BR/
To upload translations from an XLIFF file (note that uploading through the API is supported only on the Enterprise plan):
$ curl -i -L --user api:<token> -F file_type=xliff -F context=@/Users/christosmarkou/Downloads/core.xlf -X PUT https://www.transifex.com/api/2/project/transifex/resource/core/translation/pt_BR/