Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

locale support (without ja.yml)

  • Loading branch information...
commit adb4851179c876afba5501a0d427b030e2bef8f9 1 parent 2a9b783
@nov authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 app/controllers/application_controller.rb
View
13 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
Please sign in to comment.
Something went wrong with that request. Please try again.