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.
Droidcon Croatia
Danny Preussler
GROUPON
@PreusslerBerlin
All around the World
i18n and l10n in android
http://gizmodo.com...
45 17Millions
downloads
Millions
active users
+
#droidconzg #PreusslerBerlin
Definitions
Page 3
Internationalization (i18n) is the process of developing products in such ...
#droidconzg #PreusslerBerlin
Try not to kill your user...
Page 4
„A Cellphone's Missing Dot Kills Two People, Puts Three M...
#droidconzg #PreusslerBerlin
Locales
Page 5
• Never hardcode text in code or layouts!
(android studio even helps extractin...
#droidconzg #PreusslerBerlin
Locales
Page 6
• How Locale’s work:
#droidconzg #PreusslerBerlin
Locales
Page 7
• How Locale’s work with Android N:
#droidconzg #PreusslerBerlin
Locales
Page 8
• How Locale’s work with Android N:
#droidconzg #PreusslerBerlin
Strings
Page 9
Don’t concatenate strings!
• Order might change in other language for grammar
...
#droidconzg #PreusslerBerlin
Strings
Page 10
Don’t concatenate strings!
• Order might change in other language for grammar...
#droidconzg #PreusslerBerlin
Strings
Page 11
Don’t concatenate strings!
• Use Formatter.format
• Yes even for numbers!
• O...
#droidconzg #PreusslerBerlin
Strings
Page 12
• Plurals
<?xml version="1.0" encoding="utf-8"?>
<resources>
<plurals
name="t...
#droidconzg #PreusslerBerlin
Locales
Page 13
• Don’t reuse your strings too often.
Same names for different things might b...
#droidconzg #PreusslerBerlin
Locales
Page 14
• Test with Pseudo Localization
buildTypes {
debug {
pseudoLocalesEnabled tru...
#droidconzg #PreusslerBerlin
Locales
Page 15
• Careful with default locales:
assertEquals(
“billy”, “BILLY”.toLowerCase())...
#droidconzg #PreusslerBerlin
Numbers
Page 16
https://en.wikipedia.org/wiki/File:Clock-in-cairo-with-eastern-arabic-numeral...
#droidconzg #PreusslerBerlin
Numbers
Page 17
The decimal mark: Dot vs. Comma
1.00$
vs
1,00€
With delimiters:
4,294,967,295...
#droidconzg #PreusslerBerlin
Numbers
Page 18
The decimal mark: Dot vs. Comma
https://en.wikipedia.org/wiki/Decimal_mark
#droidconzg #PreusslerBerlin
Numbers
Page 19
NumberFormat.getNumberInstance(Locale)
NumberFormat.getIntegerInstance(Locale...
#droidconzg #PreusslerBerlin
Currencies
Page 20
#droidconzg #PreusslerBerlin
Currencies
Page 21
• WHICH symbols, if ANY
• WHERE to put the symbol (front or back)?
• How m...
#droidconzg #PreusslerBerlin
Currencies
Page 22
• Never ever use floating point numbers (float or double)
for Money!
Float...
#droidconzg #PreusslerBerlin
Dates
Page 23
#droidconzg #PreusslerBerlin
Dates
Page 24
• 12 hours vs 24 hours
• Timezones
• Daylight Time DST
#droidconzg #PreusslerBerlin
Dates
Page 25
• Careful with calculations and comparison (be aware of DST jumps)
public stati...
#droidconzg #PreusslerBerlin
Dates
Page 26
DateFormat
Careful with custom formats, try to use the standard java one else “...
#droidconzg #PreusslerBerlin
Dates
Page 27
android.text.format.DateUtils
• Has nice methods like:
isToday()
formatDateRang...
#droidconzg #PreusslerBerlin
Units
Page 28
#droidconzg #PreusslerBerlin
Units
Page 29
• Km vs miles
• Celcius vs Fahrenheit
• Liters vs Galons
#droidconzg #PreusslerBerlin
Units
Page 30
Regional differences:
• Structure and Length of telephone numbers
• Elements of...
#droidconzg #PreusslerBerlin
Dubai Airport #1 by emi emi, CC by 2.0; flickr.com/photos/emi_b/4793218993Right-to-Left
#droidconzg #PreusslerBerlin
The signs are in greek by Karl Baron,
flickr.com/photos/kalleboo/6624480775
Dubai Airport #1 ...
#droidconzg #PreusslerBerlin
#droidconzg #PreusslerBerlin
Right-to-Left
#droidconzg #PreusslerBerlin
Right To Left
• Replace left/right with start/end
• Manifest flag:
android:supportsRtl="true"...
#droidconzg #PreusslerBerlin
Cultural context
Page 36
#droidconzg #PreusslerBerlin
Cultural context
Page 37
• Careful with iconography
©wikipedia
#droidconzg #PreusslerBerlin
Thank you
Happy localizing!
Upcoming SlideShare
Loading in …5
×

All around the world, localization and internationalization on Android (DroidCon Zagreb)

627 views

Published on

Android apps are global, they get downloaded all around the world. And this means not only supporting multiple languages via xml files. Its about plurals, date formats, currencies up to things like right-to-left
This topic tries to give an introduction into this large topic for new developers.

Published in: Software
  • Be the first to comment

All around the world, localization and internationalization on Android (DroidCon Zagreb)

  1. 1. Droidcon Croatia Danny Preussler GROUPON @PreusslerBerlin All around the World i18n and l10n in android http://gizmodo.com/5397215/giz-explains-android-and-how-it-will-take-over-the-world
  2. 2. 45 17Millions downloads Millions active users +
  3. 3. #droidconzg #PreusslerBerlin Definitions Page 3 Internationalization (i18n) is the process of developing products in such a way that they can be localized for languages and cultures easily. Localization (l10n), is the process of adapting applications and text to enable their usability in a particular cultural or linguistic market. (docs.angularjs.org) The better internationalized an application is, the easier it is to localize it for a particular language and character encoding scheme. (docs.oracle.com) The main concern (i18n) is that application can be adapted to various languages and regions without engineering changes. (Apple Guidelines)
  4. 4. #droidconzg #PreusslerBerlin Try not to kill your user... Page 4 „A Cellphone's Missing Dot Kills Two People, Puts Three More in Jail“ http://gizmodo.com/382026/a-cellphones-missing-dot-kills-two-people-puts- three-more-in-jail
  5. 5. #droidconzg #PreusslerBerlin Locales Page 5 • Never hardcode text in code or layouts! (android studio even helps extracting to strings.xml) • If needed for layouts use the tools namespace also good for testing long texts: • Never hardcode text in images <TextView android:id="@+id/deal“ android:text="@string/deal_title“ tools:text="deal of killing 2 zombie for one“/>
  6. 6. #droidconzg #PreusslerBerlin Locales Page 6 • How Locale’s work:
  7. 7. #droidconzg #PreusslerBerlin Locales Page 7 • How Locale’s work with Android N:
  8. 8. #droidconzg #PreusslerBerlin Locales Page 8 • How Locale’s work with Android N:
  9. 9. #droidconzg #PreusslerBerlin Strings Page 9 Don’t concatenate strings! • Order might change in other language for grammar • Dangerous in Right-to-Left TextView textView = ... textView.setText(" ‫לחץ‬‫כאן‬ " + ">"); a) ‫לחץ‬‫כאן‬ > b) > ‫לחץ‬‫כאן‬ c) < ‫לחץ‬‫כאן‬
  10. 10. #droidconzg #PreusslerBerlin Strings Page 10 Don’t concatenate strings! • Order might change in other language for grammar • Dangerous in Right-to-Left TextView textView = ... textView.setText(" ‫לחץ‬‫כאן‬ " + ">"); a) ‫לחץ‬‫כאן‬ > b) > ‫לחץ‬‫כאן‬ c) < ‫לחץ‬‫כאן‬
  11. 11. #droidconzg #PreusslerBerlin Strings Page 11 Don’t concatenate strings! • Use Formatter.format • Yes even for numbers! • Or better: Use Phrase from Square Phrase.from( "Hi {first_name}, you are {age} years old.") .put("first_name", firstName) .put("age", age) .format(); format(locale, "Choose a %d-digit PIN", 4)
  12. 12. #droidconzg #PreusslerBerlin Strings Page 12 • Plurals <?xml version="1.0" encoding="utf-8"?> <resources> <plurals name="tutorials"> <item quantity="zero">no Tutorial </item> <item quantity="one">one Tutorial </item> <item quantity="other">%d Tutorials</item> </plurals> </resources> getResources().getQuantityString( R.plurals.tutorials, number);
  13. 13. #droidconzg #PreusslerBerlin Locales Page 13 • Don’t reuse your strings too often. Same names for different things might be different names on other languages • Provide context to translator • Be aware: texts have different length in different languages, English tends to be short, Finnish or German tend to be very long • Different line-heights, careful with custom fonts or cropping views in height
  14. 14. #droidconzg #PreusslerBerlin Locales Page 14 • Test with Pseudo Localization buildTypes { debug { pseudoLocalesEnabled true } }
  15. 15. #droidconzg #PreusslerBerlin Locales Page 15 • Careful with default locales: assertEquals( “billy”, “BILLY”.toLowerCase()); assertEquals( “bılly”, “BILLY”.toLowerCase( new Locale(“tr”,“TR”))); -> FALSE for turkish!!!
  16. 16. #droidconzg #PreusslerBerlin Numbers Page 16 https://en.wikipedia.org/wiki/File:Clock-in-cairo-with-eastern-arabic-numerals.jpg
  17. 17. #droidconzg #PreusslerBerlin Numbers Page 17 The decimal mark: Dot vs. Comma 1.00$ vs 1,00€ With delimiters: 4,294,967,295.00 vs 4 294 967.295,000 In 1958, disputes between European and American delegates over the correct representation of the decimal mark nearly stalled the development of the ALGOL computer programming language. (wikipedia)
  18. 18. #droidconzg #PreusslerBerlin Numbers Page 18 The decimal mark: Dot vs. Comma https://en.wikipedia.org/wiki/Decimal_mark
  19. 19. #droidconzg #PreusslerBerlin Numbers Page 19 NumberFormat.getNumberInstance(Locale) NumberFormat.getIntegerInstance(Locale) Same for Percentages, don’t just concatenate! Example: Turkey has sign before the number! NumberFormat.getPercentInstance(Locale)
  20. 20. #droidconzg #PreusslerBerlin Currencies Page 20
  21. 21. #droidconzg #PreusslerBerlin Currencies Page 21 • WHICH symbols, if ANY • WHERE to put the symbol (front or back)? • How many digits after comma/dot? 0-3 are common • Represent currencies in the Currency class ;-) NumberFormat.getCurrencyInstance(Locale);
  22. 22. #droidconzg #PreusslerBerlin Currencies Page 22 • Never ever use floating point numbers (float or double) for Money! Floats are broken by design (for representing money) IEEE 754: it is impossible to represent 0.1 (or any other negative power of ten) System.out.println(1.03 - .42); >>> 0.6100000000000001 (Bloch, J., Effective Java, 2nd ed) • Use BigDecimal and the String(!) constructor • Check Martin Fowlers Money pattern class
  23. 23. #droidconzg #PreusslerBerlin Dates Page 23
  24. 24. #droidconzg #PreusslerBerlin Dates Page 24 • 12 hours vs 24 hours • Timezones • Daylight Time DST
  25. 25. #droidconzg #PreusslerBerlin Dates Page 25 • Careful with calculations and comparison (be aware of DST jumps) public static Date getYesterday(Date from) { Calendar c = getCalendarFor(from); c.add(Calendar.DAY_OF_THE_MONTH, -1); return c.getTime(); } public static Date getYesterday(Date from) { return new Date(from.getTime() - (24*60*60*1000)); }
  26. 26. #droidconzg #PreusslerBerlin Dates Page 26 DateFormat Careful with custom formats, try to use the standard java one else “pm” might show up to “nachmittag” DateFormat.getDateInstance(DateFormat.LONG) DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT);
  27. 27. #droidconzg #PreusslerBerlin Dates Page 27 android.text.format.DateUtils • Has nice methods like: isToday() formatDateRange() getRelativeTimeSpanString() “5 minutes ago” • Check out joda-time-android https://github.com/dlew/joda-time-android (don’t use normal Java joda-time! because of GetResourceAsStream performance issue on Android)
  28. 28. #droidconzg #PreusslerBerlin Units Page 28
  29. 29. #droidconzg #PreusslerBerlin Units Page 29 • Km vs miles • Celcius vs Fahrenheit • Liters vs Galons
  30. 30. #droidconzg #PreusslerBerlin Units Page 30 Regional differences: • Structure and Length of telephone numbers • Elements of Address informations • ZIP code validation
  31. 31. #droidconzg #PreusslerBerlin Dubai Airport #1 by emi emi, CC by 2.0; flickr.com/photos/emi_b/4793218993Right-to-Left
  32. 32. #droidconzg #PreusslerBerlin The signs are in greek by Karl Baron, flickr.com/photos/kalleboo/6624480775 Dubai Airport #1 by emi emi, CC by 2.0; flickr.com/photos/emi_b/4793218993
  33. 33. #droidconzg #PreusslerBerlin
  34. 34. #droidconzg #PreusslerBerlin Right-to-Left
  35. 35. #droidconzg #PreusslerBerlin Right To Left • Replace left/right with start/end • Manifest flag: android:supportsRtl="true" • Check your images and correct in xml drawable: android:autoMirrored=“true/false“ • Set margins to both sides 35
  36. 36. #droidconzg #PreusslerBerlin Cultural context Page 36
  37. 37. #droidconzg #PreusslerBerlin Cultural context Page 37 • Careful with iconography ©wikipedia
  38. 38. #droidconzg #PreusslerBerlin Thank you Happy localizing!

×