Localization
localize
This localize helper is an i18n (internationalization) helper.
The helper will read a translation storage like:
{
"en": {
"welcome": "Welcome",
"bye": "Goodbye"
},
"de": {
"welcome": "Willkommen",
"bye": "Auf Wiedersehen"
}
}
Usage:
Default locale is: "en". So it will produce the following result:
Welcome
If we use another locale:
Result:
Willkommen
Reordered Parameters
The helper also supports message format style placeholder.
We have translation storage that includes:
{
"en": {
"greeting": "Hello {0} {1}"
}
}
If the template is:
Output:
Hello John Doe
If the translation storage is:
{
"en": {
"greeting": "Hello {1} {0}"
}
}
Output:
Hello Doe John