Transifex API & metadata

api
metadata

#1

If a resource is transferred from one project to another, will the metadata (tags, comment, etc) be lost?


#2

Please let me further elaborate on this.

First of all, translators’ comments cannot be transferred from one project to another but tags, character limit, instructions can be transferred via API as it is described in our documentation guide here.

Such an example can be found below:

# You can retrieve the desired information (tags, character limits, instructions) from the existing entries using the following API call:

$curl -i -L --user your_username:your_password -X GET http://www.transifex.com/api/2/project/project_slug/resource/resource_slug/source/source_entity_hash

The source entity hash can be either retrieved via API as it is described here or you can calculate it on your own as follows:

from hashlib import md5
keys = [“string’s_key”, ‘’]
print( md5(’:’.join(keys).encode(‘utf-8’)).hexdigest() );
dea8455d879cf86c1feecea628b9e6f3

In case you are interested in this approach, then check our documentation guide here for more details.

The information that is being returned looks like this:

{
“comment”: “This is an instruction related to the string”,
“character_limit”: null,
“tags”: [
“tag_0”,
“tag_1”
]
}

# After creating the new resource, you can send this information back to Transifex using the following API call:

curl -i -L --user api:token -X PUT -H "Content-Type: application/json" \ --data '{"comment": "These are instructions related to the string", "tags": ["tag_0", "tag_1"]}' \ http://www.transifex.com/api/2/project/project_slug/resource/resource_slug/source/source_entity_hash

The above works on a string level but in case you want to update the metadata of multiple strings in Transifex, then you can use the following API call instead:

e.g.

curl -i -L --user api:token -X PUT -H "Content-Type: application/json" \ --data '[{"source_entity_hash":"....", ...., "character_limit": 140}, {"source_entity_hash":"....", ...., "character_limit": 50}]' \ http://www.transifex.com/api/2/project/project_slug/resource/resource_slug/source/