My favorites | Sign in
Google
                
Search
for
Updated Dec 09, 2008 by msinclairstevens
DevGuideInternationalization  
Easily support multiple locales with a single code base.

Internationalization

GWT includes a flexible set of tools to help you internationalize your applications and libraries. GWT internationalization support provides a variety of techniques to internationalize strings, typed values, and classes.

Quick Start with Internationalization

GWT supports a variety of ways of internationalizing your code. Start by researching which approach best matches your development requirements.

  • Do you want to internationalize mostly settings or end-user messages?
    If you have mostly settings and interface labels with fixed text, consider Constants, which uses the least runtime resources. If you have a lot a of end-user messages where you want to add arguments to each message, then Messages is probably what you want.
  • Are you adding GWT functionality to an existing web application that already has a localization process defined?
    Dictionary will help you interoperate with existing pages without requiring you to use GWT's concept of locale.
  • Do you really just want a simple way to get properties files down to the client regardless of localization?
    You can do that, too. Try using Constants without specifying a locale.

Internationalization Techniques

GWT offers multiple internationalization techniques to afford maximum flexibility to GWT developers and to make it possible to design for efficiency, maintainability, flexibility, and interoperability in whichever combinations are most useful.

  • Extending or implementing Localizable
    Provides a method for internationalizing sets of algorithms using locale-sensitive type substitution. This is an advanced technique that you probably will not need to use directly, although it is useful for implementing complex internationalized libraries. For details on this technique, see the Localizable class documentation.

The I18N Module

Core types related to internationalization:

  • Constants Useful for localizing typed constant values
  • Messages Useful for localizing messages requiring arguments
  • Dictionary Useful when adding a GWT module to existing localized web pages
  • Localizable Useful for localizing algorithms encapsulated in a class

The GWT internationalization types reside in the com.google.gwt.i18n package. To use any of these types, your module must inherit from the I18N module (com.google.gwt.i18n.I18N).

<module>
  <inherits name="com.google.gwt.i18n.I18N"/>
</module>

As of GWT 1.5, the User module (com.google.gwt.user.User) inherits the I18N module. So if your project's module XML file inherits the User module (which generally it does), it does not need to specify explicitly an inherit for the I18N module.

Specifics

Static String Internationalization A type-safe and optimized approach to internationalizing strings.

Dynamic String Internationalization A flexible and simplistic method of internationalizing strings that easily integrates with existing web applications that do not support the GWT locale client property.

Specifying a Locale How to add locales and specify the locale client property during deployment.

Localized Properties Files How to create localized properties files for use with Constants or Messages

Annotations for use with Internationalization New to GWT 1.5 is the use of annotations to allow more sophisticated internationalization. support, such as plurals and descriptions.


Sign in to add a comment