• Documentation
  • API
  • Resources

Resources

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

Uploading and downloading resources

URL: /project/<project_slug>/resources/

GET

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

Example:

$ curl -i -L --user username:password -X GET http://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"
        },
        ...
    ],
}

POST

Creates a new resource with the specified slug. The fields slug, name, and i18n_type must be specified. The user must also upload the file with the strings in the source language or send the content as a string. In case of 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 current maximum value for the field slug is 50 characters.

If the resource is a subtitles format keep in mind that you can also use the following fields if you want to add Subtitle Video URLs 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 username:password -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 http://www.transifex.com/api/2/project/transifex/resources/

HTTP/1.0 201 CREATED

application/json example:

curl -i -L --user username:password -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"}' \ http://www.transifex.com/api/2/project/transifex/resources/

HTTP/1.1 201 CREATED

Modifying details and deleting resources

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

GET

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 extra fields are returned:

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

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 format you can also update the fields related to the Subtitle Video URLs.

  • 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. The user 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, else as 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.