- IDE Setup
- Top Level (ResourceBundle Editor)
- Formatting (ResourceBundle Editor -> Formatting)
- Performance (ResourceBundle Editor -> Performance)
There are several resource bundles, the default Messages.properties and several more locale specific files. These files need to stay synchronized as development proceeds.
The recommended approach is not to manually edit these files but to utilize the IDE Resource Bundle plugins and let them manage the underlying resource bundle files.
We allow for two different IDEs when developing RHQ. Each has a resource bundle plugin that can be configured.
Eclipse users should install the Resource Bundle plugin found HERE. Note that this is a straight plugin download. Just take the zip, unzip it, and merge it under your EclipseHome/plugins directory. Then restart eclipse.
Before starting go to Preferences->Resource Bundle Editor and make the following changes:
- Set Key Group Separator to '_' (the underscore character)
- Check Hierarchical by default
- IMPORTANT! UNCHECK all others
- Check "At least one space each side of equal signs"
- IMPORTANT! UNCHECK all others
- NOTE! Before unchecking "Group Keys" make sure the "Align equals signs within groups" is also unchecked. To do this you may need to temporarily check "Align Equal Signs".
- Leave Defaults
Once the settings are updated you can right-click, in a navigator view, on any of the resource bundles and select "Open With"->"Resource Bundle Editor".
Note that the resource bundle editor will manage the underlying files. The properties will be alphabetized. This should be fine as from now on your view should be via the resource bundle editor.
A couple of notes:
- You can switch between a flat view and a tree view of the properties.
- You'll see a little hazard icon for properties that are not set across all bundles.
|Avoid Eclipse Text Editor|
Do not edit the resource bundles or constants files in the Eclipse Text Editor (ie. Open With... Text Editor). This editor will convert native unicode to \uXXXX escaped format on save. Use only the properties file editor, or preferably, the resource bundle plugin editor.
|Windows users must ensure UNIX line terminators|
On Windows you may find that the plugin will always leave the resource bundle files with Windows style line termination. DO NOT COMMIT files with this format! (Note - Git will show you that every line has changed in the diff. If you see a 100% diff then ensure you change the file format. You should only see the proper diff lines prior to committing.)
To easily change the line terminators:
When the resource bundle editor is used to add a missing message to the locale-specific bundles, the corresponding property is added at the bottom of each properties file. When the values of existing messages are updated, the corresponding properties are updated in the properties files in place. So, unlike Eclipse's resource bundle editor, no automatic alphabetic sorting of properties files by property name is done for adds or updates.
|According to the GWT I18N documentation the Resource bundles should be UTF-8 encoded. Please ensure you maintain this encoding. Native unicode is supported. (http://code.google.com/intl/ja/webtoolkit/doc/latest/DevGuideI18n.html)|
What a developer does when adding a new property.
Add new property to the default file. Similarly, add the new property to all locale-specific files but comment it out. For example:
- Easy to search for properties needing translation in any standard editor (just search for comment character).
- Flagged as a missing property in the IDE plugins.
- Until translated will fall-through to default value.
- Slightly more work than omitting new properties.
What a developer does when removing an obsolete property.
When removing a property from the default bundle it must also be removed from all locale bundles. use the IDE.
What a developer does when changing the text of a default property.
Follow the convention for new properties in the locale bundles. use the IDE.
When working on adding, removing, or changing default properties, use an IDE. The IDE plugin will manage the underlying resource bundles. Editing them by hand increases the chances of inconsistency. Commenting the files is not recommended as the IDE may rearrange the properties (typically alphabetically) ignoring the comments.
The IDE plugins show when a property is not present in all bundles. Use these visual indicators to ensure properties are defined in all bundles.