The Translation API allows you to translate text content between different locales while maintaining formatting. It supports various text formats and includes caching capabilities for improved performance.
All API requests require authentication using an API key. Include your API key in the request headers:
x-api-key: your-api-key
POST /api/translate
Translates text content between specified locales.
{ "projectId": "string", "sourceLocale": "string", "targetLocale": "string", "format": "string", "sourceText": "string", "cache": boolean }
Success Response (200 OK)
{ "success": true, "translatedText": "string", "cached": boolean }
Error Response (4xx, 5xx)
{ "success": false, "error": "string" }
curl -X POST https://api.languine.com/api/translate \ -H "Content-Type: application/json" \ -H "x-api-key: your-api-key" \ -d '{ "projectId": "proj_123", "sourceLocale": "en", "targetLocale": "es", "format": "md", "sourceText": "Hello world", "cache": true }'
{ "success": true, "translatedText": "Hola mundo", "cached": false }
The API uses conventional HTTP response codes to indicate the success or failure of requests:
401
- Invalid or missing API key400
- Invalid request parameters403
- API key valid but insufficient permissions or exceeded limits500
- Server errorAPI requests are subject to rate limiting based on your project's configuration. The limits are verified for each API key and project combination.
The API supports optional caching of translation results. When cache
is set to true
:
The API supports various text formats including:
string
- Plain text stringsjson
- JSON files and objectsyaml
- YAML filesproperties
- Java properties filesandroid
- Android string resourcesxcode-strings
- iOS/macOS .strings filesxcode-stringsdict
- iOS/macOS .stringsdict filesxcode-xcstrings
- iOS/macOS .xcstrings filesmd
- Markdownmdx
- MDX (Markdown with JSX)html
- HTML filesjs
- JavaScript filests
- TypeScript filespo
- Gettext PO filesxliff
- XLIFF translation filescsv
- CSV filesxml
- XML filesarb
- Application Resource Bundle filesftl
- Fluent FTL filesphp
- PHP filesAdditional formats may be supported based on your project configuration.