Localizing the configuration metadata

The name and description attributes of each metadata entry can be localized, and the translated strings packaged into language-specific properties files.

Example

The following example shows how the location of the localized files is specified in the header of the metatype file:
<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.1.0" 
    localization="OSGI-INF/I10n/metatype">
where OSGI-INF/I10n is the location of the translated properties files in the bundle, and metatype is the prefix of the default language properties file. For example, if the default values, usually in English, are in a file called metatype.properties, then each locale is added with its own suffix: metatype_fr.properties, metatype_es.properties and so on.

Unlike the metatype XML file, which must always be in the OSGI-INF/metatype directory, the translated files can be in any location that is within the bundle and specified by the localization attribute. It is better to not put the properties files in the OSGI-INF/metatype directory alongside the metatype XML file; the Metatype service attempts to parse anything in that location as an XML file, and although that does not cause a failure, it generates unwanted exceptions in the console. The Liberty convention is to put them in the OSGI-INF/I10n directory, but that is not mandatory.

In the metatype XML file, to show that a value is a localized string you use a percent sign at the start of the value. For example, you might use the following definition in the metatype XML file:
<AD name="%client.inactivity.timeout" description="%client.inactivity.timeout.desc"
    id="clientInactivityTimeout" required="false" type="Integer" default="60" />
and you might use the following definition in the properties file:
client.inactivity.timeout=Client inactivity timeout
client.inactivity.timeout.desc=The maximum duration, in seconds, between transactional requests 
from a remote client. Any period of client inactivity that exceeds this timeout results in the 
transaction being rolled back in this application server.