1. How to Localize your Ruby on Rails
web application
Bethany Rentz
July 24, 2013
2. Why localize?
Estimates of the number of Internet users by language as of 31 May 2011:
[4]
"Number of Internet Users by Language", Internet World Stats, Miniwatts Marketing Group, 31 May 2011, accessed 22 April 2012
5. 1) Setup your application for localizing
a) Change URL format to include locale (in routes.rb)
ex: http://localhost:3000/fr
scope "/:locale", :locale => /en|fr/ do
resources :importantdates
end
b) Add setting to application_controller.rb
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
c)Create .yml files in config/locales for each language you are supporting
* can find pre-localized .yml files at: https://github.com/svenfuchs/rails-i18n
How to localize?