Skip to main content

Translations

The translation endpoints let you programmatically translate text using AI.

Translate a String

Translate a single string from one language to another.

POST /api/translate

Authentication: Token required

Body

{
"string": "Welcome to our app!",
"to": "es",
"from": "en"
}
FieldTypeRequiredDescription
stringstringYesThe text to translate
tostringYesTarget language code
fromstringNoSource language code (auto-detected if omitted)

Response

{
"string": "Welcome to our app!",
"translation": "¡Bienvenido a nuestra aplicación!",
"from": "en",
"to": "es"
}

Example

curl -X POST https://api.multilocale.com/api/translate \
-H "Authorization: Token <base64-token>" \
-H "Content-Type: application/json" \
-d '{"string": "Hello world", "to": "fr", "from": "en"}'

Translate to All Languages

Translate a value to multiple languages at once.

POST /api/translate-to-all-languages

Authentication: Token required

Body

{
"value": "Welcome to our app!",
"languages": ["es", "fr", "de", "ja"],
"model": "google",
"context": "This is a greeting shown on the homepage"
}
FieldTypeRequiredDescription
valuestringYesThe text to translate
languagesstring[]NoTarget language codes. If omitted, translates to all supported languages.
modelstringNoTranslation model to use. Default uses Google Translate.
contextstringNoAdditional context to improve translation quality

Response

Returns an object mapping language codes to translated values:

{
"es": "¡Bienvenido a nuestra aplicación!",
"fr": "Bienvenue dans notre application !",
"de": "Willkommen in unserer App!",
"ja": "私たちのアプリへようこそ!"
}

Example

curl -X POST https://api.multilocale.com/api/translate-to-all-languages \
-H "Authorization: Token <base64-token>" \
-H "Content-Type: application/json" \
-d '{"value": "Hello", "languages": ["es", "fr"]}'

Variable Handling

The translation endpoint preserves {variable} placeholders in your strings:

{
"value": "Hello {name}, you have {count} messages",
"languages": ["es"]
}

Response:

{
"es": "Hola {name}, tienes {count} mensajes"
}