We are deprecating the API versions namely API v2 and v2.5, to make way for the more usable and maintainable API v3.
As of April 7th, 2022 the API versions 2 and 2.5 will no longer be operational and relevant requests will begin to fail.
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.
onlyreviewed2: the response will include the proofread strings and the rest (translated or not) will be returned empty.
Note: These three modes above only apply to the following file formats: Apple stringsdict, 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), YML (v=3).
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, XLIFF, 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.
In order to get a more detailed description about how each mode behaves for a particular file format, visit the links below depending on your file format.
- Android XML
- ChromeJSON (i18N)
- Apple StringsDict
- Github Mark-Down
- Adobe InDesign
- YAML Generic
- YAML Ruby on Rails
$ 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 Premium plan and up):
$ 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 Premium plan and up) and the source file should not be in XLIFF file format:
$ 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/
In case you want to upload an XLIFF translation file for an XLIFF source file then, the tag
file_type=xliff -F from the previous example should be omitted.
To delete all translations for a given language for a given resource use the following example:
curl -i -L --user api:token -X DELETE https://www.transifex.com/api/2/project/transifex/resource/core/translation/pt_BR/