diff --git a/web/client/components/I18N/Localized.jsx b/web/client/components/I18N/Localized.jsx index 0f56f3b819..a810e72155 100644 --- a/web/client/components/I18N/Localized.jsx +++ b/web/client/components/I18N/Localized.jsx @@ -32,6 +32,16 @@ class Localized extends React.Component { }; } + componentDidMount() { + this.updateDocumentLangAttribute(); + } + + componentDidUpdate(prevProps) { + if (this.props.locale !== prevProps.locale) { + this.updateDocumentLangAttribute(); + } + } + render() { let { children } = this.props; @@ -63,6 +73,12 @@ class Localized extends React.Component { }; }, {}); }; + + updateDocumentLangAttribute() { + if (document?.documentElement) { + document.documentElement.setAttribute("lang", this.props.locale); + } + } } export default Localized; diff --git a/web/client/components/I18N/__tests__/Localized-test.jsx b/web/client/components/I18N/__tests__/Localized-test.jsx index 829b0a70eb..91ab7542d4 100644 --- a/web/client/components/I18N/__tests__/Localized-test.jsx +++ b/web/client/components/I18N/__tests__/Localized-test.jsx @@ -40,6 +40,21 @@ describe('Test the localization support HOC', () => { expect(dom.innerHTML).toBe("my message"); }); + it('correctly sets the document language', () => { + ReactDOM.render( + + {() => } + + , document.getElementById("container")); + expect(document.documentElement.lang).toBe("it-IT"); + ReactDOM.render( + + {() => } + + , document.getElementById("container")); + expect(document.documentElement.lang).toBe("de-DE"); + }); + it('localizes wrapped HTML component', () => { var localized = ReactDOM.render( diff --git a/web/client/components/mapcontrols/scale/ScaleBox.jsx b/web/client/components/mapcontrols/scale/ScaleBox.jsx index 39333c2303..eebb3d5bad 100644 --- a/web/client/components/mapcontrols/scale/ScaleBox.jsx +++ b/web/client/components/mapcontrols/scale/ScaleBox.jsx @@ -73,8 +73,8 @@ class ScaleBox extends React.Component { } else { control = (
- {this.props.label} - + {this.props.label} + {this.getOptions()}
) diff --git a/web/client/components/misc/PaginationToolbar.jsx b/web/client/components/misc/PaginationToolbar.jsx index f9e6c99038..5a6d710914 100644 --- a/web/client/components/misc/PaginationToolbar.jsx +++ b/web/client/components/misc/PaginationToolbar.jsx @@ -65,7 +65,7 @@ class PaginationToolbar extends React.Component { onSelect={this.onSelect} /> -
{this.props.loading ? : msg}
+
{this.props.loading ? : msg}
); diff --git a/web/client/index.html b/web/client/index.html index d7f952eaf2..c868c1bf74 100644 --- a/web/client/index.html +++ b/web/client/index.html @@ -3,7 +3,7 @@ - + MapStore HomePage