Add language settings for users, and translate titles to French
All checks were successful
CI / scan_ruby (push) Successful in 16s
CI / scan_js (push) Successful in 12s
CI / lint (push) Successful in 13s
CI / test (push) Successful in 36s

This commit is contained in:
sto
2025-03-27 12:55:12 +01:00
parent 497768610d
commit 8b0b1c6745
14 changed files with 128 additions and 3 deletions

View File

@@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base
include Authentication
include Pundit::Authorization
before_action :set_title, :set_current_user
before_action :set_title, :set_current_user, :set_lang
after_action :verify_authorized
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
@@ -23,6 +23,10 @@ class ApplicationController < ActionController::Base
@current_user = current_user
end
def set_lang
I18n.locale = @current_user.lang if @current_user
end
def user_not_authorized(exception)
policy_name = exception.policy.class.to_s.underscore

View File

@@ -55,6 +55,6 @@ class UsersController < ApplicationController
end
def user_params
params.expect(user: [ :username, :email_address, :password ])
params.expect(user: [ :username, :email_address, :lang, :password ])
end
end