Welcome to the 
Movember DRUG 
Meetup!!! 
Wifi Network: Neutron-Guest 
Wifi Password: welcome2u
About me 
My name is Katherine 
Muedas. 
I am from Peru. 
Software developer - I love 
ruby on rails. 
Bachelor Degree in Business 
Management. 
Passion: Marketing, fashion 
and coding. 
Also, I love playing Ping Pong, 
spending time with family and 
traveling.
I18n
Who can explain why 
internationalization is 
abbreviated as I18n?
I N T E R N A T I O N A L I Z A T I O N 
I 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 N
What is 
Internationalization?
What is I18n? 
The process of "internationalization" usually means 
to abstract all strings and other locale specific bits 
(such as date or currency formats) out of your 
application. The process of "localization" means to 
provide translations and localized formats for these 
bits.
Why Use It?
Why Use It? 
Better UX 
For Translation… obviously 
Makes your product or message more accessible 
More customers == MOAR profits
Why Use It? 
All your static text is in one spot. 
Easy to maintain and change 
Keep code DRY 
Organization
Let’s Get Started 
Empezemos!
Setting Up Your Translation File 
/config/locale/en.yml 
/config/locale/es.yml
In Your Views… 
views/home/_header.haml
You can do more than just put 
words or sentences in the 
translation file…
Nest translations for organization 
config/locale/en.yml 
views/home/_about 
.html.haml
You can change a photo based on 
language 
config/locale/en.yml 
views/home/_header.haml
and for spanish… 
config/locale/es.yml 
views/home/_header.haml
You can put HTML inside 
config/locale/en.yml
Loop through a list 
config/locale/en.yml views/about/_about.haml
Interpolation 
config/locale/es.yml 
views/about/_about.haml 
webpage
Setting the Locale/ 
Language in your 
Routes!
Setting locale in your routes 
By Sub Domain 
en.mysite.com 
es.mysite.com peru.mysite.com 
Cons 
Does not work on Heroku without a domain. 
A wild card SSL certificate is more expensive then a single domain certificate 
Pros 
Supports localization by country or by language 
Cookies can be shared across all locales.
Setting locale in your routes 
By Top-Level Domain 
mysite.com 
Cons 
mysite.pe mysite.ca 
Expensive and time consuming to buy many domains. 
Cookies cannot be shared across multiple locales 
Not a good option for localizing by language 
Can not different languages for different countries. 
Pros 
Supports localization by country.
Setting locale in your routes 
By Params 
mysite.com?locale=en 
Params get lost when redirecting 
Bad for SEO 
Quick to implement 
Could be used to store locale 
Info in a user cookie 
mysite.com?locale=es 
Cons 
Pros
Setting locale in your routes 
By Scoping Routes 
mysite.com/en/contact 
mysite.com/es 
Pros 
Easy to set up for hosting. 
Locale is set in the url route so it will not get lost when you are 
navigating to different pages. 
The locale is in a better position based on a architectural 
standpoint.
How to setup scoped 
routes ?
Application.rb 
config/application.rb
Routes.rb 
Optional language can be passed in 
config/routes.rb 
/admins/sign_in 
/en/admins/sign_in 
/es/admins/sign_in
Links to change language
Thank You!!

Internationalization with Rails

  • 1.
    Welcome to the Movember DRUG Meetup!!! Wifi Network: Neutron-Guest Wifi Password: welcome2u
  • 2.
    About me Myname is Katherine Muedas. I am from Peru. Software developer - I love ruby on rails. Bachelor Degree in Business Management. Passion: Marketing, fashion and coding. Also, I love playing Ping Pong, spending time with family and traveling.
  • 3.
  • 5.
    Who can explainwhy internationalization is abbreviated as I18n?
  • 6.
    I N TE R N A T I O N A L I Z A T I O N I 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 N
  • 7.
  • 8.
    What is I18n? The process of "internationalization" usually means to abstract all strings and other locale specific bits (such as date or currency formats) out of your application. The process of "localization" means to provide translations and localized formats for these bits.
  • 9.
  • 10.
    Why Use It? Better UX For Translation… obviously Makes your product or message more accessible More customers == MOAR profits
  • 11.
    Why Use It? All your static text is in one spot. Easy to maintain and change Keep code DRY Organization
  • 12.
  • 13.
    Setting Up YourTranslation File /config/locale/en.yml /config/locale/es.yml
  • 14.
    In Your Views… views/home/_header.haml
  • 15.
    You can domore than just put words or sentences in the translation file…
  • 16.
    Nest translations fororganization config/locale/en.yml views/home/_about .html.haml
  • 17.
    You can changea photo based on language config/locale/en.yml views/home/_header.haml
  • 18.
    and for spanish… config/locale/es.yml views/home/_header.haml
  • 19.
    You can putHTML inside config/locale/en.yml
  • 20.
    Loop through alist config/locale/en.yml views/about/_about.haml
  • 21.
  • 22.
    Setting the Locale/ Language in your Routes!
  • 23.
    Setting locale inyour routes By Sub Domain en.mysite.com es.mysite.com peru.mysite.com Cons Does not work on Heroku without a domain. A wild card SSL certificate is more expensive then a single domain certificate Pros Supports localization by country or by language Cookies can be shared across all locales.
  • 24.
    Setting locale inyour routes By Top-Level Domain mysite.com Cons mysite.pe mysite.ca Expensive and time consuming to buy many domains. Cookies cannot be shared across multiple locales Not a good option for localizing by language Can not different languages for different countries. Pros Supports localization by country.
  • 25.
    Setting locale inyour routes By Params mysite.com?locale=en Params get lost when redirecting Bad for SEO Quick to implement Could be used to store locale Info in a user cookie mysite.com?locale=es Cons Pros
  • 26.
    Setting locale inyour routes By Scoping Routes mysite.com/en/contact mysite.com/es Pros Easy to set up for hosting. Locale is set in the url route so it will not get lost when you are navigating to different pages. The locale is in a better position based on a architectural standpoint.
  • 27.
    How to setupscoped routes ?
  • 28.
  • 29.
    Routes.rb Optional languagecan be passed in config/routes.rb /admins/sign_in /en/admins/sign_in /es/admins/sign_in
  • 30.
  • 31.

Editor's Notes

  • #14 inside your rails project you have a english yml file
  • #15 Inside your views you can use this translation by simply saying t and then whatever translation key you want to give the value for
  • #17 To keep your translation organize you can nest the translations in different sections You can see here i have a header section, project section and about section and each of them have they own headline value so that means that in the view I can just call about.headline to get the headline of the about section.
  • #20 To get this to work you need to have a translation key that ends with html so that means for different languages you can have difference html if you want it or need it
  • #21 …this is even good to use even if you are not translating into diffrenten languages because it can help you clean up your html.
  • #22 If you have text that have dynamic content in it you can use interpolation to pass the data to the translation file , in this case you want to tell the user the time in their language so you pass the time to the current time translation. You can see here when I am setting the time I use a “L” which is for setting localization which is use for changing time, dates and currentcy formats base on location.
  • #31 if you click the link english, the param locale : en will be set and if you click the link spanish, the param locale : es will be set