Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby...
Transcript of Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby...
![Page 2: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/2.jpg)
2
In the Beginning…
![Page 3: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/3.jpg)
3
![Page 4: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/4.jpg)
4
![Page 5: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/5.jpg)
5
![Page 6: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/6.jpg)
6
![Page 7: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/7.jpg)
7
![Page 8: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/8.jpg)
8
![Page 9: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/9.jpg)
9
![Page 10: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/10.jpg)
10
![Page 11: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/11.jpg)
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
![Page 12: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/12.jpg)
Wish I would have prepared for that before I wrote all this code…
12
![Page 13: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/13.jpg)
Agenda• Statistics Overview
• Globalization
• Getting Started
• Basic I18n - The Rails Way
• Variables & Pluralization
• Culture-Specific Data Formats
• Bidirectional Languages
• Testing
• Takeaways
13
![Page 14: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/14.jpg)
Statistics OverviewLanguages of the Internet (2015)
English26%
Chinese21%
Spanish8%
Arabic5%
Portuguese4%
Japanese3%
Russian3%
Malay3%
French3%
German3%
Other22%
74% of Internet traffic in 2015 was from users
who prefer or only speak languages other than
English
14
http://www.internetworldstats.com/stats7.htm
![Page 15: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/15.jpg)
520%
0%
1,750%
3,500%
5,250%
7,000%
Japa
nese
Ger
man
Engl
ish
Fren
ch
Oth
er
Span
ish
Mal
ay
Portu
gues
e
Chi
nese
Rus
sian
Arab
ic
Growth of Internet Users By Language (2000-2015)
15
Statistics Overview
http://www.internetworldstats.com/stats7.htm
![Page 16: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/16.jpg)
Statistics OverviewTimezones of the Internet
*Currently 39 Unique Local Times in use
16
http://royal.pingdom.com/wp-content/uploads/2013/02/internet-users-time-zones-pingdom-5801.jpg
![Page 17: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/17.jpg)
I get it. What do I need to do?
17
![Page 18: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/18.jpg)
Globalization (in a nutshell)
Internationalization (i18n)
Localization (l10n)
Our Job
18
Step 1 Step 2
![Page 19: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/19.jpg)
Watson Explorer
Lots of… English…19
![Page 20: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/20.jpg)
Getting Started
• You can retrieve the locale from the user preferences (best)• Or you can try getting it from the accept language header (ok)
• Using the pre-bundled I18n framework in Rails, add the following to the controller:
*Make sure to use it in the html tag!
20
![Page 21: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/21.jpg)
Basic I18n - The Rails Way
Somewhere in a galaxy far far away…
../config/locales/en/activity_feed.yml
• DON’T REUSE same text• Hierarchy with short keys
BAD
*Note: Use ellipsis character (…), not three dots (...)21
../app/widgets/activity_feed/display.html.erb
![Page 22: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/22.jpg)
Variables & Pluralization
• Use interpolated variables for dynamic data• More plural forms exist in other languages
Bad
22
![Page 23: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/23.jpg)
Culture-Specific Data Formats
• Define all your formats in key-value lookups, including defaults• Follow similar structure for currency, numbers, and percentages
Bad
23
*Required hierarchy for I18n.l usage
![Page 24: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/24.jpg)
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
![Page 25: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/25.jpg)
Bidirectional LanguagesNot all languages read the same direction!
• Use Unicode• For both right-to-left AND left-to-right text at the same time, use
embedded tags to indicate text direction
HTML5
25
• Serve mirrored CSS for absolute/relative positioning
![Page 26: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/26.jpg)
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
![Page 27: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/27.jpg)
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
![Page 29: Growing Up with Globalization - Carnegie Mellon …...This presentation describes converting a Ruby on Rails web application that didn't consider globalization at its inception, using](https://reader034.fdocuments.us/reader034/viewer/2022042411/5f299b744f74c655ed1d1ba1/html5/thumbnails/29.jpg)
Thanks!
29