Skip to content
Snippets Groups Projects
Unverified Commit d39cd7bd authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

language input

parent f4f9ee5c
No related branches found
No related tags found
No related merge requests found
module ApplicationController::WithErrors
extend ActiveSupport::Concern
included do
rescue_from CanCan::AccessDenied do |exception|
render_forbidden
end
rescue_from ActionController::RoutingError do |exception|
render_not_found
end
rescue_from ActiveRecord::RecordNotFound do |exception|
render_not_found
end
def raise_403_unless(condition)
raise CanCan::AccessDenied unless condition
end
def raise_404_unless(condition)
raise ActionController::RoutingError.new('Not Found') unless condition
end
def handle_unverified_request
redirect_back(fallback_location: root_path, alert: t('inactivity_alert'))
end
def render_not_found
render file: Rails.root.join('public/404.html'), formats: [:html], status: 404, layout: false
end
def render_forbidden
render file: Rails.root.join('public/403.html'), formats: [:html], status: 403, layout: false
end
end
end
......@@ -5,7 +5,7 @@ class LocaleService
user&.language.nil? ? self.preferred_language(accept_language_header) : user.language.iso_code.to_sym
end
def self.preferred_language(brand_languages, accept_language_header)
def self.preferred_language(accept_language_header)
# browser_language > french
browser_languages = accept_language_header&.scan(/\*|([a-z]{1,8}(?:-[A-Z0-9]{1,8})*)/i)&.flatten&.compact&.reject { |v| v == "q" }
......
......@@ -18,17 +18,19 @@
<% end %>
<%= f.input :mobile_phone %>
<%= f.association :language, include_blank: false %>
<%= f.association :language,
include_blank: false,
label_method: lambda { |l| t("languages.#{l.iso_code.to_s}") } %>
<%= f.input :picture,
as: :single_deletable_file,
input_html: { accept: '.png' } %>
as: :single_deletable_file,
input_html: { accept: '.png' } %>
<%= f.input :password,
hint: t(".leave_blank_if_you_don_t_want_to_change_it"),
required: false,
input_html: { autocomplete: "new-password" } %>
</div>
......
......@@ -34,7 +34,7 @@
input_html: { autocomplete: "new-password" } %>
<%= f.association :language,
required: true,
label_method: lambda { |l| I18nData.languages(I18n.locale.to_s.upcase)[l.iso_code.to_s.upcase].capitalize },
label_method: lambda { |l| t("languages.#{l.iso_code.to_s}") },
include_blank: 'Sélectionnez une langue' %>
<%= f.input :picture,
as: :single_deletable_file,
......
......@@ -68,6 +68,9 @@ en:
edit: Edit
false: No
home: Home
languages:
en: English
fr: French
login:
already_registered: Already registered?
not_registered_yet: Not registered yet?
......
......@@ -68,6 +68,9 @@ fr:
edit: Modifier
false: Non
home: Accueil
languages:
en: Anglais
fr: Français
login:
already_registered: Déjà inscrit ?
not_registered_yet: Pas encore inscrit ?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment