API: Update translations

Last modified: April 07, 2021Author: Jakub Pomykała

This endpoint allows you to operate only on existing translations. Use this endpoint to update translation for given translation key and language or translation key, language and customer id. Using this endpoint requires authorization.

PATCH Endpoint

https://api.simplelocalize.io/api/v1/translations

Example cURL

curl 
    --location 
    --request PATCH 'https://api.simplelocalize.io/api/v1/translations' \
    --header 'X-SimpleLocalize-Token: <API_KEY>' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "content": [
            {
                "key": "EXAMPLE_TRANSLATION_KEY",
                "language": "en",
                "text": "example text"
            },
            {
                "key": "EXAMPLE_TRANSLATION_KEY",
                "language": "en",
                "text": "customer example text",
                "customerId": "my_customer"
            }
        ]
    }'

Request fields

  • key (required) - unique translation key for a project
  • language (required) - project language key
  • text - translated message for given key, language and customerId (optional)
  • customerId - if customerId is provided, then translation will be assigned to the customer translation for given key and language. Otherwise, translation will be treated as a default translation for given key and language. See customer-specific translation

Example successful response

{
  "msg": "OK",
  "status": 200,
  "data": {
    "numberOfUpdates": 2,
    "numberOfFailures": 4,
    "numberOfInserts": 1,
    "failures": [
      "Cannot update translation. Translation key value is empty.",
      "Cannot update translation. Language value is empty for key 'MY_TRANSLATION_KEY'.",
      "Cannot update translation. Language 'wrong-lang-key' does not exist in the project.",
      "Cannot update translation. Translation key 'MY_TRANSLATION_KEY' does not exist in the project."
    ]
  }
}

Response fields

  • numberOfUpdates - informs about number of processed translation updates,
  • numberOfFailures - informs about number of processed translation update failures,
  • numberOfInserts - informs about number of newly added translations,
  • failures - informs about failed updates.

Available update options

Use query param 'updateOptions' to do invoke custom logic after or during the import. You can pass more than one update option.

updateOptions Description
CREATE_KEY_IF_NOT_FOUND Creates translation key which are not present in the project.

Check how to publish translations using API