diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 315340e79..70b116d78 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -5,6 +5,18 @@ module ApplicationHelper I18n.locale.to_s end + def active_locale_link(locale) + link_to save_locale_path(locale:), { + method: :post, + class: "fr-translate__language fr-nav__link", + hreflang: locale, + lang: locale, + "aria-current": I18n.locale == locale ? "true" : nil + }.compact do + yield + end + end + def sanitize_url(url) if !url.nil? super(url, schemes: ['http', 'https'], replace_evil_with: root_url) diff --git a/app/views/layouts/_locale_dropdown.html.haml b/app/views/layouts/_locale_dropdown.html.haml index 12298abca..287df6ec3 100644 --- a/app/views/layouts/_locale_dropdown.html.haml +++ b/app/views/layouts/_locale_dropdown.html.haml @@ -1,14 +1,13 @@ %nav.fr-translate.fr-nav{ :role => "navigation", title: t('.select_locale') } .fr-nav__item %button.fr-translate__btn.fr-btn{ "aria-controls" => "translate", "aria-expanded" => "false", :title => t('.select_locale') } - = t(".#{I18n.locale}") - %span.fr-hidden-lg= t('.francais') + = I18n.locale.upcase + %span.fr-hidden-lg= " - #{t('.locale_name')}" #translate.fr-collapse.fr-menu %ul.fr-menu__list %li - = active_link_to save_locale_path(locale: :fr), method: :post, class: "fr-translate__language fr-nav__link", active: I18n.locale == :fr, hreflang: "fr", lang: "fr" do - = t('.fr_francais') + = active_locale_link(:fr) do + FR - Français %li - = active_link_to save_locale_path(locale: :en), method: :post, class: "fr-translate__language fr-nav__link", active: I18n.locale == :en, hreflang: "en", lang: "en" do - = t('.en_english') - + = active_locale_link(:en) do + EN - English diff --git a/config/locales/en.yml b/config/locales/en.yml index 0062b9469..8ea378153 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -74,13 +74,8 @@ en: back_title: "Revenir sur le site de mon administration" main_menu: "Main menu" locale_dropdown: - languages: "Languages" select_locale: "Choose a language" - fr: FR - en: EN - francais: " - French" - fr_francais: FR - French - en_english: EN - English + locale_name: "English" notifications: actions: access: View your File diff --git a/config/locales/fr.yml b/config/locales/fr.yml index a4807236c..bc9f96849 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -64,13 +64,8 @@ fr: back_title: "Revenir sur le site de mon administration" main_menu: "Menu principal" locale_dropdown: - languages: "Langues" select_locale: "Sélectionner une langue" - fr: FR - en: EN - francais: " - Français" - fr_francais: FR - Français - en_english: EN - Anglais + locale_name: "Français" notifications: actions: access: Consulter mon dossier