configure i18n

This commit is contained in:
Zachary Chai 2016-11-03 17:22:33 -04:00
parent 9a6b75d15b
commit 84fb5c617f
4 changed files with 16 additions and 0 deletions

View File

@ -60,3 +60,5 @@ gem 'bootstrap-social-rails', '~> 4.12'
gem 'font-awesome-rails'
gem 'jquery-ui-rails'
gem 'jquery-datatables-rails', '~> 3.4.0'
gem 'http_accept_language'

View File

@ -70,6 +70,7 @@ GEM
globalid (0.3.7)
activesupport (>= 4.1.0)
hashie (3.4.4)
http_accept_language (2.1.0)
i18n (0.7.0)
jbuilder (2.6.0)
activesupport (>= 3.0.0, < 5.1)
@ -212,6 +213,7 @@ DEPENDENCIES
coffee-rails (~> 4.2)
dotenv-rails
font-awesome-rails
http_accept_language
jbuilder (~> 2.5)
jquery-datatables-rails (~> 3.4.0)
jquery-rails

View File

@ -3,6 +3,11 @@ require 'digest/sha1'
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :set_locale
def set_locale
I18n.locale = http_accept_language.language_region_compatible_from(I18n.available_locales)
end
def current_user
@current_user ||= User.find_by(id: session[:user_id])

View File

@ -12,6 +12,13 @@ module Greenlight
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# i18n
# ensure each language has a regional fallback
config.i18n.available_locales = %w(en en-US)
config.i18n.default_locale = 'en-US'
config.i18n.fallbacks = {'en' => 'en-US'}
# BigBlueButton
config.bigbluebutton_endpoint = ENV['BIGBLUEBUTTON_ENDPOINT']
config.bigbluebutton_secret = ENV['BIGBLUEBUTTON_SECRET']
end