localizing web sites in ruby on rails

Download Localizing web sites in ruby on rails

If you can't read please download the document

Upload: bethany-rentz

Post on 29-May-2015

690 views

Category:

Technology


2 download

DESCRIPTION

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

TRANSCRIPT

  • 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 3. Home Page 4. Create a new important date 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. en.yml fr.yml 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. Resources Ruby on Rails Guide to localization with i18n.htm Repo with locale files for use in your application Sample Localized Project