We are adding support for localized text strings to the gt-swing module to make it easier for you to provide local versions of your applications.
A new
LocaleUtils class has been added so that client code doesn't need to worry about the usual Java i18n boiler plate code for loading and caching ResourceBundles etc. Using this class, an application can set a preferred locale at the beginning of a session, prior to constructing any GUI components that will use localized text strings), like this:
LocaleUtils.setLocale(Locale.ITALIAN);
Then, localized text strings are retrieved like this:
String localToolTip = LocaleUtils.getValue("CursorTool", "ZoomInTooltip");
The text strings are stored in properties files as per the usual Java i18n conventions. For the swing module, the properties files are in the
org.geotools.swing.locale
package and group strings according to component category: e.g. "CursorTool". Adding support for a new language or language variant simply involves adding the appropriate locale to the properties files. LocaleUtils provides support for locales that are only defined for a subset of properties files by allowing the application to specify a list of locales in preference order. For example:
LocaleUtils.setLocale( Arrays.asList( firstPrefLocale, secondPrefLocale, fallbackLocale ) );
How you can helpWe need volunteers to help add and review translations. To begin with, we are just adding support for the text strings used within the gt-swing module itself plus a small selection of generally useful strings. Next, we hope to extend the LocaleUtils class so that applications can register their own properties files.
If you would like to help please contact us via the
GeoTools User list.