![]() | |
|
|
Dynamic localization frameworkImportant note as of 2008-08-25I abandoned the internationalization project and started with a new approach. (See A new start: NI18N). The old software will remain available on this site for the time being. What is the dynamic localization framework?The dynamic localization framework makes it easy to develop Swing desktop applications, or refactor existing applications, that can dynamically change the locale setting. Upon a locale change, all visible components will display localized values for the new locale automatically. Why is this useful?There may be circumstances that a user wants to view an application in another locale than the default locale of the machine he is working on. Reasons may be:
What must a developer do to use the framework in an application?The framework must be made active. So, somewhere at startup time, one must code: I18nInstaller.ensureInstalled();(It does not matter if this method is repeatedly invoked). The framework uses so called prefixed keys that can be used on many components and that represent localized values. These prefixed keys are assembled by the I18nInstaller from a ResourceBundle's basename and a ResourceBundle key. As an example, given a ResourceBundle Resources and a key labelText, instead of coding: JLabel label = new JLabel(ResourceBundle.getBundle("Resources") .getString("labelText"));one would code: JLabel label = new JLabel(I18nInstaller.getPrefixedKey("Resources", "labelText"));The developer may also use JLabel label = new JLabel(Resources.labelText.autoKey());How does it work?The framework relies on Swing's ability to dynamically change the Look and Feel. When changing the Look and Feel, needed values are obtained from Swing's own ResourceBundles. This happens in the installUI methods. This framework is build on top of a pluggable Auxiliary Look and Feel implementation called EmptyX, that is running together with the chosen Look and Feel under management of the MultiLookAndFeel (also known as the Multiplexer Look and Feel). A internationalization plugin is registered in EmptyX in order to delegate installUI requests to that plugin. What is supported?
The bundle editorA ResourceBundle Editor is available that scans for all ResourceBundles in the classpath and builds a dictionary from values found. This dictionary helps the translator by providing translation hints. MiscellaneousSome utility classes are available that help in structuring and organizing your ResourceBundles. An Arrow icon is available, subclassed into LINE_END, LINE_START, PAGE_END and PAGE_START, that automatically points to a direction based on the current orientation. No webstart demoThe framework will run in a webstarted demo. However, changing Locale will not be permitted by the Security Manager if the application's jar file is not signed. Moreover, the Bundle Editor, which is an important part of the demonstration, needs to write translated bundles to a directory that is contained in the current class path for the changes to be immediately in effect on the GUI. Since this is impossible, even with a signed jar file (I could not find a way to include a local directory in the class path when using a webstarted application) no webstart demo is available. DownloadPlease see the download page and download the complete package. It contains a ReadMe file that explains how to run the demo.
|