From 572e1dca8e454594203ad51f8b852c53bd2387ea Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 21 Apr 2022 10:28:23 +0200 Subject: [PATCH] fix(a11y): html lang should reflect locale fix #7150 --- app/helpers/application_helper.rb | 4 ++++ app/views/layouts/application.html.haml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c1c6999a6..39f04b140 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,6 +1,10 @@ module ApplicationHelper include SanitizeUrl + def html_lang + I18n.locale.to_s + end + def sanitize_url(url) if !url.nil? super(url, schemes: ['http', 'https'], replace_evil_with: root_url) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 7aee764b5..52f4934b4 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,5 +1,5 @@ !!! 5 -%html{ lang: "fr", class: yield(:root_class) } +%html{ lang: html_lang, class: yield(:root_class) } %head %meta{ "http-equiv": "Content-Type", content: "text/html; charset=UTF-8" } %meta{ "http-equiv": "X-UA-Compatible", content: "IE=edge" }