Created
October 12, 2011 00:32
-
-
Save ywatai/1279885 to your computer and use it in GitHub Desktop.
i18n filter for rails 3.0.x (from tutorial)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ApplicationController < ActionController::Base | |
| protect_from_forgery | |
| # l19n by url parameter | |
| before_filter :set_locale | |
| private | |
| def set_locale | |
| I18n.locale = params[:locale] || I18n.default_locale | |
| end | |
| def default_url_options(options={}) | |
| logger.debug "default_url_options is passed options: #{options.inspect}\n" | |
| { :locale => I18n.locale } | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AppName::Application.routes.draw do | |
| # switch locale with parameter | |
| scope "/(:locale)", :locale => /en|ja/ do | |
| # your application routes | |
| # resources :posts | |
| end | |
| # default locale | |
| # resources :posts | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment