37
Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

Embed Size (px)

Citation preview

Page 1: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

Going Global:Internationalization with Java

Sue DavisRochester Java Users Group

November 15, 2000

Page 2: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 2

Agenda

Introduction Definition of Internationalization Why internationalize? Highlight some aspects of internationalization Java internationalization classes Simple Demonstration Closing thoughts Q&A

Page 3: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 3

Introduction

My background in internationalization

Scope of internationalization Software Documentation/On-line Help Testing Training Legal considerations Marketing

Page 4: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 4

Introduction

Internationalization is the process of designing and developing products enabled for simultaneous shipment (Sim Ship) to both domestic and world markets.

Page 5: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 5

Terms and Abbreviations

Localization Globalization Locale Diacritic Folding Decomposed character Pre-composed character MBCS DBCS

Unicode UTF-8 I18N G11N L10N NLS IME Glyph

Page 6: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 6

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

Page 7: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 7

Motivated self interest

Try “Internationalization or i18n” on major job search engine

Internationalization positions at other major corporations Sun: Internationalization Architect Apple: Internationalization Technology Evangelist Compaq: I18N/L10N 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.

Page 8: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 8

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...

Page 9: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 9

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

Page 10: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 10

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

Page 11: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 11

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

Page 12: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 12

Use culturally/linguistically neutral graphicsContinued...

Mail16b.ico Mail10.icoMsgbox01.ico Msgbox01.ico

Are any of these neutral?

Page 13: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 13

Let’s talk about Java!

What are some of the important Java classes for internationalization? Locale ResourceBundle, specifically ListResourceBundle NumberFormat DateFormat Collator CollationKey RuleBasedCollator BreakIterator

Page 14: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 14

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

Page 15: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 15

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)

Page 16: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 16

What is a ResourceBundle?

A ResourceBundle (java.util.ResourceBundle) is an abstract class with two concrete subclasses: PropertyResourceBundle (limited use, not recommended) ListResourceBundle

Consists of minimally a “base” class extending PropertyResourceBundle

Locale specific resources are added by creating additional classes with language and country extentions

Page 17: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 17

Using PropertyResourceBundle

Create the baseline ResourceBundleclass DemoResource extends PropertyResouceBundle {

public Object[][] getContents() {return contents; } static final Object[][] contents = { // Localize right hand object

{"SampleKey", "translatable text"}, // helpful hint {"HelloWorldKey", "Hello World"},

{"MenuFileKey", "File"}, {"MenuFileExitKey", "Exit"}, {"MenuHelpKey", "Help"}, {"MenuHelpAboutKey", "About"},

};}

Page 18: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 18

Begin Localizing your ResourceBundles

Create a language specific ResourceBundleclass DemoResource_fr extends PropertyResouceBundle {

public Object[][] getContents() {return contents; } static final Object[][] contents = { // Localize right hand

object {"HelloWorldKey", "Bonjour Monde"},

{"MenuFileKey", "Fichier"}, {"MenuFileExitKey", "Quittent"}, {"MenuHelpKey", "Aide"}, {"MenuHelpAboutKey", "Au sujet de"},

};}

Page 19: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 19

Localize ResourceBundles for language & country

Create a locale specific ResourceBundleclass DemoResource_fr_FR extends PropertyResouceBundle {

public Object[][] getContents() {return contents; } static final Object[][] contents = { // Localize right hand

object {"HelloWorldKey", "Bonjour Monde for France"},

};}

Page 20: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 20

Cascading Resource Bundles

Why you don’t need to redefine every key in DemoResource_fr_FR

ResourceBundles cascade from most specific locale information down to the base, in this case, DemoResource

So if your Locale is Locale.FRANCE (or Locale(“fr”, “FR”) ) the code will search the ResourceBundle classes for the key in the following order: DemoResource_fr_FR DemoResource_FR DemoResource

An exception is thrown if the key is not found in ANY of these classes

Page 21: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 21

Lets look at some code

Using ResourceBundles in Packages Package name MUST be the same as the

bundle’s base name The ResourceBundle class must be FULLY

qualified Do not need to import the package

Page 22: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 22

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

Page 23: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 23

Java to the rescue

The class MessageFormat allows you to number the placeholders for your variables:

In your ResourceBundle …{“key”, “my formatted {1} message is very {2}”}

// helpful hints to the translator go here

In your code…myObj.value = MessageFormat.format(

rb.getString(“key”),

new Object(

varible1,

variable2)

)

);

Page 24: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 24

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, 1999UK: 19 August 1999DE: Donnerstag, 19.August 1999FR: jeudi 19 aôut 1999

Page 25: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 25

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/99DE: 19.08.99FR: 19/08/99

Page 26: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 26

Automatic formatting of numbers and currency

Numeric examples: CurrencyUS: 1,234,567.89 $1,234.45UK: 1,234,567.89 £1,234.45DE: 1.234.567,89 1.234,45 DMFR: 1 234 567,89 1 234,45 F

Java 1.1.6 and later support the Euro

Page 27: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 27

Automatic Formatting in Java

Available classes DateFormat NumberFormat DecimalFormat SimpleDateFormat Date

good for storing elapsed time since Jan 1, 1970 GMT API assumes the Gregorian Calendar

Calendar TimeZone

JDK supports only the Gregorian calendar

Page 28: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 28

Dealing with characters and strings

Assuming Unicode Character traits Comparisons and conversions Sorting Text boundaries

Page 29: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 29

Characters traits

idDefined() isDigit() isLetter() isSpace()/isSpaceChar()/isWhiteSpace() isLetterOrDigit() isUpperCase()/isLowerCase()/isTitleCase() getType() getNumericValue()

Page 30: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 30

Comparisons and conversions

Comparing pre-composed characters with decomposed characters

String conversions (e.g. toUpperCase()) not always “round trip”

Page 31: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 31

Sorting

Do not use String.compareTo() for natural language text.

Use Collator to compare locale sensitive strings

Use CollationKey to sort long lists RuleBasedCollator Character folding (ignore diacritics résumé

vs. resume)

Page 32: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 32

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

Page 33: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 33

Use terms consistentlyUse correct grammar, avoid slang

Facilitates the use of Machine Assisted Translation translation tools

Helps minimize questions from translators Impacts Developers, Documentation, QA

Page 34: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 34

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

Page 35: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 35

Not Discussed

Using third party softwareSortingText boundary conditionsAccelerator keysColorSoftware Architecture Configuration Management IssuesLegal requirementsBi-directional languagesDifferent calendars (Hebrew, Japanese Imperial, Buddhist,

Islamic…)

Page 36: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 36

Recommended Reading

JavaWorld, 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 Functio

ns 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

Page 37: Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000

November 2000 37

Questions???