an i18n journey
TRANSCRIPT
An i18n JourneyAndy Waite November 2013
notonthehighstreet.com notonthehighstreet.de
Basics
Lots of extracting to t(…) and l(…)
rails-i18n gem helps a lot for supported languages.
Coverage of dates, times, numbers, error messages.
But doesn’t help for JavaScript-heavy sites
Single or Separate DBs?Each site to have separate products and suppliers
Scoping everything by site - massive amount of work.
Site was MySQL so couldn’t use Postgres schemas for multi-tenancy (Apartment gem).
Went with separate DBs for UK and German sites.
Schema migrations run on both sites to keep schemas the same.
But used primary key offsets so that we could potentially merge back together in future.
Database State Values
Generally not i18n friendly
<%= order.status.titleize %>
Order.where(status: ‘shipped’)
TimezonesChanging timezone -> broken tests -> usually due to a badly designed test
Zonebie gem (time zone randomization)
Time.parse -> Time.zone.parse
Time.now -> Time.zone.now
.to_time -> .to_time_in_current_zone
Use ISO8601 for APIs (“2012-03-16T14:55:33Z")
Credit Cards
Two-thirds of Germans don’t own a credit card
Second lowest credit card use in all of EU
‘debt’ == ‘guilt’ (Schuld)
Capitalization
German is the only language in the world that requires the capitalization of ALL nouns.
der amerikanische Präsident
#titleize considered harmful
Crazy PluralizationEnglish / German: one, other
Icelandic:
one: 1, 21, 31, 41, 51, 61, …, 0.1, 0.2, 0.3
other 0, 2-20, 22-30, 32-40, …, 0.0, 2.0, 3.0, …
Arabic:
zero 0, 0.0, …
one 1, 1.00, 1.0, …
two 2, 2.00, 2.00, 2.0, …
few 3-10, 103-110, 203-210, …, 3.00, 3.00, 4.00, …
many 11-99, 111-199, 211-299, …, 11.00, 11.00, 12.00, …
other 100-102, 200-202, 300-302, …, 0.1, 0.2, 0.3, …
http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html
blog.andywaite.com @andyw8
Lessons Learned
Stick to Rails conventions
Demo to native speakers as early as you can
Consider i18n-friendly-by-default approach:
Store all strings in YAML config
Wrap date/number/currency calls in l(…) in views