Add language settings for users, and translate titles to French
This commit is contained in:
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user