[bbb-greenlight: 24/39] Added env variable to set the default language (#2147)




commit 07557f45dc095d53773a6586bd448452cdf51f1b
Author: Ahmad Farhat <ahmad af farhat gmail com>
Date:   Fri Oct 2 09:50:24 2020 -0400

    Added env variable to set the default language (#2147)

 app/controllers/application_controller.rb | 2 +-
 config/application.rb                     | 3 +++
 sample.env                                | 9 +++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index f1de6a2..1b8a62e 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -101,7 +101,7 @@ class ApplicationController < ActionController::Base
     locale = if user && user.language != 'default'
       user.language
     else
-      http_accept_language.language_region_compatible_from(I18n.available_locales)
+      Rails.configuration.default_locale.presence || 
http_accept_language.language_region_compatible_from(I18n.available_locales)
     end
 
     begin
diff --git a/config/application.rb b/config/application.rb
index c310537..e47e754 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -131,6 +131,9 @@ module Greenlight
     # File types allowed in preupload presentation
     config.allowed_file_types = 
".doc,.docx,.ppt,.pptx,.pdf,.xls,.xlsx,.txt,.rtf,.odt,.ods,.odp,.odg,.odc,.odi,.jpg,.jpeg,.png"
 
+    # Default locale
+    config.default_locale = ENV["DEFAULT_LOCALE"]
+
     # DEFAULTS
 
     # Default branding image if the user does not specify one
diff --git a/sample.env b/sample.env
index c59bba9..52226c6 100644
--- a/sample.env
+++ b/sample.env
@@ -201,6 +201,15 @@ MAINTENANCE_WINDOW=
 # Button can be disabled by setting the value to blank
 HELP_URL=https://docs.bigbluebutton.org/greenlight/gl-overview.html
 
+# Change the default language
+# 
+# By default, Greenlight will appear in the same language as that specific user's browser. 
+# The user can override this by going into their profile and changing the language.
+# You can override the default language to a specific language instead of the browser's language by setting
+# the variable below. To find the correct value, visit: 
https://github.com/bigbluebutton/greenlight/tree/v2/config/locales
+# and find the code that matches the language you want. Ex: For Arabic -> DEFAULT_LOCALE=ar, For Italian -> 
DEFAULT_LOCALE=it
+# DEFAULT_LOCALE=
+
 # Force a redirect to HTTPS and make cookies secure. 
 # WARNING: Only set this to false for a development environment. 
 ENABLE_SSL=true


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]