Skip to content

Commit

Permalink
locale support (without ja.yml)
Browse files Browse the repository at this point in the history
  • Loading branch information
nov committed May 14, 2011
1 parent 2a9b783 commit adb4851
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/controllers/application_controller.rb
@@ -1,3 +1,16 @@
class ApplicationController < ActionController::Base
protect_from_forgery

before_filter :set_locale

def set_locale
lang = unless params[:lang].blank?
params[:lang].downcase
else
request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
end
I18n.locale = lang if I18n.available_locales.include?(lang.to_sym)
rescue
# use default
end
end

0 comments on commit adb4851

Please sign in to comment.