Localizing web sites in ruby on rails

971 views

Published on

Short talk on how to localize your Ruby on Rails web application using I18n

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Localizing web sites in ruby on rails

  1. 1. How to Localize your Ruby on Rails web application Bethany Rentz July 24, 2013
  2. 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
  3. 3. Home Page
  4. 4. Create a new important date
  5. 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?
  6. 6. en.yml fr.yml
  7. 7. 2) Use 2 methods from public API in your specs and code: ● I18n.translate or I18n.t – translate text ● I18n.localize or I18n.l – format dates
  8. 8. Resources • Ruby on Rails Guide to localization with i18n.htm • Repo with locale files for use in your application • Sample Localized Project

×