Growing Up with Globalization Andrew Turgeon - IBM - Pittsburgh, PA apturgeo@us.ibm.com 1
In the Beginning… 2
3
4
5
6
7
8
9
10
New Customer! Except they require the following: • 8 languages other than English • Culturally-accurate data formats • Timezone support for 12 unique locations • Bidirectional text capabilities 11
Wish I would have prepared for that before I wrote all this code… 12
Agenda • Statistics Overview • Culture-Specific Data Formats • Globalization • Bidirectional • Getting Started Languages • Basic I18n - The Rails Way • Testing • Takeaways • Variables & Pluralization 13
Statistics Overview Languages of the Internet (2015) 74% of Internet traffic in English 26% 2015 was from users Other 22% who prefer or only speak German languages other than 3% French English 3% Malay Chinese 3% 21% Russian Spanish 3% 8% Japanese 3% Portuguese 4% Arabic 5% http://www.internetworldstats.com/stats7.htm 14
Statistics Overview Growth of Internet Users By Language (2000-2015) 7,000% 5,250% 3,500% 1,750% 520% 0% Japanese German English French Other Spanish Malay Portuguese Chinese Russian Arabic http://www.internetworldstats.com/stats7.htm 15
Statistics Overview Timezones of the Internet *Currently 39 Unique Local Times in use http://royal.pingdom.com/wp-content/uploads/2013/02/internet-users-time-zones-pingdom-5801.jpg 16
I get it. What do I need to do? 17
Globalization (in a nutshell) Our Job Step 1 Step 2 Internationalization Localization (i18n) (l10n) 18
Watson Explorer Lots of… English… 19
Getting Started • Using the pre-bundled I18n framework in Rails, add the following to the controller: • You can retrieve the locale from the user preferences (best) • Or you can try getting it from the accept language header (ok) *Make sure to use it in the html tag! 20
Basic I18n - The Rails Way Somewhere in a galaxy far far away… ../app/widgets/activity_feed/ display .html.erb BAD ../config/locales/en/ activity_feed .yml • DON’T REUSE same text • Hierarchy with short keys *Note: Use ellipsis character (…), not three dots (...) 21
Variables & Pluralization Bad Use interpolated variables for dynamic data • More plural forms exist in other languages • 22
Culture-Specific Data Formats Bad *Required hierarchy for I18n.l usage Define all your formats in key-value lookups, including defaults • Follow similar structure for currency, numbers, and percentages • 23
Timezones • Always store in UTC (ISO6801) • Always consume in currently configured timezone • Make sensible defaults, but user setting is preferred Bad Example: Time visualizations in Javascript 24
Bidirectional Languages Not all languages read the same direction! HTML5 • Use Unicode • For both right-to-left AND left-to-right text at the same time, use embedded tags to indicate text direction • Serve mirrored CSS for absolute/relative positioning 25
Testing • Static code analysis with i18n-tasks gem • Testing dynamic translations (with RSpec): • Transitioning from non-i18n to i18n, create a “foo” or longer word language pack for testing (easy to spot non-foo) 26
Takeaways • Treat language as an abstraction from the beginning (sooner the better) • Don’t try to be a hero when doing i18n • Getting started isn’t too bad when you use a framework that is: • Maintainable • Modifiable • Testable • Translatable • addresses main pitfalls discussed in this presentation 27
Q&A Andrew Turgeon - apturgeo@us.ibm.com 28
Thanks! 29
Recommend
More recommend