Overview
The Contazen API supports localization for error messages and responses. Currently, the API supports:- English (
en
) - Default - Romanian (
ro
)
Setting the Language
There are three ways to specify your preferred language:1. Accept-Language Header (Recommended)
Use the standard HTTPAccept-Language
header:
2. Query Parameter
Include thelocale
parameter in the URL:
3. Request Body
For POST and PUT requests, includelocale
in the JSON body:
Priority
If multiple methods are used, the API follows this priority order:- Query parameter (
?locale=ro
) - Request body (
"locale": "ro"
) - Accept-Language header
- Default to English (
en
)
Response Header
The API includes aContent-Language
header in all responses to indicate the language used:
Localized Elements
The following elements are localized:Error Messages
Field Labels
Field validation messages are localized based on the context:English | Romanian |
---|---|
Name is required | Numele este obligatoriu |
Invalid email format | Format email invalid |
Invoice not found | Factura nu a fost găsită |
Client not found | Clientul nu a fost găsit |
Due date cannot be before invoice date | Data scadentă nu poate fi înainte de data facturii |
Examples
Creating an Invoice with Romanian Errors
Request:Retrieving Non-existent Client
Request:Language Detection
If no language preference is specified, the API attempts to detect the language from theAccept-Language
header:
- If the header contains
ro
(e.g.,ro-RO
,ro
), Romanian is used - Otherwise, English is used as the default
Best Practices
- Consistency - Use the same language setting method throughout your application
- User Preference - Store user language preferences and apply them to all API requests
- Fallback Handling - Always handle English responses as a fallback
- Header Method - Prefer the
Accept-Language
header for RESTful compliance
Notes
Success messages and data field names remain in English regardless of the locale setting. Only error messages and validation messages are localized.
Not all error messages may be translated. If a translation is missing, the English version will be returned as a fallback.