detect users preferred language

This commit is contained in:
Joshua Arts 2018-07-13 11:04:32 -04:00
parent 29e273f5a1
commit 55b83226c9
4 changed files with 22 additions and 4 deletions

View File

@ -56,6 +56,9 @@ gem 'bigbluebutton-api-ruby'
gem 'bootstrap', '~> 4.1.1'
gem 'tabler-rubygem'
# For detecting the users preferred language.
gem 'http_accept_language'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

View File

@ -83,6 +83,7 @@ GEM
globalid (0.4.1)
activesupport (>= 4.2.0)
hashie (3.5.7)
http_accept_language (2.1.1)
i18n (1.0.1)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.1)
@ -274,6 +275,7 @@ DEPENDENCIES
dotenv-rails
factory_bot_rails
faker
http_accept_language
jbuilder (~> 2.5)
jquery-rails
listen (~> 3.0.5)

View File

@ -6,16 +6,22 @@ class ApplicationController < ActionController::Base
include SessionsHelper
before_action :migration_error?
before_action :set_locale
protect_from_forgery with: :exception
MEETING_NAME_LIMIT = 90
USER_NAME_LIMIT = 30
# Show an information page when migration fails and there is a version error.
def migration_error?
render :migration_error unless ENV["DB_MIGRATE_FAILED"].blank?
end
protect_from_forgery with: :exception
MEETING_NAME_LIMIT = 90
USER_NAME_LIMIT = 30
# Sets the appropriate locale.
def set_locale
I18n.locale = http_accept_language.language_region_compatible_from(I18n.available_locales)
end
def meeting_name_limit
MEETING_NAME_LIMIT

View File

@ -17,9 +17,16 @@ module Greenlight
# Use custom error routes.
config.exceptions_app = routes
# Configure I18n localization.
config.i18n.available_locales = %w(en)
config.i18n.default_locale = "en"
# Check if a loadbalancer is configured.
config.loadbalanced_configuration = ENV["LOADBALANCER_ENDPOINT"].present? && ENV["LOADBALANCER_SECRET"].present?
# The default callback url that bn launcher will redirect to
config.gl_callback_url = ENV["GL_CALLBACK_URL"]
# Setup BigBlueButton configuration.
if config.loadbalanced_configuration
# Fetch credentials from a loadbalancer based on provider.