Poseidon's Internationalization (i18n) API

The current language can be changed online in Poseidon. To make this possible it is important to follow some simple rules:

  • Store all component properties (e.g. label texts and mnemonics) in properties files.
  • Use com.gentleware.services.swingx.SwingFactory to create all labels, buttons, menus etc.
  • Extend from XTab, not JPanel. From XDialog, not JDialog.
  • A couple of GUI elements need special attention: Currently there are helper classes for dialogs and titled borders.
  • I18n issues not covered by these default mechanisms must react to locale change themselves.

Here it is in detail:

Properties File

When SwingFactory creates a component it looks in the given resource bundle and uses the resource key to check for a couple of keys, e.g. SwingFactory.makeRadioButton("Menu", "GridLines") will use the following entries from the MenuResourceBundle_de.properties file:

Gridlines=LinienIn general the resource key without suffix is taken for the components text
Gridlines_name=GridlinesThe component will have the given name set. Default is resource key itself, so this particular entry is superfluous.
Gridlines_mnemonic=iThe character that will get underlined to represent the mnemonic.
Gridlines_mnemonicIndex=5If you don't want the first occurence of the given character to get underlined, specify the character index here (e.g. this will be the second 'i' in 'Linien'). Will only take effect if running under JDK 1.4 or later.
Gridlines_tooltip=Zeigt das Gitter als LinienA component will have no tooltip by default, except for toolbar buttons where the text is used as tooltip default.
Gridlines_icon=grid_lines 
Gridlines_accelerator= shortcut LBe sure to use 'shortcut' instead of 'control': The Localizer will make this the apple key for Mac OS and 'control' on other platforms.
Gridlines_enabled=trueCan be only 'true' or 'false'. Default is 'true'.
Gridlines_toggle=trueCan be only 'true' or 'false'. Default is 'true'. If true a button created from this action will be a toggle button (or check box menu item).

Dialogs

To have each dialog automatically update its title and contained components, use XDialog instead of JDialog: new XDialog(String resourceBundle, String resourceKey) (or any of the other constructors that takes bundle and key name).

XDialog also fixes a bug concerning the default button: When a dialog is made displayable again after begin disposed, the default button is lost (at least on JDK 1.4 / Linux). To fix this, use XDialog.setDefaultButton() instead of getRootPane().setDefaultButton().

Titled Borders

Use com.gentleware.poseidon.swingx.XTitledBorder to have the border titles translated.

Other I18n Issues

If any part of Poseidon not covered by the previous topics is dependent on the current locale or language: Use com.gentleware.services.Localizer.addListener() to be informed of locale changes and update the GUI.



Contact Us

Any questions or suggestions?

Send us a note at plugins@gentleware.com or post to the 'Plug-Ins' section of our forum.



© 2000 - 2010 Gentleware AG
         
                        
 support  documentation  documentation  APIs