an i18n journey

11
An i18n Journey Andy Waite November 2013

Upload: andyw8

Post on 14-Apr-2017

264 views

Category:

Software


0 download

TRANSCRIPT

Page 1: An i18n Journey

An i18n JourneyAndy Waite November 2013

Page 2: An i18n Journey

notonthehighstreet.com notonthehighstreet.de

Page 3: An i18n Journey

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

Page 4: An i18n Journey

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.

Page 5: An i18n Journey

Database State Values

Generally not i18n friendly

<%= order.status.titleize %>

Order.where(status: ‘shipped’)

Page 6: An i18n Journey

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")

Page 7: An i18n Journey

Credit Cards

Two-thirds of Germans don’t own a credit card

Second lowest credit card use in all of EU

‘debt’ == ‘guilt’ (Schuld)

Page 8: An i18n Journey

Capitalization

German is the only language in the world that requires the capitalization of ALL nouns.

der amerikanische Präsident

#titleize considered harmful

Page 9: An i18n Journey

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

Page 10: An i18n Journey

blog.andywaite.com @andyw8

Page 11: An i18n Journey

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