Localizations Service
The localization service
is a simple service that features storage and retrieval of text snippets, translated into multiple languages. A snippet is identified by a key, for example 'mail_greeting', and has associated values in all translated languages.
The notification service
as well as the template service
are aware of the localization service
, and have built-in support for localizations. They both use the localization service
in order to generate notifications and emails in appropriate languages based on a pre-defined template, which in turn are filled with localization keys that can be retrieved by the localization service
.
Intro
The Localization Service provides a database to store text snippets in multiple languages that can be retrieved on demand by using a localization key
. These keys can be included in the Template Service to automatically provide the text messages in the preferred language.
Objects and attributes
LocalizationSets
Text snippets are stored in a LocalizationSet
object, which is uniquely identified by its key attribute. The translations and their respective language codes (ISO 639-1
) are stored as key-value pairs in the text attribute.
Tip: It is recommended to compose text snippets with complete sentences because the order of words in a sentence can differ between languages due to their unique set of grammar rules.
Common timestamp attributes
All Extra Horizon Services keep track of the time of creation (creation_Timestamp) and of the most recent update (update_Timestamp) of their stored objects.
Note: The timestamp attributes in the Localization Service have a number format, whereas other Services use a string($date-time) format.
Using Variables in a LocalizationSet
Generic text snippets are often combined with user-specific data, such as the user’s name or medical records. These variables can be added to the text strings of the LocalizationSet
as $1
, $2
, etc.
Example LocalizationSet
When requesting text snippets, a value for each variable should be added in numeric order. This means that the first additional argument in the request corresponds to $1.
Example List LocalizationSet text(s) in specific language(s) request
Request body:
Request Response:
Actions
This section gives an overview of the available Localization Service endpoints. The full descriptions, including the required permissions and/or scopes, can be found in the API reference documentation.
Managing LocalizationSets
The four CRUD actions are available to set up LocalizationSets. The {languageCode: string}
pairs in a set can be updated but cannot be removed individually.
Create LocalizationSet(s)
POST
/
List all LocalizationSets
GET
/
Update LocalizationSet(s)
PUT
/
Delete LocalizationSet(s)
DELETE
/
Using LocalizationSets
Text snippets in one or more languages can also be requested directly from the Localization Service with the following endpoint. The response will include the snippet in the requested language(s), if available, and in English.
List LocalizationSet text(s) in specific language(s)
POST
/request
In addition, LocalizationSets can be implemented in the Template Service by using double curly brackets: {{key}}
in the text fields. The Services will then communicate with each other to provide the text snippets in the user’s preferred language, if available. If not, the default text is returned, i.e. the English version of the snippet.
Last updated