From 8e47238bf7debcf7238a117b0cb9915f46c26665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Mon, 21 Jun 2021 13:10:08 +0200 Subject: [PATCH] Fix language attribute of top level html tag (#1705) Sets aka "fixes" the language attribute of the top level html tag. This was hard coded to 'en' before, what led to bad experiences with screen readers. We now set overwrite the attribute with the language from i18next. --- gradle/changelog/html_language_tag.yaml | 2 ++ scm-ui/ui-webapp/src/containers/Index.tsx | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 gradle/changelog/html_language_tag.yaml diff --git a/gradle/changelog/html_language_tag.yaml b/gradle/changelog/html_language_tag.yaml new file mode 100644 index 0000000000..f53a9bf6e2 --- /dev/null +++ b/gradle/changelog/html_language_tag.yaml @@ -0,0 +1,2 @@ +- type: fixed + description: Language tag of top level html element ([#1705](https://github.com/scm-manager/scm-manager/pull/1705)) diff --git a/scm-ui/ui-webapp/src/containers/Index.tsx b/scm-ui/ui-webapp/src/containers/Index.tsx index 74ac89c02c..12edbc7e10 100644 --- a/scm-ui/ui-webapp/src/containers/Index.tsx +++ b/scm-ui/ui-webapp/src/containers/Index.tsx @@ -29,6 +29,7 @@ import ScrollToTop from "./ScrollToTop"; import IndexErrorPage from "./IndexErrorPage"; import { useIndex } from "@scm-manager/ui-api"; import { Link } from "@scm-manager/ui-types"; +import i18next from "i18next"; const Index: FC = () => { const { isLoading, error, data } = useIndex(); @@ -36,6 +37,10 @@ const Index: FC = () => { // TODO check componentDidUpdate method for anonymous user stuff + i18next.on("languageChanged", (lng) => { + document.documentElement.setAttribute("lang", lng); + }); + if (error) { return ( <>