March 22nd 2016
by @frederikvollert
Internationalization
"i18n"
Internationalization
"i#{'nternationalizatio'.length}n"
i18n: Preparing code for international audience
"Hello!" can become "¡Hola!"
Uber becomes Über, or �ber
ASCII or UTF-8 ?
.de or /de, Accept-Header
03/22/16 2pm PST
or 14:00h 22.03.2016 CET
Anybody got an IBAN or EC-Card?
Copy & Templates
Encoding
Routing & Language detection
Date & Time
Currency & Payment
Tips and Tricks
Prepare early! Use keys in templates from the start;
Use constants and symbols instead of string values for
e.g. <select> options
UI: Allow 20% stretching space for captions (Even more on buttons)
Every time should be stored as UTC
Money should be stored as integer amounts in smallest unit of currency
(No float) with currency name
Make sure you use UTF-8 as encoding
Localization
"l10n"
l10n: Adapting software to a specific locale
Translation of locale file (string file)
Support for local currency
Are your graphics, references and
name culturally adequate?
Is your service legal in China? Tax?
pt-BR:
welcome: "Oi!"
Does your PSP handle ¥ or € ?
Wix.com, Mitsubishi Pajero
"Salud" != "Oi"
br != pt-BR
Language code-Country code
Locale codes are well-defined
(ISO 3166, ISO 639, RFC 5646)
en-GB, en-US, de-DE, pt-BR, pt-PT
Rails i18n support
I18n.t(:welcome, default: "Hello!", scope: [:home, :index])
Partial in path "app/views/home/index"
<h1>t(".welcome")</h1>
<h1>t("home.index.welcome")</h1>
I18n.l(@user.created_at, format: :long)
Localized time and date notations
Pro-Tip: I18n.with_locale(temporary_locale) do … end
Placeholders
Pluralization
html-suffix
Rails i18n features
greeting: "Hello, %{name}!"
t(:greeting, name: "Frederik")
item:
one: "%{count} item"
other: "%{count} items"
t(:item, count: @items.length)
body_html: "<b>Statement!</b>"
Language detection
request.env["HTTP_ACCEPT_LANGUAGE"]
I18n.default_locale = :en
Routing param
(Store in cookie)
config/routes.rb:
scope "/(:language)", language: /(en|de|fr)/ do
get "features" => "home#features"
end
Joining translated chunks is a bad idea (as are elaborate placeholders and
YAML’s :<< )
SEO
Top-level domain brand.de > brand.com/de or de.brand.com
However, Page authority vs. Domain authority, Google vs. Facebook
Gettext as rails-i18n alternative:
https://github.com/grosser/gettext_i18n_rails
Excel spreadsheet-driven processes will not work forever
Additional things to consider
Useful links & gems
Rails i18n guide
https://github.com/enriclluelles/route_translator
I18n routes: /en/cars becomes /de/autos
https://github.com/phrase/slimkeyfy
Extract string file from .slim templates easily (Contributions welcome!)
https://github.com/phrase/phraseapp-in-context-editor-ruby
In-context editor for Rails applications
<5 minutes
via API
<12 hours
with 1-click
export
PhraseApp Translation Platform
Translate and
edit copy
inside your
Rails app.
PhraseApp Rails In-Context Editor
FAMILO achieved
400% global user growth;
surpassed 1 million users.
"PhraseApp helped us
streamline our
localization and become
an industry leader."
Hauke
Windmueller
CEO, FAMILO
Thank you!
Frederik Vollert
@frederikvollert
+1 (650) 898-9785
frederik@phraseapp.com
PhraseApp
720 University Ave
Palo Alto

Ruby on Rails Internationalization Best Practices, i18n SFRAILS

  • 1.
    March 22nd 2016 by@frederikvollert
  • 2.
  • 3.
  • 4.
    i18n: Preparing codefor international audience "Hello!" can become "¡Hola!" Uber becomes Über, or �ber ASCII or UTF-8 ? .de or /de, Accept-Header 03/22/16 2pm PST or 14:00h 22.03.2016 CET Anybody got an IBAN or EC-Card? Copy & Templates Encoding Routing & Language detection Date & Time Currency & Payment
  • 5.
    Tips and Tricks Prepareearly! Use keys in templates from the start; Use constants and symbols instead of string values for e.g. <select> options UI: Allow 20% stretching space for captions (Even more on buttons) Every time should be stored as UTC Money should be stored as integer amounts in smallest unit of currency (No float) with currency name Make sure you use UTF-8 as encoding
  • 6.
  • 7.
    l10n: Adapting softwareto a specific locale Translation of locale file (string file) Support for local currency Are your graphics, references and name culturally adequate? Is your service legal in China? Tax? pt-BR: welcome: "Oi!" Does your PSP handle ¥ or € ? Wix.com, Mitsubishi Pajero
  • 8.
    "Salud" != "Oi" br!= pt-BR Language code-Country code Locale codes are well-defined (ISO 3166, ISO 639, RFC 5646) en-GB, en-US, de-DE, pt-BR, pt-PT
  • 9.
    Rails i18n support I18n.t(:welcome,default: "Hello!", scope: [:home, :index]) Partial in path "app/views/home/index" <h1>t(".welcome")</h1> <h1>t("home.index.welcome")</h1> I18n.l(@user.created_at, format: :long) Localized time and date notations Pro-Tip: I18n.with_locale(temporary_locale) do … end
  • 10.
    Placeholders Pluralization html-suffix Rails i18n features greeting:"Hello, %{name}!" t(:greeting, name: "Frederik") item: one: "%{count} item" other: "%{count} items" t(:item, count: @items.length) body_html: "<b>Statement!</b>"
  • 11.
    Language detection request.env["HTTP_ACCEPT_LANGUAGE"] I18n.default_locale =:en Routing param (Store in cookie) config/routes.rb: scope "/(:language)", language: /(en|de|fr)/ do get "features" => "home#features" end
  • 12.
    Joining translated chunksis a bad idea (as are elaborate placeholders and YAML’s :<< ) SEO Top-level domain brand.de > brand.com/de or de.brand.com However, Page authority vs. Domain authority, Google vs. Facebook Gettext as rails-i18n alternative: https://github.com/grosser/gettext_i18n_rails Excel spreadsheet-driven processes will not work forever Additional things to consider
  • 13.
    Useful links &gems Rails i18n guide https://github.com/enriclluelles/route_translator I18n routes: /en/cars becomes /de/autos https://github.com/phrase/slimkeyfy Extract string file from .slim templates easily (Contributions welcome!) https://github.com/phrase/phraseapp-in-context-editor-ruby In-context editor for Rails applications
  • 15.
    <5 minutes via API <12hours with 1-click export PhraseApp Translation Platform
  • 16.
    Translate and edit copy insideyour Rails app. PhraseApp Rails In-Context Editor
  • 17.
    FAMILO achieved 400% globaluser growth; surpassed 1 million users. "PhraseApp helped us streamline our localization and become an industry leader." Hauke Windmueller CEO, FAMILO
  • 18.
    Thank you! Frederik Vollert @frederikvollert +1(650) 898-9785 frederik@phraseapp.com PhraseApp 720 University Ave Palo Alto

Editor's Notes

  • #16 PhraseApp integrates into the developer’s toolchain and can extract source copy changes automatically from the source code management systems like GitHub. Content is immediately available for translation in PhraseApp’s online editor. It even allows in-context editing of the copy. Our customers either use in-house translators or our directly integrated providers, who will be able to translate 80% of orders within 12 hours.