Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Internationalization

823 views

Published on

Introductory presentation on Internationalization.

Published in: Education, Technology
  • Be the first to comment

Internationalization

  1. 1. Internationalization
  2. 2. Agenda  What is Internationalization  What it offers  Sample Application  How to use it  Best Practices  Questions
  3. 3. What is Internationalization  Internationalization (i18n) the process of changing your software so that it isn't hardwired to one language/locale/culture.  Localization (l10n) the process of adding the appropriate resources to your software so that a particular language/locale is supported.
  4. 4. What is Internationalization  The terms are frequently abbreviated to the numeronyms i18n (where 18 stands for the number of letters between the first i and last n in internationalization, a usage coined at DEC in the 1970s or 80s) and L10n respectively, due to the length of the words.  Some companies, like IBM and Sun Microsystems, use the term "globalization" for the combination of internationalization and localization.  Microsoft defines Internationalization as a combination of World-Readiness and localization. World-Readiness is a developer task, which enables a product to be used with multiple scripts and cultures (globalization) and separating user interface resources in a localizable format (localizability, abbreviated to L12y).
  5. 5. What it offers  Build once, sell anywhere  Modularity demands it!  Ease of translation  “With the addition of localization data, the same executable can be run worldwide.”
  6. 6. Characteristics  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.  Support for new languages does not require recompilation.  Other culturally-dependent data, such as dates and currencies, appear in formats that conform to the end-user's region and language.
  7. 7. Sample Application  Before Internationalization  After Internationalization
  8. 8. Before Internationalization
  9. 9. After Internationalization % java I18NSample fr FR Bonjour. Comment allez-vous? Au revoir. % java I18NSample en US Hello. How are you? Goodbye.
  10. 10. How does it work 1) Create Properties Files 2) Define the Locale 3) Create Resource Bundle 4) Fetch Text from Resource Bundle
  11. 11. Properties file  A properties file stores information about the characteristics of a program or environment. A properties file is in plain-text format.  E.g. greetings = Hello farewell = Goodbye inquiry = How are you?
  12. 12. Locale  The Locale object identifies a particular language     and country. has the form xx_YY xx is two-character language code (ISO-639) YY is two-character country code (ISO-3166) Examples:  en_US - United States English  en_GB - Great Britain English  es_MX - Mexico Spanish (Espanol)
  13. 13. 1) Create Properties file  MessagesBundle_fr_FR.properties greetings = Bonjour. farewell = Au revoir. inquiry = Comment allez-vous?  Keys remains same, values changes
  14. 14. 2) Define the locale
  15. 15. 3) Create a ResourceBundle
  16. 16. 4) Fetch Text from ResourceBundle
  17. 17. What may need Internationalization  Just a few thing  And some more  messages • numbers  labels on GUI • currencies        components online help sounds colors graphics icons dates times • measurements • phone numbers • honorifics and personal titles • postal addresses • page layouts
  18. 18. What’s easily translatable?  Status messages  Error messages  Log file entries  GUI component labels  BAD! Button okButton = new Button(“OK”);  GOOD! String okLabel = ButtonLabel.getString("OkKey"); Button okButton = new Button(okLabel);
  19. 19. What’s NOT (easily translatable)?  “At 1:15 PM on April 13, 1998, we attack the 7 ships on Mars.” MessageBundle_en_US.properties template = At {2,time,short} on {2,date,long}, we attack the {1,number,integer} ships on planet {0}. planet = Mars The time portion of a Date object. The "short" style specifies the DateFormat.SHORT formatting style. 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. A Number object, further qualified with the "integer" number style. The String in the ResourceBundle that corresponds to the "planet" key.
  20. 20. 1. Compound Messages: messageArguments...  Set the message arguments…  Remember the numbers in the template refer to the index in messageArguments!
  21. 21. 2. Compound Messages: create formatter...  Don’t forget setting the Locale of the formatter object...
  22. 22. 3. Compound Messages:  Get the template we defined earlier…  Then pass in our arguments!  And finally RUN...
  23. 23. 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 13.15 Uhr am 13. April 1998 haben wir 7 Raumschiffe auf dem Planeten Mars entdeckt.
  24. 24. What’s NOT (easily translatable)?  Plurals! There There There are no files is one file are 2 files on XDisk. on XDisk. on XDisk. Also variable... 3 possibilities for output templates. Possible integer value in one of the templates.
  25. 25. Plurals ChoiceBundle_en_US.properties pattern = There {0} on {1}. noFiles = are no files oneFile = is one file multipleFiles = are {2} files noFiles = are no files oneFile = is one file multipleFiles = are {2} files There are 2 files on XDisk.
  26. 26. Plurals  What’s different?  Now we even index our templates… see fileStrings, indexe d with fileLimits.  First create the array of templates.
  27. 27. Sample Run currentLocale = en_US There There There There are no files on XDisk. is one file on XDisk. are 2 files on XDisk. are 3 files on XDisk. currentLocale = fr_FR Il Il Il Il n' y a pas des y a un fichier y a 2 fichiers y a 3 fichiers fichiers sur XDisk. sur XDisk. sur XDisk. sur XDisk.
  28. 28. Numbers  Supported through NumberFormat! o Shows what locales are available. Note, you can also Locale[] create custom formats if needed. locales = NumberFormat.getAvailableLocales(); 345 987,246 345.987,246 345,987.246 fr_FR de_DE en_US
  29. 29. Currency  Supported with: NumberFormat.getCurrencyInstance! 9 876 543,21 F fr_FR 9.876.543,21 DM de_DE $9,876,543.21 en_US
  30. 30. A Date and Time  Supported with:  DateFormat.getDateInstance DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, currentLocale);  DateFormat.getTimeInstance DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.DEFAULT, currentLocale);  DateFormat.getDateTimeInstance DateFormat dateTimeFormatter = DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.LONG, currentLocale);
  31. 31. Date example  Supported with: DateFormat.getDateInstance 9 avr 98 9.4.1998 09-Apr-98 fr_FR de_DE en_US
  32. 32. Unicode Characters  16 bit!  65,536 characters  Encodes all major languages  In Java Char is a Unicode character  See unicode.org/ Future Use ASCII 0x0000 Greek Kana Symbols Internal 0xFFFF
  33. 33. Java support for the Unicode Char  Character API:        isDigit isLetter isLetterOrDigit isLowerCase isUpperCase isSpaceChar isDefined  Unicode Char values accessed with: String eWithCircumflex = new String("u00EA");
  34. 34. Java support for the Unicode Char  Example of some repair…  BAD! if ((ch  GOOD!>= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) // ch is a letter if (Character.isLetter(ch)) // ch is a letter
  35. 35. Java support for the Unicode Char  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”
  36. 36. Next Steps - Internationalization  Expedite and make necessary business decisions  Identify the scope and timelines for internationalization  Implement design and code changes
  37. 37. Localization  Identify the specific localization need  Country / Culture  Language(s) to be supported  Pages / Interfaces / data elements to be localized  Translation  Language experts for translation  Localize content (text, graphics, etc)  Build a translation database, if required  Implement design & code changes that may arise
  38. 38. Questions
  39. 39. Thank you ..
  40. 40. References:  http://docs.oracle.com/javase/tutorial/i18n/index.h tml  https://www.slideshare.net  https://www.google.com  http://gwt.googleusercontent.com/samples/Showc ase/Showcase.html

×