Locale Resource Bundles
From DOC
Contents |
Overview
Resource bundles provide locale-specific strings for use in specific languages and countries.
Resource Bundles
Tolven defines several resource bundles (for each locale).
| Point-id | Description |
global-locale
| Strings that apply to the application as a whole such as administrative, login, and account selection where no account type is known or applicable. For example:
Login=Login ageInYears=y |
application-global-locale
| Strings specific to an account type. For example, echr.GlobalBundle for the echr account type. This allows variations among account types. The echr account type might define:
Preferences=Preferences while the ephr account type might define the same property as: Preferences=Settings |
application-locale
| Strings specific to an account type and specific to the application structure within that account type. For example, echr.AppBundle for the echr account type would contain properties such as:
echr.patients=Patients for the string used for the "Patients" tab in the echr application. |
Each plugin can contribute entries to one or more of these bundles as described below. The point-id defines which of these bundles is contributed to. For the two application-related bundles, you must also specify the account type (application name). For example:
<parameter id="application-name" value="echr" />
Resource Bundle Hierarchy
Tolven uses a hierarchical locale scheme. All resources in all plugins should be defined in a default locale (no _xx suffix) resource bundle. This is the bundle that is used if no language and/or country bundle is found.
For example, Tolven developers will only populate the default bundle. Language translators are then free to maintain locale-specific resource bundles. This avoids collisions between translators and Java and web page developers. This is even true for English resource bundles such as _en or _enUS or _enGB. For example, say the developer creates a default property with incorrect spelling such as:
AppBundle.properties: echr.patient.summary.portal.specsum=Specamen
While this spelling in the default bundle might eventually be fixed by the developer, the translator would make it correct in the _en resource bundle and not be worried that the developer would mess up the translation later.
AppBundle_en.properties: echr.patient.summary.portal.specsum=Specimen
As long as each language-specific bundle provides that property, the default property will never be seen by an end-user.
Plugins
Two locale plugins are provided by default in the <config-dir>/plugins.xml file:
<plugin id="org.tolven.component.tolvenlocale">
<root />
</plugin>
<plugin id="org.tolven.component.tolvenlocale_en">
<root />
</plugin>
The default plugin org.tolven.component.tolvenlocale will eventually be deprecated. Each plugin that needs resources should define its own bundle(s) that will be merged into the main bundles (as currently defined in the default bundle.
Other locales can be downloaded by adding one or more of the following to <config-dir>/plugins.xml as <root> plugins:
<plugin id="org.tolven.component.tolvenlocale_ar">
<root />
</plugin>
<plugin id="org.tolven.component.tolvenlocale_de">
<root />
</plugin>
<plugin id="org.tolven.component.tolvenlocale_es">
<root />
</plugin>
<plugin id="org.tolven.component.tolvenlocale_fr">
<root />
</plugin>
<plugin id="org.tolven.component.tolvenlocale_hi">
<root />
</plugin>
<plugin id="org.tolven.component.tolvenlocale_nl">
<root />
</plugin>
<plugin id="org.tolven.component.tolvenlocale_pt">
<root />
</plugin>
<plugin id="org.tolven.component.tolvenlocale_zh">
<root />
</plugin>
Any changes to the plugins.xml needs to be followed by the following command to download the plugins:
On Windows:
tpf -getPlugins
On Linux:
./tpf.sh -getPlugins
Add To An Existing Locale
To add to the base locale, which is used when no matching locale is found, use one or more of the following extensions:
<extension id="application-locale-myapp" plugin-id="org.tolven.component.tolvenlocale" point-id="application-locale">
<parameter id="application-name" value="myapp" />
<parameter id="properties-file" value="myapp-locale.properties" />
</extension>
<extension id="application-global-locale-myapp" plugin-id="org.tolven.component.tolvenlocale" point-id="application-global-locale">
<parameter id="application-name" value="myapp" />
<parameter id="properties-file" value="myapp-global-locale.properties" />
</extension>
<extension id="global-locale" plugin-id="org.tolven.component.tolvenlocale" point-id="global-locale">
<parameter id="properties-file" value="custom-global.properties" />
</extension>
When using another plugin, you need to add an import tag to your plugin. There should be only one <requires> tag (which can contain many <import> tags) and it should appear before any <extension> tags. In this case:
<requires>
<import plugin-id="org.tolven.component.tolvenlocale" />
</requires>
To add to a specific locale, for example _en, _es etc, then replace _xx, with the appropriate locale, and use one or more of the following extensions:
<extension id="application-locale" plugin-id="org.tolven.component.tolvenlocale_xx" point-id="application-locale">
<parameter id="application-name" value="myapp" />
<parameter id="properties-file" value="myapp-locale.properties" />
</extension>
<extension id="application-global-locale" plugin-id="org.tolven.component.tolvenlocale_xx" point-id="application-global-locale">
<parameter id="application-name" value="myapp" />
<parameter id="properties-file" value="myapp-global-locale.properties" />
</extension>
<extension id="global-locale" plugin-id="org.tolven.component.tolvenlocale_xx" point-id="global-locale">
<parameter id="properties-file" value="custom-global.properties" />
</extension>
The properties files are referenced by a path given by the values above, and are added as part of the plugin. Default values for the application names are echr and ephr, but if you have created your own applications, you can use those names. When using another plugin, you need to add an import tag to your plugin. There should be only on <requires> tag (which can contain many <import> tags) and it should appear before any <extension> tags. In this case, where _xx is your chosen locale:
<requires>
<import plugin-id="org.tolven.component.tolvenlocale_xx" />
</requires>
Add a New Locale
A locale jar file is basically a java module, and so once you have created a new one, which does not need to handle contributions, you can add the following extension to your plugin. The example will be based on the English (_en) locale:
<extension id="myLocale_en" plugin-id="org.tolven.component.tolvenear" point-id="javaModuleProduct">
<parameter id="jar" value="myLocale_en.jar"/>
</extension>
The name of the jar file can be anything, which does not clash with a jar file already in the tolven.ear file. The jar file should have the following internal structure, and be located at the relative plugin path given by the value above. In the example below, the application name is myapp
-myapp
-AppBundle_en.properties
-GlobalBundle_en.properties
-messages
-GlobalBundle_en.properties
When using another plugin, you need to add an import tag to your plugin. There should be only on <requires> tag (which can contain many <import> tags) and it should appear before any <extension> tags. In this case:
<requires>
<import plugin-id="org.tolven.component.tolvenear" />
</requires>

