JBoss Community Archive (Read Only)

RHQ

Working with the Resource Bundles

Overview

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.

IDE Setup

We allow for two different IDEs when developing RHQ. Each has a resource bundle plugin that can be configured.

Eclipse

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:

Top Level (ResourceBundle Editor)

  • Set Key Group Separator to '_' (the underscore character)

  • Check Hierarchical by default

  • IMPORTANT! UNCHECK all others

Formatting (ResourceBundle Editor -> Formatting)

  • 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".

Performance (ResourceBundle Editor -> Performance)

  • 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:

  1. You can switch between a flat view and a tree view of the properties.

  2. 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:

  1. Select all of the resource bundle property files in the navigator view.

  2. Click File->Convert Line Delimiters To->Unix.

IntelliJ

IntelliJ provides a resource bundle editor and a properties file editor out of box; no additional plugins must be installed.

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.

Conventions

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)

Adding New Properties

What a developer does when adding a new property.

Comment out new properties

Add new property to the default file. Similarly, add the new property to all locale-specific files but comment it out. For example:

Messages.properties
new_property - abc efg
Messages_de.properties
# new_property - abc efg

Pros:

  • 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.

Cons:

  • Slightly more work than omitting new properties.

Removing Properties

What a developer does when removing an obsolete property.

Delete from all bundles

When removing a property from the default bundle it must also be removed from all locale bundles. use the IDE.

Updating Properties

What a developer does when changing the text of a default property.

Treat like a new property

Follow the convention for new properties in the locale bundles. use the IDE.

Avoid Editing Multiple Resource Bundles by Hand

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.

IDE Flags

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.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 13:01:35 UTC, last content change 2011-06-27 17:16:31 UTC.