Translations
Ticketmatic accounts can have multiple languages. This is also exposed in the API.
Before reading on, read the translation documentation first to understand how multi-language support works in the application.
Multi-language support in the API largely works the same way: by default all data is returned in the base language. In the API documentation you will notice how some fields have a type of mlstring
: this indicates a string field that is translatable.
There are two ways to handle language support in the API:
- Switching the client language
- Using translation calls
Switching the client language
By default, all calls are handled in the default account language. You can override this by sending an HTTP Accept-Language
header with a language code as value (en
, nl
, fr
, …). Both input and output will then be handled in the requested language. Passing an invalid language code will cause a fallback to the default language.
Note that if a field is not translated, the value for the default account language will be returned as fallback. For instance: when requesting French if a user only configures the English labels for a price type will return the English labels.
PHP Library
To set the language in the PHP library, use the setLanguage()
function on Client
:
1$client->setLanguage("nl");
All subsequent calls when then be performed in the requested language.
Go Library
To set the language in the Go library, change the Language
field on Client
:
1c.Language = "nl"
All subsequent calls when then be performed in the requested language.
Translation calls
You can request and update all multi-language strings for an object in one call using the translations calls.
These calls accept and return objects with string keys and string values. For example:
1{
2 "nameen": "Free ticket",
3 "namenl": "Gratis ticket",
4 "namefr": "Billet gratuit"
5}
Each field has a key composed of the field name and the language code.