18th international unicode conference hong kong, april 2001 preference object-based...
TRANSCRIPT
![Page 1: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/1.jpg)
18th International Unicode Conference Hong Kong, April 2001
Preference Object-based InternationalizationPreference Object-based Internationalizationfor Distributed Application Framework for Distributed Application Framework
in Javain Java
Kenya [email protected]
Yamato Software Laboratory
IBM Japan, Ltd.
![Page 2: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/2.jpg)
18th International Unicode Conference Hong Kong, April 20012
AgendaAgenda
• Introduction• Requirements for Internationalization• Difficulties with JDK• Approach• Conclusion• Q&A
![Page 3: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/3.jpg)
18th International Unicode Conference Hong Kong, April 2001
IntroductionIntroduction
![Page 4: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/4.jpg)
18th International Unicode Conference Hong Kong, April 20014
Tivoli Systems - background informationTivoli Systems - background information
• an IBM company • dedicated to providing products, services,
and programs that enable companies of any size to manage their networked PCs and distributed systems from a single location.
![Page 5: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/5.jpg)
18th International Unicode Conference Hong Kong, April 20015
Tivoli Application FrameworkTivoli Application Framework
• Distributed• Used in the global company
– multi-lingual– multi-culture
• Multiple-platform• CORBA, XML• Java• UTF-8• Component-base• Tivoli Console for applications to interact users
![Page 6: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/6.jpg)
18th International Unicode Conference Hong Kong, April 20016
Tivoli Console ExampleTivoli Console Example
![Page 7: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/7.jpg)
18th International Unicode Conference Hong Kong, April 20017
AgendaAgenda
• Introduction• Requirements for Internationalization
1.Global multi-user support2.Multiple locales for a single user3.End-user Customization4.Advanced Features
• Difficulties with JDK• Approach• Conclusion• Q&A
![Page 8: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/8.jpg)
18th International Unicode Conference Hong Kong, April 2001
Requirements for Requirements for InternationalizationInternationalization
![Page 9: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/9.jpg)
18th International Unicode Conference Hong Kong, April 20019
Req.1: Global multi-user supportReq.1: Global multi-user support
• Support multiple users simultaneously across different locales and time zones
Locale = fr_FR
Locale = zn_HK
Locale = en_US
TimeZone = Hong Kong
TimeZone = Paris
TimeZone = CST
![Page 10: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/10.jpg)
18th International Unicode Conference Hong Kong, April 200110
Req.2: Multiple locales for a single userReq.2: Multiple locales for a single user
• Allow user to select different locales for resource lookup and cultural conventions
Locale = fr_FR
Locale = zn_HK
Locale = en_US
Locale = en_GB
for language
for cultural conventionsTimeZone =
Hong Kong
TimeZone = Paris
TimeZone = CST
• Tivoli provides English + 9 translated language resources• JDK can support more for cultural conventions. User can select them.
![Page 11: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/11.jpg)
18th International Unicode Conference Hong Kong, April 200111
Req.2: Multiple locales for a single userReq.2: Multiple locales for a single user
• Locale constructor
Locale loc = new Locale(“fr”, “FR”);
Locale loc = new Locale(“el”, “GR”);
Locale loc = new Locale(“fr”, “GR”);
// French (France)
// Greek (Greece)
// French (Greece) ?
Locale(String language, String country)
![Page 12: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/12.jpg)
18th International Unicode Conference Hong Kong, April 200112
Req.3: End-user CustomizationReq.3: End-user Customization
• Allow user to override a locale’s default attributes– e.g. date format styles and symbols
• The preferred non-default style should be persisted and to be used for future session, by all framework applications
![Page 13: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/13.jpg)
18th International Unicode Conference Hong Kong, April 200113
Req.4: Advanced featuresReq.4: Advanced features
• More features than the JDK– Multi-cultural calendar (Gregorian, Buddhist, Japanese,
Hebrew, Islamic, Chinese)
– Some other requirements are being discussed for future release. For example, transliteration, Java input method editor, etc.
![Page 14: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/14.jpg)
18th International Unicode Conference Hong Kong, April 200114
AgendaAgenda
• Introduction• Requirements for Internationalization• Difficulties with JDK
– JDK’s Internationalization API– Example
• Approach• Conclusion• Q&A
![Page 15: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/15.jpg)
18th International Unicode Conference Hong Kong, April 2001
Difficulties with JDKDifficulties with JDK
![Page 16: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/16.jpg)
18th International Unicode Conference Hong Kong, April 200116
JDK’s Internationalization APIJDK’s Internationalization API
• Rich features, highly customizable• Locale-sensitive classes in
– java.util package
– java.text package
– etc.
• One default locale can be set
![Page 17: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/17.jpg)
18th International Unicode Conference Hong Kong, April 200117
Example: set default localeExample: set default locale
Locale.setDefault(aLocale);
// set default locale
![Page 18: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/18.jpg)
18th International Unicode Conference Hong Kong, April 200118
DateFormat df = DateFormat.getDateTimeInstance();String dateDisplay = sdf.format(aDate);
Example 1: format a dateExample 1: format a date
// everything is based on the default locale
![Page 19: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/19.jpg)
18th International Unicode Conference Hong Kong, April 200119
DateFormat df = DateFormat.getDateTimeInstance();String dateDisplay = sdf.format(aDate);
Example 1: format a dateExample 1: format a date
// use cultLocale
DateFormat df = DateFormat.getDateTimeInstance( );String dateDisplay = sdf.format(aDate);
DateFormat.DEFAULT, DateFormat.DEFAULT, cultLocale
![Page 20: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/20.jpg)
18th International Unicode Conference Hong Kong, April 200120
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, cultLocale);String dateDisplay = sdf.format(aDate);
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, cultLocale);
String dateDisplay = sdf.format(aDate);
SimpleDateFormat sdf = (SimpleDateFormat)df;sdf.applyPattern(dateTimePattern);
Example 1: format a dateExample 1: format a date
// use cultLocale, dateTimePattern
![Page 21: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/21.jpg)
18th International Unicode Conference Hong Kong, April 200121
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, cultLocale);SimpleDateFormat sdf = (SimpleDateFormat)df;sdf.applyPattern(dateTimePattern);String dateDisplay = sdf.format(aDate);
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, cultLocale);SimpleDateFormat sdf = (SimpleDateFormat)df;sdf.applyPattern(dateTimePattern);
String dateDisplay = sdf.format(aDate);
DateFormatSymbols dfs = sdf.getDateFormatSymbols();dfs.setAmPmStrings(ampmStr);sdf.setDateFormatSymbols(dfs);
Example 1: format a dateExample 1: format a date
// use cultLocale, dateTimePattern, ampmStr
![Page 22: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/22.jpg)
18th International Unicode Conference Hong Kong, April 200122
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, cultLocale);SimpleDateFormat sdf = (SimpleDateFormat)df;sdf.applyPattern(dateTimePattern);DateFormatSymbols dfs = sdf.getDateFormatSymbols();dfs.setAmPmStrings(ampmStr);sdf.setDateFormatSymbols(dfs);String dateDisplay = sdf.format(aDate);
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, cultLocale);
SimpleDateFormat sdf = (SimpleDateFormat)df;sdf.applyPattern(dateTimePattern);DateFormatSymbols dfs = sdf.getDateFormatSymbols();dfs.setAmPmStrings(ampmStr);sdf.setDateFormatSymbols(dfs);String dateDisplay = sdf.format(aDate);
Example 1: format a dateExample 1: format a date
// use cultLocale, dateTimePattern, ampmStr, timeZoneID
TimeZone tz = TimeZone.getTimeZone(timeZoneID);Calendar cal = Calendar.getInstance(tz, cultLocale);
df.setCalendar(cal);
![Page 23: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/23.jpg)
18th International Unicode Conference Hong Kong, April 200123
ResourceBundle rb = ResourceBundle.getBundle("MessageResources”);String msgPattern = rb.getString(MessageResources.MSG0001);MessageFormat mf = new MessageFormat(msgPattern);String msg = mf.format(new Object[] {aDate});
ResourceBundle rb = ResourceBundle.getBundle("MessageResources” );String msgPattern = rb.getString(MessageResources.MSG0001);MessageFormat mf = new MessageFormat(msgPattern);
String msg = mf.format(new Object[] {aDate});
TimeZone tz = TimeZone.getTimeZone(timeZoneID);Calendar cal = Calendar.getInstance(tz, cultLocale);DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,
DateFormat.DEFAULT, cultLocale);df.setCalendar(cal);SimpleDateFormat sdf = (SimpleDateFormat)df;sdf.applyPattern(dateTimePattern);DateFormatSymbols dfs = sdf.getDateFormatSymbols();dfs.setAmPmStrings(ampmStr);sdf.setDateFormatSymbols(dfs);ResourceBundle rb = ResourceBundle.getBundle("MessageResources", langLocale);String msgPattern = rb.getString(MessageResources.MSG0001);MessageFormat mf = new MessageFormat(msgPattern);mf.setLocale(cultLocale);mf.applyPattern(msgPattern);mf.setFormat(0, sdf);String msg = mf.format(new Object[] {aDate});
Example 2: format a messageExample 2: format a message// everything is based on the default locale// use langLocale, cultLocale, dateTimePattern, ampmstr, timeZoneID
![Page 24: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/24.jpg)
18th International Unicode Conference Hong Kong, April 200124
How can we . . .How can we . . .
• fulfill requirements for internationalization and• keep application’s code simple as much as
possible and• keep consistent result across various
applications on the framework?
![Page 25: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/25.jpg)
18th International Unicode Conference Hong Kong, April 200125
AgendaAgenda
• Introduction• Requirements for Internationalization• Difficulties with JDK• Approach
– Use of ICU4J– Low-level Internationalization API– High-level Framework Service
• Conclusion• Q&A
![Page 26: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/26.jpg)
18th International Unicode Conference Hong Kong, April 2001
ApproachApproach
![Page 27: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/27.jpg)
18th International Unicode Conference Hong Kong, April 200127
Hierarchy of Internationalization APIsHierarchy of Internationalization APIs
Application (Tivoli Products)
ICU4JJDK Locale Sensitive Classes
UI Lib.
ICU4J: International Components for Unicode for Java
![Page 28: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/28.jpg)
18th International Unicode Conference Hong Kong, April 200128
Use of ICU4JUse of ICU4J
• International Components for Unicode for Java• IBM’s open source project• Java classes for internationalization in Unicode
– International Calendars– Unicode Normalization– Number Format Enhancements– Enhanced word-break detection– Unicode Text Searching– Unicode Text Compression– etc...
• http://oss.software.ibm.com/developerworks/opensource/icu4j/
ICU4J is . . .
![Page 29: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/29.jpg)
18th International Unicode Conference Hong Kong, April 200129
Hierarchy of Internationalization APIsHierarchy of Internationalization APIs
Application (Tivoli Products)
ICU4J
Low-level Internationalization API
JDK Locale Sensitive Classes
UI Lib.
ICU4J: International Components for Unicode for Java
![Page 30: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/30.jpg)
18th International Unicode Conference Hong Kong, April 200130
AgendaAgenda
• Introduction• Requirements for Internationalization• Difficulties with JDK• Approach
– Use of ICU4J– Low-level Internationalization API
• International Preference Object• JDK/ICU4J Wrapper• Other classes• Rewrite Example
– High-level Framework Service
• Conclusion• Q&A
![Page 31: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/31.jpg)
18th International Unicode Conference Hong Kong, April 200131
International Preference ObjectInternational Preference Object
• Encapsulates user’s internationalization preferences– Language (Locale for resource lookup, HelpSet access, etc.)– Region (Locale for data formatting, etc.)– Calendar Type (Gregorian, Buddhist, Japanese, Islamic,
Hebrew, Chinese)– Time Zone– Default override for Number format patterns and symbols– Default override for Date/Time format patterns and symbols
• All low-level API work with this object
![Page 32: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/32.jpg)
18th International Unicode Conference Hong Kong, April 200132
Setters on IntlPreferences ClassSetters on IntlPreferences Class
setLanguageLocalesetCulturalConventionLocalesetTimeZonesetCalendarTypesetDefaultDateStylesetDatePatternsetDefaultTimeStylesetTimePatternsetDateTimeOrdersetDateTimeSeparatorsetAMStringsetPMString
setNumberPattern
setCurrencyPattern
setPercentPattern
setGroupingSeparator
setDecimalSeparator
setPercent
setZeroDigit
setMinusSign
setCurrencySymbol
setInternationalCurrencySymbol
setMonetaryDecimalSeparator
![Page 33: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/33.jpg)
18th International Unicode Conference Hong Kong, April 200133
Hierarchy of Internationalization APIsHierarchy of Internationalization APIs
Application (Tivoli Products)
ICU4J
Low-level Internationalization API
JDK Locale Sensitive Classes
UI Lib.
International Preference-based APIICU4J: International Components for Unicode for Java
![Page 34: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/34.jpg)
18th International Unicode Conference Hong Kong, April 200134
AgendaAgenda
• Introduction• Requirements for Internationalization• Difficulties with JDK• Approach
– Use of ICU4J– Low-level Internationalization API
• International Preference Object• JDK/ICU4J Wrapper• Other classes• Rewrite Example
– High-level Framework Service
• Conclusion• Q&A
![Page 35: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/35.jpg)
18th International Unicode Conference Hong Kong, April 200135
JDK/ICU4J WrapperJDK/ICU4J Wrapper
• Extend locale-based API to the international preferences object-based API
• Add one layer on ICU4J to avoid side effects of possible API changes
Purpose:
![Page 36: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/36.jpg)
18th International Unicode Conference Hong Kong, April 200136
• java.util • java.text
JDK/ICU4J Wrapper ClassesJDK/ICU4J Wrapper Classes
TimeZoneSimpleTimeZoneCalendarGregorianCalendar
DateFormatSimpleDateFormatDateFormatSymbolsNumberFormatDecimalFormatDecimalFormatSymbolsMessageFormat
• com.ibm.util • com.ibm.text• com.tivoli.intl • com.tivoli.intl
TimeZoneSimpleTimeZoneCalendarGregorianCalendarBuddhistCalendarJapaneseCalendarHebrewCalendarIslamicCalendarChineseCalendar
DateFormatSimpleDateFormatDateFormatSymbolsNumberFormatDecimalFormatDecimalFormatSymbols
IntlTimeZoneIntlSimpleTimeZoneIntlCalendarIntlGregorianCalendarIntlBuddhistCalendarIntlJapaneseCalendarIntlHebrewCalendarIntlIslamicCalendarIntlChineseCalendar
IntlDateFormatIntlSimpleDateFormatIntlDateFormatSymbolsIntlNumberFormatIntlDecimalFormatIntlDecimalFormatSymbolsIntlMessageFormat
![Page 37: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/37.jpg)
18th International Unicode Conference Hong Kong, April 200137
JDK/ICU4J Wrapper Class ExampleJDK/ICU4J Wrapper Class Example
public static DateFormat getDateInstance()
public static DateFormat getDateInstance(int style)
public static DateFormat getDateInstance(int style, Locale locale)
public static IntlDateFormat getDateInstance(IntlPreferences ip)
java.text.DateFormat class (JDK)
com.ibm.text.DateFormat class (ICU4J)
com.tivoli.intl.IntlDateFormat class (Tivoli Wrapper)
public static IntlDateFormat getDateInstance()
public static IntlDateFormat getDateInstance(int style)
public static IntlDateFormat getDateInstance(int style, Locale locale)
![Page 38: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/38.jpg)
18th International Unicode Conference Hong Kong, April 200138
• com.tivoli.intl
Other ClassesOther Classes
IntlPreferencesIntlUtilitiesIntlDisplayableTextIntlBundleLoader
![Page 39: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/39.jpg)
18th International Unicode Conference Hong Kong, April 200139
AgendaAgenda
• Introduction• Requirements for Internationalization• Difficulties with JDK• Approach
– Use of ICU4J– Low-level Internationalization API
• International Preference Object• JDK/ICU4J Wrapper• Other classes• Rewrite Example
– High-level Framework Service
• Conclusion• Q&A
![Page 40: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/40.jpg)
18th International Unicode Conference Hong Kong, April 200140
TimeZone tz = TimeZone.getTimeZone(timeZoneID);Calendar cal = Calendar.getInstance(tz, cultLocale);DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, cultLocale);df.setCalendar(cal);SimpleDateFormat sdf = (SimpleDateFormat)df;sdf.applyPattern(dateTimePattern);DateFormatSymbols dfs = sdf.getDateFormatSymbols();dfs.setAmPmStrings(ampmStr);sdf.setDateFormatSymbols(dfs);String dateDisplay = sdf.format(aDate);
Example 1: format a dateExample 1: format a date
// use cultLocale, dateTimePattern, ampmStr, timeZoneID
![Page 41: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/41.jpg)
18th International Unicode Conference Hong Kong, April 200141
TimeZone tz = TimeZone.getTimeZone(timeZoneID);Calendar cal = Calendar.getInstance(tz, cultLocale);DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,
DateFormat.DEFAULT, cultLocale);df.setCalendar(cal);SimpleDateFormat sdf = (SimpleDateFormat)df;sdf.applyPattern(dateTimePattern);DateFormatSymbols dfs = sdf.getDateFormatSymbols();dfs.setAmPmStrings(ampmStr);sdf.setDateFormatSymbols(dfs);ResourceBundle rb = ResourceBundle.getBundle("MessageResources", langLocale);String msgPattern = rb.getString(MessageResources.MSG0001);MessageFormat mf = new MessageFormat(msgPattern);mf.setLocale(cultLocale);mf.applyPattern(msgPattern);mf.setFormat(0, sdf);String msg = mf.format(new Object[] {aDate});
// use langLocale, cultLocale, dateTimePattern, ampmstr, timeZoneID
Example 2: format a messageExample 2: format a message
![Page 42: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/42.jpg)
18th International Unicode Conference Hong Kong, April 200142
Rewrite examples: CustomizationRewrite examples: Customization
ip.setLanguageLocale(langLocale);ip.setCulturalConventionLocale(cultLocale);ip.setTimeZone(timeZoneID);ip.setAMString(ampmStr[0]);ip.setPMString(ampmStr[1]);ip.setDatePattern(datePattern, IntlPreferences.MEDIUM);ip.setTimePattern(timePattern, IntlPreferences.MEDIUM);ip.setDateTimeOrder(IntlPreferences.DATE_FIRST);
. . .
// Customizations are centralized to the International preferences
( . . . 23 setters can be used )
![Page 43: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/43.jpg)
18th International Unicode Conference Hong Kong, April 200143
Rewrite example 1: format a dateRewrite example 1: format a date
IntlDateFormat df = IntlDateFormat.getDateTimeInstance(ip);String dateDisplay = df.format(aDate);
// use international preferences
DateFormat df = DateFormat.getDateTimeInstance();String dateDisplay = df.format(aDate);
// everything is based on the default locale
![Page 44: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/44.jpg)
18th International Unicode Conference Hong Kong, April 200144
Rewrite example 2: format a messageRewrite example 2: format a message
ResourceBundle rb = IntlUtilities.getBundle(ip, "MessageResources");String msgPattern = rb.getString(MessageResources.MSG0001);IntlMessageFormat mf = new IntlMessageFormat(ip, msgPattern);String msg = mf.format(new Object[] {aDate});
// use international preferences
// everything is based on the default locale
ResourceBundle rb = ResourceBundle.getBundle("MessageResources");String msgPattern = rb.getString(MessageResources.MSG0001);MessageFormat mf = new MessageFormat(msgPattern);String msg = mf.format(new Object[] {aDate});
![Page 45: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/45.jpg)
18th International Unicode Conference Hong Kong, April 200145
AgendaAgenda• Introduction• Requirements for Internationalization• Difficulties with JDK• Approach
– Use of ICU4J– Low-level Internationalization API– High-level Framework Service
• Layer Separation• High-level Framework Service• Rewrite Example• International Preferences Notebook• Example
• Conclusion• Q&A
![Page 46: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/46.jpg)
18th International Unicode Conference Hong Kong, April 200146
Hierarchy of Internationalization APIsHierarchy of Internationalization APIs
High-level International Service
Application (Tivoli Products)
ICU4J
Low-level Internationalization API
JDK Locale Sensitive Classes
UI Lib.
International Preference-based APIICU4J: International Components for Unicode for Java
![Page 47: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/47.jpg)
18th International Unicode Conference Hong Kong, April 200147
Layer SeparationLayer Separation
Include the framework specific implementations
Correlate application’s context to the user’s international preference
Be generic for reusability Take international preference object from method argument
High-level International Service
Low-level Internationalization API
![Page 48: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/48.jpg)
18th International Unicode Conference Hong Kong, April 200148
AgendaAgenda• Introduction• Requirements for Internationalization• Difficulties with JDK• Approach
– Use of ICU4J– Low-level Internationalization API– High-level Framework Service
• Layer Separation• High-level Framework Service• Rewrite Example• International Preferences Notebook• Example
• Conclusion• Q&A
![Page 49: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/49.jpg)
18th International Unicode Conference Hong Kong, April 200149
High-level International ServiceHigh-level International Service
• One of the services for the framework applications
• Provides a set of convenience methods on top of low-level internationalization API
• Manages the international preferences object according to the application context
• The preferences object is persisted using a framework service.
![Page 50: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/50.jpg)
18th International Unicode Conference Hong Kong, April 200150
Hierarchy of Internationalization APIsHierarchy of Internationalization APIs
High-level International Service
Application (Tivoli Products)
ICU4J
Low-level Internationalization API
JDK Locale Sensitive Classes
preference
UI Lib.
International Preference-based APIICU4J: International Components for Unicode for Java
![Page 51: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/51.jpg)
18th International Unicode Conference Hong Kong, April 200151
Methods on International ServiceMethods on International Service
• Resource Loading– getBundle, getString, getObject
• Date Formatting– formatDate, formatTime,
formatDateTime, parseDate, parseTime, parseDateTime
• Number Formatting– formatNumber, formatCurrency,
formatPercent, parseNumber, parseCurrency, parsePercent
• Message Formatting– formatMessage, parseMessage
• Collator Factory Method– getCollator
• BreakIterator Factory Method– getCharacterBreakIterator,
getWordBreakIterator, getLineBreakIterator, getSentenceBreakIterator
• Case Conversion / Comparison– toLowerCase, toUpperCase,
equalsIgnoreCase
• Late-binding Text Resolution– getDisplayText
• IntlPreferences Access– getIntlPreferences
• com.tivoli.pf.fmk.external.IFmkIntlService
![Page 52: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/52.jpg)
18th International Unicode Conference Hong Kong, April 200152
AgendaAgenda• Introduction• Requirements for Internationalization• Difficulties with JDK• Approach
– Use of ICU4J– Low-level Internationalization API– High-level Framework Service
• Layer Separation• High-level Framework Service• Rewrite Example• International Preferences Notebook• Example
• Conclusion• Q&A
![Page 53: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/53.jpg)
18th International Unicode Conference Hong Kong, April 200153
Rewrite example 1: format a dateRewrite example 1: format a date
String dateDisplay = intlService.formatDate(aContext, aDate);
// works according to the user’s international preferences
DateFormat df = DateFormat.getDateTimeInstance();String dateDisplay = df.format(aDate);
// everything is based on the default locale
![Page 54: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/54.jpg)
18th International Unicode Conference Hong Kong, April 200154
Rewrite example 2: format a messageRewrite example 2: format a message
String msg = intlService.getString(aContext, "MessageResources", MessageResources.MSG0001, new Object[] {aDate});
// works according to the user’s international preferences
// everything is based on the default locale
ResourceBundle rb = ResourceBundle.getBundle("MessageResources");String msgPattern = rb.getString(MessageResources.MSG0001);MessageFormat mf = new MessageFormat(msgPattern);String msg = mf.format(new Object[] {aDate});
![Page 55: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/55.jpg)
18th International Unicode Conference Hong Kong, April 200155
AgendaAgenda• Introduction• Requirements for Internationalization• Difficulties with JDK• Approach
– Use of ICU4J– Low-level Internationalization API– High-level Framework Service
• Layer Separation• High-level Framework Service• Rewrite Example• International Preferences Notebook• Example
• Conclusion• Q&A
![Page 56: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/56.jpg)
18th International Unicode Conference Hong Kong, April 200156
International Preference NotebookInternational Preference Notebook
![Page 57: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/57.jpg)
18th International Unicode Conference Hong Kong, April 200157
Preference Notebook Preview ExamplePreference Notebook Preview Example
Region: USStyle: MediumCalendar: GregorianTime Zone: CST
![Page 58: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/58.jpg)
18th International Unicode Conference Hong Kong, April 200158
Preference Notebook Preview ExamplePreference Notebook Preview Example
Region: FranceStyle: MediumCalendar: GregorianTime Zone: Paris
![Page 59: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/59.jpg)
18th International Unicode Conference Hong Kong, April 200159
Preference Notebook Preview ExamplePreference Notebook Preview Example
Region: JapanStyle: FullCalendar: Japanese-eraTime Zone: Tokyo
![Page 60: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/60.jpg)
18th International Unicode Conference Hong Kong, April 200160
AgendaAgenda• Introduction• Requirements for Internationalization• Difficulties with JDK• Approach
– Use of ICU4J– Low-level Internationalization API– High-level Framework Service
• Layer Separation• High-level Framework Service• Rewrite Example• International Preferences Notebook• Example
• Conclusion• Q&A
![Page 61: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/61.jpg)
18th International Unicode Conference Hong Kong, April 200161
Example – Message DialogExample – Message Dialog
Language: English
Region: US
![Page 62: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/62.jpg)
18th International Unicode Conference Hong Kong, April 200162
Example – Message DialogExample – Message Dialog
Language: Simplified Chinese
Region: US
![Page 63: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/63.jpg)
18th International Unicode Conference Hong Kong, April 200163
Example – Message DialogExample – Message Dialog
Language: French
Region: France
![Page 64: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/64.jpg)
18th International Unicode Conference Hong Kong, April 200164
Example – Message DialogExample – Message Dialog
Language: French
Region: Greece
![Page 65: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/65.jpg)
18th International Unicode Conference Hong Kong, April 200165
Example – Message DialogExample – Message Dialog
Language: JapaneseRegion: JapanCalendar: Japanese
![Page 66: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/66.jpg)
18th International Unicode Conference Hong Kong, April 200166
AgendaAgenda
• Introduction• Requirements for Internationalization• Difficulties with JDK• Approach• Conclusion
– For Requirements…1. Global multi-user support2. Multiple locales for a single user3. End-user Customization4. Advanced Features
– Benefits
• Q&A
![Page 67: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/67.jpg)
18th International Unicode Conference Hong Kong, April 2001
ConclusionConclusion
![Page 68: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/68.jpg)
18th International Unicode Conference Hong Kong, April 200168
For req.1: Global multi-user supportFor req.1: Global multi-user support
• In high-level international service layer, the user’s locale and time zone is managed according to the application context.
• Each user’s preference settings are persistent across the network.
![Page 69: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/69.jpg)
18th International Unicode Conference Hong Kong, April 200169
For req.2: Multiple locales for a single userFor req.2: Multiple locales for a single user
• Multiple locales are encapsulated in the international preferences object.
• Low-level API uses appropriate locale from the preferences object.
![Page 70: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/70.jpg)
18th International Unicode Conference Hong Kong, April 200170
For req.3: End-user CustomizationFor req.3: End-user Customization
• Various attributes for customization encapsulated in an object. It simplifies API usage.
• User can alter the object through preference notebook GUI.
![Page 71: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/71.jpg)
18th International Unicode Conference Hong Kong, April 200171
For req.4: Advanced featuresFor req.4: Advanced features
• Multi-cultural calendar systems are supported• ICU4J is used as core internationalization
API. More feature will be used in the future releases.
![Page 72: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/72.jpg)
18th International Unicode Conference Hong Kong, April 200172
Benefits for end-usersBenefits for end-users
• Flexible customization• Functionality for multiple-locale• Consistent presentation
![Page 73: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/73.jpg)
18th International Unicode Conference Hong Kong, April 200173
Benefits for application developerBenefits for application developer
• High-level International Service can be used as a single point to provide internationalization API
• Various internationalization attributes are encapsulated into an object to make API usage simple
• International preference-based Swing widgets
![Page 74: 18th International Unicode Conference Hong Kong, April 2001 Preference Object-based Internationalization for Distributed Application Framework in Java](https://reader036.vdocument.in/reader036/viewer/2022062618/55150757550346a87d8b466a/html5/thumbnails/74.jpg)
18th International Unicode Conference Hong Kong, April 2001
Questions & AnswersQuestions & Answers