Transifex

  • Documentation
  • API
  • Resources

Resources

The resources endpoint handles CRUD operations on resources for a specific project, identified by project_slug.

New API endpoint

This feature relies on our new API endpoint: api.transifex.com. You must authenticate with a token when calling this endpoint.

URL: api.transifex.com/organizations/<organization_slug>/projects/<project_slug>/resources/

GET

Return a JSON-encoded list with the resources that belong to the specified project. The fields returned are:

  • id - the unique ID of the resource
  • slug - the unique slug of the resource
  • name - the resource name
  • priority - the priority of the resource
  • i18n_type - the file format of the resource
  • stringcount - the number of strings included in the resource
  • wordcount - the number of words included in the resource
  • categories - the categories of the resource
  • created - the date the resource was originally uploaded
  • last_update - the date the resource was last updated
  • accept_translations - whether the resource is locked from being translated
  • stats - statistics of the resource across languages for the different steps in your localization workflow: translation, review, and proofread (if available)

If you include language_code as a GET parameter, the response returned will only contain stats for that target language code:

Example:

$ curl -i -L --user api:<token> -X GET https://api.transifex.com/organizations/transifex/projects/transifex/resources/?language_code=fr_FR

HTTP/1.1 200 OK
...

[
    {
        "id": 27146,
        "slug": "core",
        "name": "Core",
        "priority": "2",
        "i18n_type": "PO",
        "stringcount": 3296,
        "wordcount": 23377,
        "categories": null,
        "created": "2012-06-18T12:32:28.583374Z",
        "last_update": "2017-11-08T10:39:29.405332Z",
        "accept_translations": true,
        "stats": {
            "last_activity": "2017-11-08T12:12:52.028696Z",
            "reviewed_1": {         
                "wordcount": 14985,
                "stringcount": 2571,
                "percentage": 0.7800364077669902,
                "last_activity": "2017-11-08T12:12:51.993861Z",
                "name": "reviewed"          
            },
            "translated": {
                "wordcount": 14985,
                "stringcount": 2571,
                "percentage": 0.7800364077669902,
                "last_activity": "2017-11-08T12:12:49.960100Z",
                "name": "translated"            
            },
            "reviewed_2": {
                "wordcount": 14985,
                "stringcount": 2571,
                "percentage": 0.7800364077669902,
                "last_activity": "2017-11-08T18:12:49.960100Z",
                "name": "proofread"         
            },
            "language_code": "fr_FR"
        }
    }
]

URL: /project/<project_slug>/resources/

GET (DEPRECATED)

New endpoint available

Please use the new resources endpoint described above to get the list of resource to take advantage of the the new capabilities.

Return a JSON-encoded list with the fields slug, name, i18n_type, source_language_code, and the categories of the resources that belong to the specified project.

Example:

$ curl -i -L --user api:<token> -X GET https://www.transifex.com/api/2/project/transifex/resources/

HTTP/1.1 200 OK
...

[
    {
        "source_language_code": "en", 
        "name": "Core", 
        "i18n_type": "PO", 
        "priority": "2", 
        "slug": "core", 
        "categories": null
    }
]

Uploading resources

URL: /project/<project_slug>/resources/

POST

Creates a new resource with the specified slug. The slug, name, and i18n_type fields must be specified. You must also upload a file with the strings in the source language or send the content as a string. If you use a file, the content type of the request must be multipart/form-data. Otherwise, it must be application/json. The available fields are:

  • slug
  • name
  • accept_translations
  • i18n_type
  • category or categories - Later should be a list.
  • priority - 0 for Normal, 1 for High, 2 for Urgent
  • content - In case of sending the content as one string instead of a file.

Note that the slug field has a 50-character limit.

If you're uploading a video subtitle file, you can also use the following fields to associate a video URL to the resource:

  • mp4_url
  • ogg_url
  • webm_url
  • youtube_url

Note that the values of these fields must be a publicly accessible URL.

multipart/form-data example:

$ curl -i -L --user api:<token> -X POST -H "Content-type: multipart/form-data" \
-F slug=txc -F name=core -F i18n_type=PO -F content=@/path/to/the/file/core.po https://www.transifex.com/api/2/project/transifex/resources/

HTTP/1.0 201 CREATED

application/json example:

curl -i -L --user api:<token> -X POST -H "Content-type: application/json" \
--data '{"content": "<?xml version='1.0' encoding='UTF-8'?>\n<resources>\n<string name=\"localization_manager\">Localization Manager</string>\n<string name=\"admin_users\">Administrators are people that manage the organization.</string>\n<string name=\"contribution\">Become a translator or contribute to a Transifex project.</string>\n<string name=\"updates\">Keep me up to date with Transifex news</string>\n<string name=\"live_status\">Live status of Transifex service</string>\n<string name=\"connect_with_users\">Connect with users on Transifex</string>\n</resources>\n", "i18n_type":"ANDROID", "name": "Android", "slug": "android_app"}' \ https://www.transifex.com/api/2/project/transifex/resources/

HTTP/1.1 201 CREATED

New API endpoint

This feature relies on our new API endpoint: api.transifex.com. You must authenticate with a token when calling this endpoint.

URL: api.transifex.com/organizations/<organization_slug>/projects/<project_slug>/resources/<resource_slug>

GET

Return a JSON encoded string with the details for the specified resource. The fields returned are:

  • id - the unique ID of the resource
  • slug - the unique slug of the resource
  • name - the resource name
  • priority - the priority of the resource
  • i18n_type - the file format of the resource
  • stringcount - the number of strings included in the resource
  • wordcount - the number of words included in the resource
  • categories - the categories of the resource
  • created - the date the resource was originally uploaded
  • last_update - the date the resource was last updated
  • accept_translations - whether the resource is locked from being translated
  • stats - statistics of the resource for each language for the different steps in your localization workflow: translation, review, and proofread (if available)

Example:

$ curl -i -L --user api:<token> -X GET https://api.transifex.com/organizations/transifex/projects/transifex/resources/core/

HTTP/1.1 200 OK
...

{
    "id": 27146,
    "slug": "core",
    "name": "Core",
    "priority": "2",
    "i18n_type": "PO",
    "stringcount": 3296,
    "wordcount": 23377,
    "categories": null,
    "created": "2012-06-18T12:32:28.583374Z",
    "last_update": "2017-11-08T10:39:29.405332Z",
    "accept_translations": true,
    "stats": {
        "lt": {
            "reviewed_1": {
                "wordcount": 0,
                "stringcount": 0,
                "percentage": 0,
                "last_activity": null,
                "name": "reviewed"          
            },
              "reviewed_2": {
                "wordcount": 0,
                "stringcount": 0,
                "percentage": 0,
                "last_activity": null,
                "name": "proofread"         
            },      
            "translated": {
                "wordcount": 18926,
                "stringcount": 2752,
                "percentage": 0.8349514563106796,
                "last_activity": "2017-10-12T12:03:22.704475Z",
                "name": "translated"            
            }
        },
        "ja": {
            "reviewed_1": {
                "wordcount": 22780,
                "stringcount": 3206,
                "percentage": 0.9726941747572816,
                "last_activity": "2017-07-28T14:47:18.055344Z",
                "name": "reviewed"
            },
              "reviewed_2": {
                "wordcount": 0,
                "stringcount": 0,
                "percentage": 0,
                "last_activity": null,
                "name": "proofread"         
            },      
            "translated": {
                "wordcount": 23291,
                "stringcount": 3295,
                "percentage": 0.9996966019417476,
                "last_activity": "2017-10-31T14:00:25.792557Z",
                "name": "translated"            

            }
        }
    }
}

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

GET (DEPRECATED)

Please use the new resources endpoint described above to get the list of resource to take advantage of the the new capabilities.

Return a JSON encoded string with the details for the resource. The default fields returned are the name, slug, i18n_type, source_language, priority, and categories. If the keyword details is given as a GET parameter, then additional fields are returned:

  • created
  • available_languages
  • project_slug
  • wordcount
  • total_entities
  • accept_translations
  • last_update

Example:

$ curl -i -L --user api:<token> -X GET https://www.transifex.com/api/2/project/transifex/resource/txc/?details

HTTP/1.1 200 OK
...

{
    "slug": "txc",
    "mimetype": "text/x-po",
    "source_language_code": "en",
    "wordcount": 6160,
    "total_entities": 1017,
    "last_update": "2011-12-05 19:59:55",
    "categories": ["core"],
    "available_languages": [
        {
            "code_aliases": " ",
            "code": "sq",
            "name": "Albanian"
        },
        ...
    ],
}

PUT

Update the details for the specified resource – not the content in the source language. The same restrictions about the allowed fields as in POST requests apply here as well.

If the resource is a subtitles file, you can also update the fields for the subtitle video URL:

  • mp4_url
  • ogg_url
  • webm_url
  • youtube_url

Note that the values of these fields must be a publicly accessible URL.

DELETE

Delete a resource. If the resource does not exist, an error is returned. You must be authenticated.

Uploading and downloading translations for a file

The resource content available in a source language for translations is handled under this URL:

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

GET

Return the original translation/content in the source language of the resource. If the parameter file is specified in the GET request, the translation is sent as a file. Otherwise, you'll get a JSON encoded string.

PUT

Puts a new translation for the source language of the resource. This affects all languages being translated for the resource, that will get the changes of the source language automatically applied. If the content type of the request is application/json, the content must be sent as a json-encoded string. Else, multipart/form-data content type should be used to sent it as a file.

In the case of 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.