-
Notifications
You must be signed in to change notification settings - Fork 38
Multilingual sites adding translations
Here is a list of the steps you need to follow if you want to supply a translation (more detailed explanation below):
- Supply an
<i18n:text>
element around every piece of text that you want to have a translation of. This element should contain an attribute i18n:key the value of which should be something short and unique but descriptive of the element's content. - Define the i18n:key in the list of keys along with its translation in each language's message file (
messages_*.xml
) in webapps/ROOT/assets/translations. - Note that the content of the key defined in
messages_*.xml
has priority over the content of the<i18n:text>
element. This holds true also when the<i18n:text>
element containing the key is empty. It is good practice to leave some content in the default language within the element for human readability.
In main.xmap in the map:matches for all of the public URLs the last step before serializing is a call to the i18n transformer that Cocoon uses:
<map:transform type="i18n">
<map:parameter name="locale" value="{1}" />
</map:transform>
This allows us to provide a translation for every text which is within an <i18n:text>
element with an i18n:key attribute. Keys are defined and given content in the messages_*.xml files in webappps/ROOT/assets/translations, the "*" being the language code, e.g. messages_en.xml. There should be one such file per language and all translations for all headers, menu items, text etc. are defined in each of them:
<catalogue xml:lang="en">
<message key="menu-texts">Texts</message>
<message key="menu-inscriptions">Inscriptions</message>
<message key="menu-search">Search</message>
<message key="menu-admin">Admin</message>
<message key="home-title">Welcome to EFES!</message>
</catalogue>
When you first download the EFES package, of the provided templates and menus, only assets/templates/home.xml and assets/menu/main.xml have partial i18n markup; this must be added where appropriate. Sometimes this will need to be within XSLT documents. An example is provided in stylesheets/solr/results-to-html.xsl
, which wraps facet names in i18n markup with keys of the form facet-{name of facet field}
(eg, facet-origin_place
).