GUI Commands 2.0 has arrived! Find out what's new and improved.
Internationalization

There are two mechanism for the internationalization of GUI Commands.

  1. Using i18n keys in the command configuration file that map to resource bundle properties.
  2. Specifying a locale for each face.

Both mechanisms make the command file considerably more verbose.

ResourceBundle

Since version 1.1.34, textural elements now support the i18n attribute.  If specified, the text value of the element will be read from the CommandManager resource bunde using the key specified by the attribute.

Attributes can also be loaded from the resouce bundle by prefixing the bundle key with i18n: and using that as the attribute value.

Example

CommandManager.defaultInstance().setResourceBundle(myResourceBundle);

<command id="my-command">
   <face>
      <text i18n="my-command.text"/>	
      <accelerator keystroke="i18n:my-command.accelerator"/>	
   </face>
</command>

Face Locales

Example

<!-- 
Set the default locale for faces with no locale defined, if not 
specified the default locale is the local of the local machine 
-->
<commands defaultLocale="en_US">
   <command id="my-command">
      <face name="menu">...</face> <!-- inherits the default locale -->
      <face name="menu" locale="en_AU">...</face> <!- Australian menus -->
   </command>
</commands>

// Explicitly set the locale (other wise the locale machine is used)
CommandManager.defaultInstance().load(commandFile, new Locale("en", "US"));

Please note: Faces not matching the current locale are discarded by the command manager. Therefore you can't have a face from one locale extending one from another.

Todo

  • Support locale heirarchies (ie locale="en" matches physical locales en_AU, en_US etc), currently you have to explicitly specify the exact locale in the command configuration file. (Also need support locale variants eg en_AU_UNIX)
  • Improve the documentation coverage on the Face Locales