Permalink
Browse files

locale support (without ja.yml)

  • Loading branch information...
1 parent 2a9b783 commit adb4851179c876afba5501a0d427b030e2bef8f9 @nov committed May 14, 2011
Showing with 13 additions and 0 deletions.
  1. +13 −0 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.