Localizing Structured Messages
Localizing Structured Messages
The front-end developer is responsible for localizing and presenting structured messages to the user. The debug-message field is povided as a developer convenience and is not suitable for presentation to end users.
Localization involves the following steps:
Localization Example
Let's use the following message as an example of localization into English.
{ "id": "field.required", "debug-message": "given-name attribute is required", "data": { "field-name": "given-name" } }
- Lookup a localized message template for id=field.required and
locale=en. For example, the template might be:
localized-template = "{field-name} is required"
- Localize the field-name data value of given-name to
match what the field in called in the user interface (e.g. "First
name")
localized-field-name = "First name"
- Substitute the {field-name} placeholder with the localized data
value.
localized-message = "First name is required"