forked from External/greenlight
detect users preferred language
This commit is contained in:
parent
29e273f5a1
commit
55b83226c9
3
Gemfile
3
Gemfile
|
@ -56,6 +56,9 @@ gem 'bigbluebutton-api-ruby'
|
||||||
gem 'bootstrap', '~> 4.1.1'
|
gem 'bootstrap', '~> 4.1.1'
|
||||||
gem 'tabler-rubygem'
|
gem 'tabler-rubygem'
|
||||||
|
|
||||||
|
# For detecting the users preferred language.
|
||||||
|
gem 'http_accept_language'
|
||||||
|
|
||||||
# Use Capistrano for deployment
|
# Use Capistrano for deployment
|
||||||
# gem 'capistrano-rails', group: :development
|
# gem 'capistrano-rails', group: :development
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ GEM
|
||||||
globalid (0.4.1)
|
globalid (0.4.1)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
hashie (3.5.7)
|
hashie (3.5.7)
|
||||||
|
http_accept_language (2.1.1)
|
||||||
i18n (1.0.1)
|
i18n (1.0.1)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
jaro_winkler (1.5.1)
|
jaro_winkler (1.5.1)
|
||||||
|
@ -274,6 +275,7 @@ DEPENDENCIES
|
||||||
dotenv-rails
|
dotenv-rails
|
||||||
factory_bot_rails
|
factory_bot_rails
|
||||||
faker
|
faker
|
||||||
|
http_accept_language
|
||||||
jbuilder (~> 2.5)
|
jbuilder (~> 2.5)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
listen (~> 3.0.5)
|
listen (~> 3.0.5)
|
||||||
|
|
|
@ -6,16 +6,22 @@ class ApplicationController < ActionController::Base
|
||||||
include SessionsHelper
|
include SessionsHelper
|
||||||
|
|
||||||
before_action :migration_error?
|
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.
|
# Show an information page when migration fails and there is a version error.
|
||||||
def migration_error?
|
def migration_error?
|
||||||
render :migration_error unless ENV["DB_MIGRATE_FAILED"].blank?
|
render :migration_error unless ENV["DB_MIGRATE_FAILED"].blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
protect_from_forgery with: :exception
|
# Sets the appropriate locale.
|
||||||
|
def set_locale
|
||||||
MEETING_NAME_LIMIT = 90
|
I18n.locale = http_accept_language.language_region_compatible_from(I18n.available_locales)
|
||||||
USER_NAME_LIMIT = 30
|
end
|
||||||
|
|
||||||
def meeting_name_limit
|
def meeting_name_limit
|
||||||
MEETING_NAME_LIMIT
|
MEETING_NAME_LIMIT
|
||||||
|
|
|
@ -17,9 +17,16 @@ module Greenlight
|
||||||
# Use custom error routes.
|
# Use custom error routes.
|
||||||
config.exceptions_app = 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?
|
config.loadbalanced_configuration = ENV["LOADBALANCER_ENDPOINT"].present? && ENV["LOADBALANCER_SECRET"].present?
|
||||||
|
|
||||||
# The default callback url that bn launcher will redirect to
|
# The default callback url that bn launcher will redirect to
|
||||||
config.gl_callback_url = ENV["GL_CALLBACK_URL"]
|
config.gl_callback_url = ENV["GL_CALLBACK_URL"]
|
||||||
|
|
||||||
# Setup BigBlueButton configuration.
|
# Setup BigBlueButton configuration.
|
||||||
if config.loadbalanced_configuration
|
if config.loadbalanced_configuration
|
||||||
# Fetch credentials from a loadbalancer based on provider.
|
# Fetch credentials from a loadbalancer based on provider.
|
||||||
|
|
Loading…
Reference in New Issue