Format i18n

Various user-visible labels defined in the format and format index files can be internationalized.

For this we used Cocoon's "i18n transformer" system.

To have something translated, you basically use an <i18n:text> tag and define the corresonding label in a resource bundle.

Let's look at an example.

We want to internationalize the name of a format:

<f:format xmlns:f="http://outerx.org/xreporter/format/1.0"
          xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
  <f:info>
    <f:formattype>chart</f:formattype>
    <f:name><i18n:text catalogue="format">format.chart.name</i18n:text></f:name>
  </f:info>
</f:format>

This example declares the i18n namespace and then uses the i18n:text tag to define a piece of text which should be retrieved from a language-dependent resource bundle.

The actual resource bundles should be created at these location:

the default (usually english):
<conf.home>/reports/customformats/messages.xml

for specific languages:
<conf.home>/reports/customformats/messages_nl.xml
<conf.home>/reports/customformats/messages_fr.xml

An example of the content of such a resource bundle:

<?xml version="1.0" encoding="ISO-8859-1"?>
<catalogue>
  <message key="format.chart.name">Sample chart</message>
</catalogue>

As usual, don't forget to run "xreporter-cocoon deploy" to put your changes live.

Comments (0)