XMLI18n

Description

An implementation of the I18n interface, that loads the localized strings from a set of XML files.

Browse

Dependencies

required components FileSystem, XMLValidator, LoggerFactory, ConfigurationFactory
required libraries DNA API (dna:dna-api)

Constructor parameters

position type descritpion
1 org.jcontainer.dna.Configuration the configuration
2 org.jcontainer.dna.Logger the logger
3 org.objectledge.filesystem.FileSystem the file system to access the templates
4 org.objectledge.xml.XMLValidator for validating the localization files.

XMLI18n localization files

The name of the localization files must conform to the following regular expression:

[a-zA-Z0-9]*(\.[a-zA-Z0-9]+)*_[a-z]{2}_[A-Z]{2}\.xml

First part of the file name represents the namespace, second part, separated by the first underscore character is locale marker. Namespace elements are separated with dots, locale is composed of ISO language code and ISO country code. Language variants are not supported at this time.

Here's an example of namespace compositioning: Consider a file in the localization data directory named:

foo.bar_pl_PL.xml
containing the following XML markup:
<strings>
  <prefix name="foo2">
    <value>first_value</value>
    <prefix name="bar2">
      <prefix name="baz"><value>second_value</value></prefix>
    </prefix>
  </prefix>
</strings>
The prefixes from file name and internal xml structure are composed into single namespace. Following the example, if you want to obtain the prefix value second_value you should use the following key:
foo.bar.foo2.bar2.baz
. If you want to obtain the prefix value first_value you should use the following key:
foo.bar.foo2
.