Copyright, 1998 © Alexander Schonfeld TIP Try and stay awake… kick sleeping neighbors. Don’t blink!

Slides:



Advertisements
Similar presentations
Advanced.Net Framework 2.0 David Ringsell MCPD MCSD MCT MCAD.
Advertisements

JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Introduction to Programming G51PRG University of Nottingham Revision 1
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Chapter 2: Algorithm Discovery and Design
8 November Forms and JavaScript. Types of Inputs Radio Buttons (select one of a list) Checkbox (select as many as wanted) Text inputs (user types text)
Internationalization of Java Platform Presenter: Ataru Nakazawa Advisor: Xiaoping Jia Date: January 23, 2004.
Characters and Strings. Characters In Java, a char is a primitive type that can hold one single character A character can be: –A letter or digit –A punctuation.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 2: Algorithm Discovery and Design
Object-oriented Programming in Java. © Aptech Ltd. Internationalization and Localization/Session 12 2  Describe internationalization  Describe localization.
NU Data Excel Orientation Graphing of Screening Data and Basic Graphing Functions.
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
Creating a Web Page HTML, FrontPage, Word, Composer.
CH1 – A 1 st Program Using C#. Program Set of instructions which tell a computer what to do. Machine Language Basic language computers use to control.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Software Engineering 2003 Jyrki Nummenmaa 1 GLOBALISATION I bet it is quite natural to dream about writing software that is being sold around.
Sophia Antipolis, September 2006 Multilinguality, localization and internationalization Miruna Bădescu Finsiel Romania.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
A First Program Using C#
AITI Tutorial: Internationalization Coding for the world MIT AITI July NNth, 2005.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
Internationalization (I18N) Sufficiency Testing Presented to Seattle Area Software Quality Assurance Group June 19, 2003.
Sakai: Localization & Internationalization Beth Kirschner University of Michigan
Going Global: Internationalization with Java Sue Davis Rochester Java Users Group November 15, 2000.
SOFTWARE INTERNATIONALIZATION Dallas Ramsden. Internationalization GOAL Software that can run ANYWHERE in the world without having the source code changed.
Georgia Institute of Technology Creating and Modifying Text part 1 Barb Ericson Georgia Institute of Technology Oct 2005.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
L10n and I18n in the Real World Dan Moore Moore Consulting June 9, 2005.
Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Internationalisation.
Internationalization and the Java Stack Matt Wheeler.
 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(1/16) Internationalization and Locales Joel Adams and Jeremy Frens Calvin.
Invitation to Computer Science, Java Version, Second Edition.
Company Confidential 1 This presentation is solely for the use of Patni personnel. No part of it may be circulated, quoted, or reproduced for distribution.
Presenting results to the USER in a professional manner 1. semicolon, disp(), fprintf() 2. Placeholders 3. Special characters 4. Format-modifiers Output.
CIS 218 Advanced UNIX1 CIS 218 – Advanced UNIX (g)awk.
ITP © Ron Poet Lecture 3 1 Comments. ITP © Ron Poet Lecture 3 2 Legibility  It is important that programs are easy to read.  It is easier to find bugs.
Chapter 14 Internationalization F Processing Date and Time –Locale –Date –TimeZone –Calendar and GregorianCalendar –DateFormat and SimpleDateFormat F Formatting.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 26 Internationalization.
Chapter 12: Internationalization Processing Date and Time Processing Date and Time  Locale  Date  TimeZone  Calendar and GregorianCalendar  DateFormat.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
An Introduction to Java Programming and Object-Oriented Application Development Chapter 7 Characters, Strings, and Formatting.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
Copenhagen, 6 June 2006 EC CHM Multilinguality Anton Cupcea Finsiel Romania.
A Simple Guide to Using SPSS ( Statistical Package for the Social Sciences) for Windows.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Asking the USER for values to use in a software 1 Input.
Chapter 14 Internationalization F Processing Date and Time –Locale –Date –TimeZone –Calendar and GregorianCalendar –DateFormat and SimpleDateFormat F Formatting.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 1 Other GUI components In this section, we will.
Asking the USER for values to use in a software 1 Input.
1 Chapter 20 Internationalization. 2 Objectives F To describe Java's internationalization features (§ 20.1). F To construct a locale with language, country,
Internationalization Slide 1©SoftMoore Consulting.
Understanding Character Encodings Basics of Character Encodings that all Programmers should Know. Pritam Barhate, Cofounder and CTO Mobisoft Infotech.
Aside: Running Supplied *.java Programs Just double clicking on a *.java file may not be too useful! 1.In Eclipse, create a project for this program or.
CSE1222: Lecture 1The Ohio State University1. Computing Basics  Computers CPU, Memory & Input/Output (IO)  Program Sequence of instructions for the.
Word and the Writing Process. To create a document 1.On the Start menu, point to Programs, and then click Microsoft Word. A new document opens in Normal.
17-Mar-16 Characters and Strings. 2 Characters In Java, a char is a primitive type that can hold one single character A character can be: A letter or.
Module 1 Introduction to JavaScript
Unit 2.6 Data Representation Lesson 2 ‒ Characters
Chapter 14 Internationalization
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
JavaScript Syntax and Semantics
Word Processing.
Intro to PHP & Variables
Creating your first C program
Chapter 35 Internationalization
Presentation transcript:

Copyright, 1998 © Alexander Schonfeld TIP Try and stay awake… kick sleeping neighbors. Don’t blink!

Introduction Internationalization (i18n) is the process of designing an application so that it can be adapted to different languages and regions, without requiring engineering changes. Localization (l10n) is the process of adapting software for a specific region or language by adding locale-specific components and translating text.

Organization of Presentation n What is i18n? n Java example of messages n What is a “locale”? n Formatting data in messages n Translation issues n Date/Time/Currency/etc n Unicode and support in Java n Iteration through text

Why is i18n important? n Build once, sell anywhere… n Modularity demands it! –Ease of translation n “With the addition of localization data, the same executable can be run worldwide.”

Characteristics of i18n... n Textual elements such as status messages and the GUI component labels are not hardcoded in the program. Instead, they are stored outside the source code and retrieved dynamically. n Support for new languages does not require recompilation. n Other culturally-dependent data, such as dates and currencies, appear in formats that conform to the end-user's region and language.

Really why… n Carmaggedon

The rest is Java… why? n Java: –is readable! –has most complete built-in i18n support. –easily illustrates correct implementation of many i18n concepts. –concepts can be extended to any language. n For more info see: n n java.sun.com/docs/books/tutorial/i18n

Java Example: Messages... Before: System.out.println("Hello."); System.out.println("How are you?"); System.out.println("Goodbye.");

Too much code! After:

Sample Run… % java I18NSample fr FR Bonjour. Comment allez-vous? Au revoir. % java I18NSample en US Hello. How are you? Goodbye.

Created, which contains these lines: Created MessagesBundle_fr_FR.properties, which contains these lines: (What the translator deals with.) n In the English one? 1. So What Just Happened? greetings = Bonjour. farewell = Au revoir. inquiry = Comment allez-vous?

n Look! 2. Define the locale...

n Look! 3. Create a ResourceBundle...

n Look! 4. Get the Text from the ResourceBundle...

What is a “locale”? n Locale objects are only identifiers. n After defining a Locale, you pass it to other objects that perform useful tasks, such as formatting dates and numbers. n These objects are called locale-sensitive, because their behavior varies according to Locale. n A ResourceBundle is an example of a locale- sensitive object.

Did you get that? currentLocale = new Locale(language, country); message = ResourceBundle.getBundle("MessagesBundle",currentLocale); MessagesBundle_en_US.properties MessagesBundle_fr_FR.properties MessagesBundle_de_DE.properties greetings = Bonjour. farewell = Au revoir. inquiry = Comment allez-vous? “fr” “FR” message.getString(“inquiry”)

Got a program… need to… n What do I have to change? n What’s easily translatable? n What’s NOT? –“It said 5:00pm on that $5.00 watch on May 5th!” –“There are 5 watches.” n Unicode characters. n Comparing strings.

What do I have to change? n Just a few things… n messages n labels on GUI components n online help n sounds n colors n graphics n icons n dates n times n numbers n currencies n measurements n phone numbers n honorifics and personal titles n postal addresses n page layouts

What’s easily translatable? Isolate it! n Status messages n Error messages n Log file entries n GUI component labels –BAD! –GOOD! Button okButton = new Button(“OK”); String okLabel = ButtonLabel.getString("OkKey"); Button okButton = new Button(okLabel);

template = At {2,time,short} on {2,date,long}, we attack \ the {1,number,integer} ships on planet {0}. planet = Mars What’s NOT ? What’s NOT (easily translatable) ? n “At 1:15 PM on April 13, 1998, we attack the 7 ships on Mars.” MessageBundle_en_US.properties The String in the ResourceBundle that corresponds to the "planet" key. The date portion of a Date object. The same Date object is used for both the date and time variables. In the Object array of arguments the index of the element holding the Date object is 2. The time portion of a Date object. The "short" style specifies the DateFormat.SHORT formatting style. A Number object, further qualified with the "integer" number style.

What’s NOT = “Compound Messages” n Example!

1. Compound Messages: messageArguments... n Set the message arguments… n Remember the numbers in the template refer to the index in messageArguments!

2. Compound Messages: create formatter... n Don’t forget setting the Locale of the formatter object...

3. Compound Messages: n Get the template we defined earlier… n Then pass in our arguments! n And finally RUN...

Sample Run… currentLocale = en_US At 1:15 PM on April 13, 1998, we attack the 7 ships on the planet Mars. currentLocale = de_DE Um Uhr am 13. April 1998 haben wir 7 Raumschiffe auf dem Planeten Mars entdeckt. (Note: I modified the example and don’t speak German so couldn’t translate my changes so the German does not match.)

What’s NOT ? What’s NOT (easily translatable) ? n Answer = Plurals! There are no files on XDisk. There is one file on XDisk. There are 2 files on XDisk. 3 possibilities for output templates. Possible integer value in one of the templates. Also variable...

pattern = There {0} on {1}. noFiles = are no files oneFile = is one file multipleFiles = are {2} files Plurals(s)’ses!?! ChoiceBundle_en_US.properties noFiles = are no files oneFile = is one file multipleFiles = are {2} files There are 2 files on XDisk.

Plurals! n What’s different? n Now we even index our templates… see fileStrings, indexed with fileLimits. n First create the array of templates.

How = n Not just a pattern... n Now we have formats too...

And... n Before we just called format directly after applyPattern... n Now we have setFormats too. n This is required to give us another layer of depth to our translation.

Sample Run… currentLocale = en_US There are no files on XDisk. There is one file on XDisk. There are 2 files on XDisk. There are 3 files on XDisk. currentLocale = fr_FR Il n' y a pas des fichiers sur XDisk. Il y a un fichier sur XDisk. Il y a 2 fichiers sur XDisk. Il y a 3 fichiers sur XDisk.

Numbers and Currencies! n What’s wrong with my numbers? –We say: –Germans say: –French say: 345, , ,246

Numbers... n Supported through NumberFormat! n Shows what locales are available. Note, you can also create custom formats if needed. Locale[] locales = NumberFormat.getAvailableLocales(); ,246 fr_FR ,246 de_DE 345, en_US

Money! n Supported with: NumberFormat.getCurrencyInstance! ,21 F fr_FR ,21 DM de_DE $9,876, en_US

Percents? n Supported with: NumberFormat.getPercentInstance!

“A Date and Time… n Supported with: –DateFormat.getDateInstance –DateFormat.getTimeInstance –DateFormat.getDateTimeInstance DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.DEFAULT, currentLocale); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, currentLocale); DateFormat dateTimeFormatter = DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.LONG, currentLocale);

Date example... n Supported with: DateFormat.getDateInstance! 9 avr 98 fr_FR de_DE 09-Apr-98 en_US

Characters... Characters... n 16 bit! n 65,536 characters n Encodes all major languages n In Java Char is a Unicode character n See unicode.org/ 0x00000xFFFF ASCII Greek Symbols Kana Future Use Internal etc...

Java support for the Unicode Char... n Character API: –isDigit –isLetter –isLetterOrDigit –isLowerCase –isUpperCase –isSpaceChar –isDefined n Unicode Char values accessed with: String eWithCircumflex = new String("\u00EA");

Java support for the Unicode Char... n Example of some repair… –BAD! –GOOD! if (Character.isLetter(ch)) // ch is a letter if ((ch >= 'a' && ch = 'A' && ch <= 'Z')) // ch is a letter

Java support for the Unicode Char... n Get the Unicode category for a Char: –LOWERCASE_LETTER –UPPERCASE_LETTER –MATH_SYMBOL –CONNECTOR_PUNCTUATION –etc... if (Character.getType('_') == Character.CONNECTOR_PUNCTUATION) // ch is a “connector”

Comparing Strings n Called “string collation” n Collation rules provided by the Collator class n Rules vary based on Locale n Note: –can customize rules with RuleBasedCollator –can optimize collation time with CollationKey Strings of the world unite!

Collator! n As always make a new class... n Note the Unicode char definitions. n Finally note the use of the collator.compare

Sample Run! n The English Collator returns: n According to the collation rules of the French language, the preceding list is in the wrong order. In French, "pêche” should follow "péché" in a sorted list. The French Collator thus returns: peach péché pêche sin peach pêche péché sin

Detecting Text Boundaries n Important for? Word processing functions such as selecting, cutting, pasting text… etc. (double-click and select) n BreakIterator class (imaginary cursor) –Character boundaries getCharacterInstance –Word boundaries getWordInstance –Sentence boundaries getSentenceInstance –Line boundaries getLineInstance Beware!!! The END of the word is coming!

BreakIterator: n First we create our wordIterator. n Then attach the iterator to the target text. n Loop through the text finding boundaries and set them to carrets in our footer string. She stopped. She said, "Hello there," and then went on. ^ ^^ ^^ ^ ^^ ^^^^ ^^ ^^^^ ^^ ^^ ^^ ^

BreakIterator: n You see this n Although this word contains three user characters, it is composed by six Unicode characters: n Really only 3 user characters… (Imagine the characters masked on top of each other…) = String house = "\u0628" + "\u064e" + "\u064a" + "\u0652" + "\u067a" + "\u064f"; I only speak English... Arabic for “house”

BreakIterator: n First note creating the Arabic/Saudi Arabia Locale. n Then notice our 6 Unicode char of text. n Looping through the text finding boundaries yields only 3 breaks after the beginning

n It works with: n Problems with: BreakIterator: Please add 1.5 liters to the tank! “It’s up to us.” ^ ^ ^ "No man is an island... every man... " ^ ^ ^ ^ ^ ^^ My friend, Mr. Jones, has a new dog. The dog's name is Spot. ^ ^

n Returns places where you can split a line (good for word wrapping) : n According to a BreakIterator, a line boundary occurs after the end of a sequence of whitespace characters (space, tab, newline). BreakIterator: She stopped. She said, "Hello there," and then went on. ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^

n Java provides: BreakIterator: FileInputStream fis = new FileInputStream("test.txt"); InputStreamReader defaultReader = new InputStreamReader(fis); String defaultEncoding = defaultReader.getEncoding(); Unicode chars InputStreamReader OutputStreamWriter Unicode chars Non-Unicode FileOutputStream fos = new FileOutputStream("test.NEW"); Writer out = new OutputStreamWriter(fos, "UTF8"); Output encoding format

n For more info on i18n and: –W3C and i18n n The future of HTTP, HTML, XML, CSS2… –GUIs –The OTHER character sets… n Scary stuff… those ISO standards –UNIX/clones n C programming for i18n n X/Open I18N Model Go forth and internationalize...