• Save
Internationalization in Jakarta Struts 1.3
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Internationalization in Jakarta Struts 1.3

on

  • 790 views

How to internationalize web applications made with Jakarta Struts 1.3

How to internationalize web applications made with Jakarta Struts 1.3

Statistics

Views

Total Views
790
Views on SlideShare
790
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Internationalization in Jakarta Struts 1.3 Presentation Transcript

  • 1. Internationalization in StrutsIlio Catallo – Politecnico di Milanocatallo@elet.polimi.it
  • 2. Outline¤  How to internationalize a web app ¤  Distinguish between different localities ¤  Display appropriate message for different localities ¤  Automatically format elements sensitive to locality¤  References 2
  • 3. How to internationalizea web app
  • 4. Internationalization andLocalization¤  Internationalization (i18n) is the process of designing an application so that it can be adapted to various languages and regions without engineering changes¤  Localization (l10n) is the process of adapting software for a specific region or language by adding locale-specific components and translating text 4
  • 5. Internationalization requirements¤  To be internationalized, an application should be able to: ¤  Distinguish between different localities ¤  Display appropriate messages and labels for different localities (using the same executable) ¤  Provide support for new localities without compiling a new executable ¤  Automatically format elements sensitive to locality (e.g., dates) 5
  • 6. Distinguish between differentlocalities¤  The Struts framework maintains a standard Locale object for each user (java.util.Locale) ¤  A Locale object represents a specific geographical, political, or cultural region ¤  Example: the locale for French-speaking Canadians is Locale l = new Locale("fr", "CA")¤  Components that can alter their behavior by locality are called locale-sensitive ¤  A number of Struts components are locale-sensitive and make use of the Locale object that the framework manages for each user 6
  • 7. Display appropriate messages andlabels for different localities (1/2)¤  Every message that may be displayed in the application is stored in a separate file, called the resource bundle ¤  Messages can be updated independently from the source code (and vice versa)¤  The web app can be localized by a adding resource bundle for each supported locale, according to a specific naming convention: ¤  Example: application_it_IT.properties 7
  • 8. Display appropriate messages andlabels for different localities (2/2)application.properties (snippet)registerform.email.msg=Invalid e-mail addressapplication_it_IT.properties (snippet)registerform.email.msg=Indirizzo e-mail non valido¤  The same key is used for the element regardless of locale, but the message it returns may be different¤  To support another locale, just add a new resource bundle 8
  • 9. Automatically format elementssensitive to locality¤  Elements sensitive to locality, such as dates and currencies, may be subject to different formatting¤  Any local-specific pattern is specified in the resource bundle according to java.text.MessageFormat conventionsLocalizing a date in application.propertiesregister.welcome.message=Welcome {0}, today is {1, date, long} The second argument is expected to be a date 9
  • 10. References¤  Struts 1 In Action, T. N. Husted, C. Dumoulin, G. Franciscus, D. Winterfeldt, Manning Publications Co.¤  MessageFormat Javadoc, http://docs.oracle.com/javase/1.5.0/docs/api/java/text/ MessageFormat.html 10