This document describes how the translations system is defined and used on the server side.
translation and key are Handlebars block helpers. The key helper generates the translated text for the specified key.
Here is an example for a folder structure:
appname/htdocs/locales
\
|
|- en_US
| \
| |- media
| | \
| | |- image1.png
| | |- audio2.mp3
| | |- video3.mp4
| | |- video4.ogg
| |- messages.po
| |- other.po
| |- keys.properties
| o
|
|- de_DE
| \
| |- messages.po
| |- other.po
| o
|
|- fr_FR
o \
|- messages.po
|- other.po
o
mkey is a Handlebars block helper. The media key helper generates the attributes based on the JSON object that represents a translation (example of generated text: “src=’url’ alt=’text’”).
Here is an example of a media messages translation file (en_US/media_messages.js):
1 2 3 4 5 6 7 8 9 | {translations : {
"image_key_1" : {
"type" : "image",
"src" : "images/image1.png",
"alt" : "alternative localized text - en version", // use "key:message_1" when referencing a text key
"width" : "32",
"height" : "32"
}
}}
|
The translations for a component are considered dynamic when they are provided by an entity external to the component, like a web service. Each time a component is rendered, a request is made to the web service to retrieve the translations for the component with the specified version. The returned translations must be cached on the RAIN server in order to avoid multiple unnecessary requests.
The RAIN servers will cache all the translations that they receive from the web service and they keep them until they are notified otherwise. The notification is made by the RAIN Mothership, so a RAIN server must be able to receive them.
The translation web service MUST notify the RAIN Mothership when a translation for a component was changed, in order to notify all the RAIN servers that have cached those translations to invalidate the cache.