Transifex

  • Documentation
  • API
  • Resource Strings

Resource Strings

The Resource Strings endpoint lets you retrieve and update source string metadata.

Note

These endpoints rely on a source string hash for identifying each string. More information on how you can generate the hash can be found here.

Editing instructions, character limits, and tags for a set of source strings

URL: /project/<project_slug>/resource/<resource_slug>/source/

PUT

This method is used for updating the following source string metadata fields for a set of source strings:

  • comment - Instructions for translating the string
  • character_limit - Maximum number of characters allowed in a translation, excluding variables
  • tags - List of tags that can be used to filter and group strings

For each source string in the list you want to update, you must provide a source_string_hash key for identifying the source string.

Note

As of April 3, 2018, the source_entity_hash key has been renamed to source_string_hash in the payload. The change is backwards compatible, but we recommend using the source_string_hash going forward.

Sample payload data:

[
{
  "source_string_hash":"2e354ef120752c67afa1b6855aa80c52",
  "comment": "Foo string",
  "tags": ["foo"],
  "character_limit": 140
},
{
  "source_string_hash":"1d40ddf4d81533383adfd72ebfcf028a",
  "comment": "Bar string",
  "tags": ["bar"],
  "character_limit": 140
}
]

Sample request:

curl -i -L  --user api:<token>  -X PUT -H "Content-Type: application/json" \
--data '[{"source_string_hash":"2e354ef120752c67afa1b6855aa80c52", "comment": "Foo string", "tags": ["foo"], "character_limit": 140}, {"source_string_hash":"1d40ddf4d81533383adfd72ebfcf028a", "comment": "Bar string", "tags": ["bar"], "character_limit": 140}]' \
https://www.transifex.com/api/2/project/transifex/resource/core/source/

Getting and editing instructions, character limits, and tags for one source string

URL: /project/<project_slug>/resource/<resource_slug>/source/<source_string_hash>/

GET

This method is used to get the following metadata for one particular source string:

  • comment - Instructions for translating the string
  • character_limit - Maximum number of characters allowed in a translation, excluding variables
  • tags - List of tags that can be used to filter and group strings

Example

$ curl -i -L --user api:token -X GET https://www.transifex.com/api/2/project/transifex/resource/core/source/2e354ef120752c67afa1b6855aa80c52/

HTTP/1.1 200 OK
Server: nginx
Vary: Accept-Encoding
Vary: Authorization, Host, Accept-Language, Cookie
Content-Type: application/json; charset=utf-8
Date: Mon, 19 Mar 2018 17:04:09 GMT
Transfer-Encoding: chunked
Content-Language: en
X-Content-Type-Options: nosniff
Connection: keep-alive
Set-Cookie: X-Mapping-fjhppofk=2F71BA404CBE394603A72279804CAC7D; path=/
X-Frame-Options: SAMEORIGIN

{
    "comment": "Instructions for translators:....", 
    "character_limit": 25, 
    "tags": [
        "accounts"
    ]
}

PUT

This method is used to update the following metadata for one particular source string:

  • comment - Instructions for translating the string
  • character_limit - Maximum number of characters allowed in a translation, excluding variables
  • tags - List of tags that can be used to filter and group strings

Sample payload:

{
  "comment": "Foo string",
  "tags": ["foo"],
  "character_limit": 140
}

Sample request:

$ curl -i -L --user api:<token> -X PUT -H "Content-Type: application/json" \
--data '{"comment": "Foo string", "tags": ["foo"], "character_limit": 140}' \
https://www.transifex.com/api/2/project/transifex/resource/core/source/1d40ddf4d81533383adfd72ebfcf028a

Downloading a collection of source strings

GET

URL: /project/<project_slug>/resource/<resource_slug>/translation/<source_lang_code>/strings/

There are two parameters you can specify in the request in order to filter the response:

  • source_update_from - When this parameter is submitted (yyyy-mm-dd format), the response contains only strings that their source content was updated from the specified date onward (source strings updated on the specified date are included).
  • source_update_to - When this parameter is submitted (yyyy-mm-dd format), the response contains only strings that their source content was updated before the specified date (strings updated on the specified date are included).

Example

$ curl -i -L --user api:token -X GET  https://www.transifex.com/api/2/project/transifex/resource/core/translation/en/strings/?source_update_from=2017-11-01&source_update_to=2017-12-30

HTTP/1.1 200 OK
Server: nginx
Vary: Accept-Encoding
Vary: Authorization, Host, Accept-Language, Cookie
Content-Type: application/json; charset=utf-8
Date: Mon, 19 Mar 2018 17:20:16 GMT
Transfer-Encoding: chunked
Content-Language: en
X-Content-Type-Options: nosniff
Connection: keep-alive
Set-Cookie: X-Mapping-fjhppofk=978A30C321AEE9D0F95E25198189AC99; path=/
X-Frame-Options: SAMEORIGIN

[
    {
        "comment": "\n", 
        "context": "", 
        "key": "Full name is required.", 
        "string_hash": "1d40ddf4d81533383adfd72ebfcf028a", 
        "reviewed": false, 
        "pluralized": false, 
        "source_string": "Full name is required.", 
        "translation": "Full name is required."
    }, 
    {
        "comment": "\n", 
        "context": "", 
        "key": "Transifex does not support this role.", 
        "string_hash": "2e354ef120752c67afa1b6855aa80c52", 
        "reviewed": false, 
        "pluralized": false, 
        "source_string": "Transifex does not support this role.", 
        "translation": "Transifex does not support this role."
    }
    ....
]