diff --git a/Gemfile b/Gemfile index 369e3947..ca9df6a1 100644 --- a/Gemfile +++ b/Gemfile @@ -28,6 +28,7 @@ gem 'high_voltage', '~> 3.0.0' gem 'bugsnag' gem 'rack-cors', :require => 'rack/cors' gem 'rack-jsonp' +gem 'http_accept_language' # Upgraded to 1.0.0 for Rails 5.1.4 gem 'activeadmin', '~> 1.0.0' diff --git a/Gemfile.lock b/Gemfile.lock index 43ed535e..0c3119e0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -190,6 +190,7 @@ GEM activesupport (>= 4.1, < 5.2) hashie (3.5.6) high_voltage (3.0.0) + http_accept_language (2.1.1) i18n (0.8.6) i18n_data (0.8.0) ice_nine (0.11.2) @@ -407,6 +408,7 @@ DEPENDENCIES grape-swagger (~> 0.7.2) haml high_voltage (~> 3.0.0) + http_accept_language jbuilder (~> 2.5) jquery-rails kaminari (~> 0.17.0) @@ -436,4 +438,4 @@ RUBY VERSION ruby 2.3.1p112 BUNDLED WITH - 1.14.6 + 1.15.3 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5891422c..103cf92c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,9 +3,14 @@ class ApplicationController < ActionController::Base # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception before_action :mobile_filter_header + before_action :set_locale def mobile_filter_header @mobile = true end + def set_locale + I18n.locale = http_accept_language.language_region_compatible_from(I18n.available_locales) + end + end diff --git a/config/application.rb b/config/application.rb index 920155ac..47d9d980 100644 --- a/config/application.rb +++ b/config/application.rb @@ -20,7 +20,16 @@ class Application < Rails::Application resource "/api/*", headers: :any, methods: [:get, :post, :options] end end -# I18n stuff -config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] +<<<<<<< HEAD + + # I18n stuff + config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] + config.i18n.available_locales = [:en] + +======= + # I18n stuff + config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] + config.i18n.available_locales = [:en] +>>>>>>> 63dd86f11203e4f83cdb45c8a5c5addc7c26dd66 end end diff --git a/config/locales/en.yml b/config/locales/en/en.yml similarity index 100% rename from config/locales/en.yml rename to config/locales/en/en.yml