Going Global Internationalization with Java Sue Davis Rochester
Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000 August 1999
Agenda ü ü ü ü Introduction Definition of Internationalization Why internationalize? Highlight some aspects of internationalization Java internationalization classes Simple Demonstration Closing thoughts Q&A November 2000 2
Introduction ý My background in internationalization þ Scope of internationalization ý Software ý Documentation/On-line Help ý Testing ý Training ý Legal considerations ý Marketing November 2000 3
Introduction z Internationalization is the process of designing and developing products enabled for simultaneous shipment (Sim Ship) to both domestic and world markets. November 2000 4
Terms and Abbreviations z z z z z Localization Globalization Locale Diacritic Folding Decomposed character Pre-composed character MBCS DBCS November 2000 z z z z Unicode UTF-8 I 18 N G 11 N L 10 N NLS IME Glyph 5
Why Internationalization Is Important ý North America represents only 1/3 of the world economy ý Europe, Latin America, Japan and Asia Pacific represent more than 1/2 ý Subtle differences even in other English speaking counties ý Localization is expensive ý Maintain one set of source, ship one binary for multiple locales November 2000 6
Motivated self interest ü Try “Internationalization or i 18 n” on major job search engine ü Internationalization positions at other major corporations ü Sun: Internationalization Architect ü Apple: Internationalization Technology Evangelist ü Compaq: I 18 N/L 10 N Development Manager ü Kodak: Product Internationalization Manager ü The Web has made it easier than ever to reach the global market. Expect this to be skill that is in demand. November 2000 7
What does it mean to Internationalize ý Externalize text, icons, sound. ý Design for expansion of translated text ý Use of culturally neutral graphics whenever possible ý Automatically format of dates and numbers as appropriate to the locale ý Consistent use of terminology, correct grammar, avoid slang ý Managing various character encoding schemes ý And more. . . November 2000 8
Design for expansion of translated text þ English is very compact language þ If target markets include Asian countries, allow additional vertical spacing. þ Negatives if the UI has to be redesigned to be usable after translation: ü Longer time to market ü Higher localization costs ü Higher maintenance costs ü Localization of Training, Help, & User documentation becomes more complicated November 2000 9
English length (in characters) Additional growth for localized strings* 1 to 4 100% 5 to 10 80% 11 to 20 60% 21 to 30 40% 31 to 50 20% 51+ 10% * From MSDN, VB Concepts, Designing an International Aware User Interface November 2000 10
Use culturally/linguistically neutral graphics ý Don’t use a Christmas Tree and Champagne glass as a “holiday” icon ý Keep text off graphics ý Don’t use homonyms as a basis for icons November 2000 11
Use culturally/linguistically neutral graphics Continued. . . Are any of these neutral? November 2000 12
Let’s talk about Java! ý What are some of the important Java classes for internationalization? ý Locale ý Resource. Bundle, specifically List. Resource. Bundle ý Number. Format ý Date. Format ý Collator ý Collation. Key ý Rule. Based. Collator ý Break. Iterator November 2000 13
The Locale class ý A Locale is defined as a combination of language, country and variant ý Two character ISO codes for both language and country. ý Language codes are all lower case (ISO 639) ý Country codes are upper case (ISO 3166) ý Variants are “ad hoc” - most frequently used to specify Euro currency November 2000 14
Externalize text, icons, sound ü Resources reside in a resource file that is separate from the application. ü Java - Resource Bundle ü Don’t combine phrases to make sentences ü Makes the executable language independent ü Isolates resources for translation and localization ü Can enable a new locale by just installing the appropriate Resource Bundle. (in theory) November 2000 15
What is a Resource. Bundle? ü A Resource. Bundle (java. util. Resource. Bundle) is an abstract class with two concrete subclasses: ü Property. Resource. Bundle (limited use, not recommended) ü List. Resource. Bundle ý Consists of minimally a “base” class extending Property. Resource. Bundle ý Locale specific resources are added by creating additional classes with language and country extentions November 2000 16
Using Property. Resource. Bundle Create the baseline Resource. Bundle class Demo. Resource extends Property. Resouce. Bundle { public Object[][] get. Contents() {return contents; } static final Object[][] contents = { // Localize right hand object {"Sample. Key", "translatable text"}, // helpful hint {"Hello. World. Key", "Hello World"}, {"Menu. File. Key", "File"}, {"Menu. File. Exit. Key", "Exit"}, {"Menu. Help. Key", "Help"}, {"Menu. Help. About. Key", "About"}, }; } November 2000 17
Begin Localizing your Resource. Bundles Create a language specific Resource. Bundle class Demo. Resource_fr extends Property. Resouce. Bundle { public Object[][] get. Contents() {return contents; } static final Object[][] contents = { // Localize right hand object {"Hello. World. Key", "Bonjour Monde"}, {"Menu. File. Key", "Fichier"}, {"Menu. File. Exit. Key", "Quittent"}, {"Menu. Help. Key", "Aide"}, {"Menu. Help. About. Key", "Au sujet de"}, }; } November 2000 18
Localize Resource. Bundles for language & country Create a locale specific Resource. Bundle class Demo. Resource_fr_FR extends Property. Resouce. Bundle { public Object[][] get. Contents() {return contents; } static final Object[][] contents = { // Localize right hand object {"Hello. World. Key", "Bonjour Monde for France"}, }; } November 2000 19
Cascading Resource Bundles Why you don’t need to redefine every key in Demo. Resource_fr_FR ü Resource. Bundles cascade from most specific locale information down to the base, in this case, Demo. Resource ü So if your Locale is Locale. FRANCE (or Locale(“fr”, “FR”) ) the code will search the Resource. Bundle classes for the key in the following order: = Demo. Resource_fr_FR = Demo. Resource ü An exception is thrown if the key is not found in ANY of these classes November 2000 20
Lets look at some code ü Using Resource. Bundles in Packages ü Package name MUST be the same as the bundle’s base name ü The Resource. Bundle class must be FULLY qualified ü Do not need to import the package November 2000 21
Formatting Text Messages Sometimes there’s no way around it. You HAVE to have variables integrated into the message. Remember sentence structures vary between languages, so you need to give your translator a way to move things around without breaking the code November 2000 22
Java to the rescue The class Message. Format allows you to number the placeholders for your variables: In your Resource. Bundle … {“key”, “my formatted {1} message is very {2}”} // helpful hints to the translator go here In your code… my. Obj. value = Message. Format. format( rb. get. String(“key”), new Object( varible 1, variable 2) ) ); November 2000 23
Automatic formatting of dates and numbers as appropriate to the locale Date formats vary from country to country, even among English speaking counties. Long Date examples: US: Thursday, August 19, 1999 UK: 19 August 1999 DE: Donnerstag, 19. August 1999 FR: jeudi 19 aôut 1999 November 2000 24
Automatic formatting continued. . . Date formats vary from country to country, even among English speaking counties. Short Date examples: US: 8/19/99 UK: 19/08/99 DE: 19. 08. 99 FR: 19/08/99 November 2000 25
Automatic formatting of numbers and currency Numeric examples: US: 1, 234, 567. 89 UK: 1, 234, 567. 89 DE: 1. 234. 567, 89 FR: 1 234 567, 89 Currency $1, 234. 45 £ 1, 234. 45 1. 234, 45 DM 1 234, 45 F Java 1. 1. 6 and later support the Euro November 2000 26
Automatic Formatting in Java ü Available classes ü Date. Format ü Number. Format ü Decimal. Format ü Simple. Date. Format ü Date ü good for storing elapsed time since Jan 1, 1970 GMT ü API assumes the Gregorian Calendar ü Time. Zone ü JDK supports only the Gregorian calendar November 2000 27
Dealing with characters and strings ü Assuming Unicode ý Character traits ý Comparisons and conversions ý Sorting ý Text boundaries November 2000 28
Characters traits ý id. Defined() ý is. Digit() ý is. Letter() ý is. Space()/is. Space. Char()/is. White. Space() ý is. Letter. Or. Digit() ý is. Upper. Case()/is. Lower. Case()/is. Title. Case() ý get. Type() ý get. Numeric. Value() November 2000 29
Comparisons and conversions ý Comparing pre-composed characters with decomposed characters ý String conversions (e. g. to. Upper. Case()) not always “round trip” November 2000 30
Sorting ü Do not use String. compare. To() for natural language text. ý Use Collator to compare locale sensitive strings ý Use Collation. Key to sort long lists ý Rule. Based. Collator ý Character folding (ignore diacritics résumé vs. resume) November 2000 31
Tools to help you go global. . . ü Internationalizing source code ü One Realm ü Uniscape ü Java ü Machine Translation/Machine Assisted Translation ü Consulting ü Internationalization - small but growing ü Localization - Lots ü Training - Minimal, usually in conjunction with a product purchase or consulting contract November 2000 32
Use terms consistently Use correct grammar, avoid slang þ Facilitates the use of Machine Assisted Translation tools þ Helps minimize questions from translators þ Impacts Developers, Documentation, QA November 2000 33
Closing Thoughts ü EJAL: English is Just Another Language ü Anything is fair game for localization, including corporate names and logos. ü Internationalization is NOT a feature. ü Internationalization IS a design issue ü Internationalization shortens and simplifies the localization process. ü Rapid deployment, improved time to market ü Lower maintenance time & costs ü Frees development resources for new product development November 2000 34
Not Discussed Using third party software Sorting Text boundary conditions Accelerator keys Color Software Architecture Configuration Management Issues Legal requirements Bi-directional languages Different calendars (Hebrew, Japanese Imperial, Buddhist, Islamic…) November 2000 35
Recommended Reading þ Java. World, Internationalize Your Software, Geoff Friesen part 1, part 2, and part 3 Internationalization: Localization with Resource bundles, John O'Conner Global Design Homepage, Richard Ishida Scripting Clinic: Using Script to Internationalize Web Site Functions Localization and the XML/DHTML Menus Developing Global Applications in Java, Richard Gillam Developing International Software for Windows 95 and Windows NT, Nadine Kano, Available electronically on MSDN þ MSDN, Windows Interface Guidelines for Software Design þ þ þ November 2000 36
Questions? ? ? November 2000 37
- Slides: 37