core icon indicating copy to clipboard operation
core copied to clipboard

HTML lang attribute does not change

Open doudbanks opened this issue 5 years ago • 3 comments

Current behavior

When changing the language through setDefaultLang(param);, the lang attribute of the html root ellement in the dom does not change, it's a major issue for screen readers ...

Expected behavior

HTML lang attribute changes.

How do you think that we should fix this?

Select the attribute and change his value when the language is changed.

Minimal reproduction of the problem with instructions

Just change the language using setDefaultLang() and check the html root element via the chrome inspector.

Environment

Angular CLI: 6.1.5 Node: 8.11.3 OS: win32 x64 Angular: 6.1.6 ngx-translate-core v10.0.2



Browser:
- [ ] Chromium (desktop) version 70.0.3518.0

doudbanks avatar Oct 02 '18 14:10 doudbanks

This should helps you: https://github.com/ngx-translate/core/issues/565

Mr-Eluzive avatar Oct 13 '18 11:10 Mr-Eluzive

@ocombe Any news regarding #565? +1

miloshavlicek avatar Aug 05 '20 14:08 miloshavlicek

It's simple, you may do it yourself: https://stackoverflow.com/a/53995975

  constructor(
    @Inject(LOCALE_ID) locale: string,
    @Inject(DOCUMENT) document: Document,
  ) {
    document.documentElement.lang = locale;
  }

Znippet avatar Oct 27 '23 09:10 Znippet