From 6e1121179d4846e73f057e8c1b2ae8fe1877f91c Mon Sep 17 00:00:00 2001 From: "livefromthemoon@gmail.com" Date: Thu, 28 Oct 2010 03:37:29 +0200 Subject: [PATCH] guess locale from browser settings --- Gemfile | 1 + Gemfile.lock | 7 +++++++ app/controllers/application_controller.rb | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/Gemfile b/Gemfile index ddff8fa21..b97d1df4f 100644 --- a/Gemfile +++ b/Gemfile @@ -27,6 +27,7 @@ gem 'roxml', :git => 'git://github.com/Empact/roxml.git' gem 'addressable', :require => 'addressable/uri' gem 'json' gem 'mini_fb' +gem 'http_accept_language', :git => 'http://github.com/iain/http_accept_language.git' #Standards gem 'pubsubhubbub' diff --git a/Gemfile.lock b/Gemfile.lock index dc26a8bf9..d4e0cf1c1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -67,6 +67,12 @@ GIT capistrano (>= 2.5.5) highline (>= 1.4.0) +GIT + remote: http://github.com/iain/http_accept_language.git + revision: 0b78aa7849fc90cf9e12586af162fa4c408a795d + specs: + http_accept_language (1.0.1) + GEM remote: http://rubygems.org/ specs: @@ -367,6 +373,7 @@ DEPENDENCIES em-websocket factory_girl_rails haml + http_accept_language! json launchy magent! diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e581613f3..e1327bac4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base before_filter :set_friends_and_status, :except => [:create, :update] before_filter :count_requests before_filter :set_invites + before_filter :set_locale def set_friends_and_status if current_user @@ -33,4 +34,8 @@ class ApplicationController < ActionController::Base @invites = current_user.invites end end + + def set_locale + I18n.locale = request.compatible_language_from I18n.available_locales + end end