diff --git a/web/client/components/I18N/Localized.jsx b/web/client/components/I18N/Localized.jsx index 8473efee2be..b5adbccfe83 100644 --- a/web/client/components/I18N/Localized.jsx +++ b/web/client/components/I18N/Localized.jsx @@ -30,6 +30,22 @@ class Localized extends React.Component { }; } + componentDidMount() { + this.updateDocumentLangAttribute(); + } + + componentDidUpdate(prevProps) { + if (this.props.locale !== prevProps.locale) { + this.updateDocumentLangAttribute(); + } + } + + updateDocumentLangAttribute() { + if (document?.documentElement) { + document.documentElement.setAttribute("lang", this.props.locale); + } + } + render() { let { children } = this.props; @@ -50,22 +66,6 @@ class Localized extends React.Component { return null; } - componentDidMount() { - this.updateDocumentLangAttribute(); - } - - componentDidUpdate(prevProps) { - if (this.props.locale !== prevProps.locale) { - this.updateDocumentLangAttribute(); - } - } - - updateDocumentLangAttribute() { - if (document?.documentElement) { - document.documentElement.setAttribute("lang", this.props.locale); - } - } - flattenMessages = (messages, prefix = '') => { return Object.keys(messages).reduce((previous, current) => { return typeof messages[current] === 'string' ? {