From 9b155e018cad7d817c0e887320ed2714566edd3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lecour?= Date: Wed, 13 Jun 2018 20:28:37 +0200 Subject: [PATCH] Real label for locale selection --- app/helpers/application_helper.rb | 4 ++++ app/views/devise/registrations/edit.html.erb | 2 +- app/views/devise/registrations/new.html.erb | 2 +- config/locales/en.yml | 3 +++ config/locales/fr.yml | 3 +++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c5d65f3..f40a4ac 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2,4 +2,8 @@ module ApplicationHelper def format_utc(time, format: :default) l(time.utc, format: format) end + + def available_locales_collection + I18n.available_locales.map { |k| [t("shared.locales.#{k}"), k]} + end end diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 367c124..8207e04 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -24,7 +24,7 @@ <%= f.input :password_confirmation, autocomplete: "off" %> - <%= f.input :locale, label: t('.locale'), collection: I18n.available_locales, selected: resource.locale %> + <%= f.input :locale, label: t('.locale'), collection: available_locales_collection, selected: resource.locale %> <%= f.input :notifications_enabled %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 0c5150d..a7de793 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -9,7 +9,7 @@ <%= f.input :password_confirmation, autocomplete: "off" %> - <%= f.input :locale, label: t('.locale'), collection: I18n.available_locales, selected: I18n.default_locale %> + <%= f.input :locale, label: t('.locale'), collection: available_locales_collection, selected: I18n.default_locale %> <%= f.input :tos_accepted, label: t('.tos_acceptance_html') %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 805fee2..d2c4c13 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -40,6 +40,9 @@ en: shared: + locales: + en: English + fr: French navbar: sign_up: "Sign up" sign_in: "Sign in" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 87ba44c..007f979 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -40,6 +40,9 @@ fr: shared: + locales: + en: Anglais + fr: Français navbar: sign_up: "Enregistrement" sign_in: "Connexion"