diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 2176cbfb..4dc368a5 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -39,7 +39,15 @@ class ApplicationController < ActionController::Base
# Sets the appropriate locale.
def set_locale
- I18n.locale = http_accept_language.language_region_compatible_from(I18n.available_locales)
+ update_locale(current_user)
+ end
+
+ def update_locale(user)
+ I18n.locale = if user && user.language != 'default'
+ user.language
+ else
+ http_accept_language.language_region_compatible_from(I18n.available_locales)
+ end
end
def meeting_name_limit
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 50f9e7ca..3ed56ede 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -93,6 +93,7 @@ class UsersController < ApplicationController
@user.update_attributes(email_verified: false)
redirect_to edit_user_path(@user), notice: I18n.t("info_update_success")
elsif @user.update_attributes(user_params)
+ update_locale(@user)
redirect_to edit_user_path(@user), notice: I18n.t("info_update_success")
else
render :edit, params: { settings: params[:settings] }
@@ -171,6 +172,6 @@ class UsersController < ApplicationController
def user_params
params.require(:user).permit(:name, :email, :image, :password, :password_confirmation,
- :new_password, :provider, :accepted_terms)
+ :new_password, :provider, :accepted_terms, :language)
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 7283d93e..6bbad7a5 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -46,6 +46,15 @@ module ApplicationHelper
Rails.configuration.bigbluebutton_endpoint_default == Rails.configuration.bigbluebutton_endpoint
end
+ # Returns language selection options
+ def language_options
+ language_opts = [['<<<< ' + t("language_options.default") + ' >>>>', "default"]]
+ Rails.configuration.languages.each do |loc|
+ language_opts.push([t("language_options." + loc), loc])
+ end
+ language_opts.sort
+ end
+
# Parses markdown for rendering.
def markdown(text)
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
diff --git a/app/views/shared/settings/_account.html.erb b/app/views/shared/settings/_account.html.erb
index 4a8eb00b..8d09d1c8 100644
--- a/app/views/shared/settings/_account.html.erb
+++ b/app/views/shared/settings/_account.html.erb
@@ -34,6 +34,9 @@
<%= f.label t("settings.account.provider"), class: "form-label" %>
<%= f.text_field :provider, class: "form-control", readonly: "" %>
+
+ <%= f.label t("settings.account.language"), class: "form-label" %>
+ <%= f.select :language, language_options, {}, { class: "form-control custom-select" } %>
<%= f.label t("settings.account.image"), class: "form-label mt-5" %>