04. Translating the Pentaho Application
The .properties files in the Pentaho application directory tree contain text used in the application files. These include error messages, debug messages, and user interface text. These files are all named 'messages.properties'.  In the Pre-Configured install, the application resource bundles are located below the WEB-INF directory. By default, this is the path to the WEB-INF directory:
/pentaho-demo/jboss/server/default/deploy/pentaho.war/WEB-INF
Not all of the text in these files will be seen by users during typical use. To make this clear we have used a naming convention for each piece of text in the .properties files.
Prefix |
Meaning |
.USER_ |
This text will be viewable by users. |
.ERROR_ |
This text represents an error in the system. Viewable in event logs if log level is ERROR or above. |
.WARN_ |
This text represents a warning in the system. Viewable in event logs if log level is WARN or above. |
.INFO_ |
This text represents an error in the system. Viewable in event logs if log level is INFO or above. |
.DEBUG_ |
This text represents detailed system information used for problem tracking. Viewable in event logs if log level is DEBUG or above. |
The priority order in which you should translate the messages is:
- All of the text in WEB-INF\portlet.properties
- Translate according to the following table:
For the following paths |
Translate text names with |
WEB-INF\classes\org\pentaho\locale WEB-INF\classes\org\pentaho\ui\component |
.USER_ |
WEB-INF\classes\org\pentaho\ui\portlet |
.USER_ |
WEB-INF\classes\org\pentaho\ui\component\charting |
.USER_ |
WEB-INF\classes\org\pentaho\ui\portlet\charting |
.USER_ |
WEB-INF\classes\org\pentaho\ui\servlet |
.USER_ |
If you just want to translate the Pre-Configured Installation and samples, you only need to translate the following files under <pentaho-demo>/jboss/server/default/deploy/pentaho.war/WEB-INF:
   \portlet.properties
   \classes\org\pentaho\locale\messages.properties
This is significantly different than prior releases of the Pentaho Pre-Configured install. Previously each Java package owned its own ResourceBundle manager 'Messages.java' and a set of properties files called messages.properties (one for each locale). Now we have consolidated all of our resources into the directories listed above using a common set of manager classes, org\pentaho\messages. There is a messages.properties for each locale and we have merged all previously translated bundles into one locale specific counterpart. This should make it much easier to locate strings that need to be translated as they all live in a common location.
Like the samples, the format of the .properties file is name=message. You must be careful not to change anything to the left of the equals '=' sign. All messages must stay on one line. Do NOT add carriage returns to the .properties files.
In the application messages, there are special replaceable parameter tags. They look like {0} and {1} etc. They are used to build messages. For example:
HelloWorld.USER_HELLO_WORLD_TEXT=\nHello World.{0}\n
The {0} represents a placeholder, and SHOULD NOT BE CHANGED. The text for these placeholders will come from data and be inserted by the application. All of the placeholders from the original text must appear in the translated string. The test position of the placeholders and the order they appear may be changed in order to match the correct grammar of your language. So, our second example would look like
HelloWorld.USER_HELLO_WORLD_TEXT =\nBonjour Monde.{0}\n
Seeing the results of your application translations
In order to see your changes you will have to restart the application server. Use 'stop-pentaho' and 'start-pentaho' to do this. The name of the text may help figure out where to look for your results. In this example, you would look for a message displayed to the user while executing the "Hello World" component.
Testing From Your Browser
If you want to switch between languages in your web browser you can do so by changing the language preference of your web browser.
Changing Language Preferences in Internet Explorer
In Internet Explorer, follow these steps to change your language preference:
- From the main menu, navigate to the Tools menu, then select Internet Options...
- On the General tab, select the Languages... button.
- On the Languages dialog, select the Add... button.
- You will get a dialog with a list of locales to choose from. Select the locale you wish to change your preference to, then select OK.
- Your selection should appear in the Languages dialog now. Select your preference, then select the Move Up button until your preference is first in the list.
- Select OK until all dialogs are closed.
- Refresh your web page.
Changing Language Preferences in Firefox
In Mozilla Firefox, follow these steps to change your language preference:
- From the main menu, navigate to the Tools menu, then select Options...
- On the Advanced tab, select the Edit Languages... button.
- On the Languages dialog, select the combo box at the bottom of the dialog.
- You will get a list of locales to choose from. Select the locale you wish to change your preference to.
- Select the Add button to add your preference to the displayed list.
- Your selection should appear in the Edit Languages dialog list now. Select your preference in the list, then select the Move Up button until your preference is first in the list.
- Select OK until all dialogs are closed.
- Refresh your web page