In this section, you will learn how to add translations using API access. You can use this endpoint to add new translation keys and translations or update existing translations.
Deprecation notice: This endpoint will be deprecated in the future. Check the updated documentation instead.
Endpoint
POST
https://api.simplelocalize.io
/api/v1/translations
Description
This endpoint allows you to:
- create new translation keys and translations
- add new languages/locales
- modify existing translations (
importOptions=REPLACE_TRANSLATION_IF_FOUND
)
Check importOptions
section to learn more. If you use this endpoint, note that it requires authorization.
Endpoint behaviour
- Endpoint will add translation for the translation key and language if not found.
- Endpoint will automatically update last seen value in translation editor.
- Endpoint will automatically add language if not found.
- Endpoint won't replace existing translations by default. Use update translations endpoint or
importOptions=REPLACE_TRANSLATION_IF_FOUND
. - Endpoint won't create customerId automatically if not found.
- Endpoint won't update a translation, if
key
and/orlanguage
is missing.
Sample request
curl
--location
--request POST 'https://api.simplelocalize.io/api/v1/translations' \
--header 'X-SimpleLocalize-Token: <API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
"content": [
{
"key": "HELLO_WORLD",
"language": "en",
"text": "Hello world!"
},
{
"key": "HELLLO_WORLD",
"language": "pl",
"text": "Witaj świecie!"
}
]
}'
Request fields
content
- array of objects with translations,key
- unique translation key for a project,language
- project language key,text
- translation text,namespace
- namespace for a translation key,description
- description for a translation key,customerId
- customer id for a translation key.
Import options
Use query param importOptions
to invoke custom logic after or during the import. You can pass more than one import
option.
Option value | Description |
---|---|
REPLACE_TRANSLATION_IF_FOUND | Replaces translation for key if the key already exists. Without this option SimpleLocalize will only add new translations. |
PUBLISH_AFTER_IMPORT | Translations will be published automatically to the CDN after successful import. Option available only in paid plans. Check also how to publish translations using API endpoint |
Example response
{
"msg": "OK",
"status": 200,
"data": {
"uniqueKeysProcessed": 2,
"processedWithWarnings": false,
"message": "OK"
}
}
Response fields
uniqueKeysProcessed
- informs about number of processed translation keys which was sent by a client,processedWithWarnings
- informs about encountered warnings during import,message
- informs about warning details.