Add html dir attribute

This commit is contained in:
ErickSkrauch
2021-03-25 04:35:50 +01:00
parent a2d4243bc3
commit 370725dd7e
4 changed files with 21 additions and 6 deletions

View File

@@ -1,5 +1,8 @@
import React, { useState, useEffect, ComponentType } from 'react';
import { RawIntlProvider, IntlShape } from 'react-intl';
import { Helmet } from 'react-helmet-async';
import { getLangDir } from 'rtl-detect';
import i18n from 'app/services/i18n';
import { useReduxSelector } from 'app/functions';
@@ -26,7 +29,12 @@ const IntlProvider: ComponentType = ({ children }) => {
return null;
}
return <RawIntlProvider value={intl}>{children}</RawIntlProvider>;
return (
<RawIntlProvider value={intl}>
<Helmet htmlAttributes={{ lang: locale, dir: getLangDir(locale) }} />
{children}
</RawIntlProvider>
);
};
export default IntlProvider;

View File

@@ -30,6 +30,7 @@
"redux": "^4.0.5",
"redux-localstorage": "^0.4.1",
"redux-thunk": "^2.0.0",
"rtl-detect": "^1.0.2",
"url-search-params-polyfill": "^8.1.0",
"webfontloader": "^1.6.26",
"whatwg-fetch": "^3.0.0"
@@ -45,6 +46,7 @@
"@types/react-helmet": "^6.0.0",
"@types/react-motion": "^0.0.29",
"@types/react-transition-group": "^4.2.4",
"@types/rtl-detect": "^1.0.0",
"@types/webfontloader": "^1.6.30",
"@types/webpack-env": "^1.15.2",
"utility-types": "^3.10.0"

View File

@@ -1,6 +1,5 @@
import React from 'react';
import { Route, Switch } from 'react-router-dom';
import { Helmet } from 'react-helmet-async';
import clsx from 'clsx';
import { connect } from 'app/functions';
@@ -54,10 +53,6 @@ class RootPage extends React.PureComponent<{
return (
<div className={styles.root}>
<Helmet>
<html lang={user.lang} />
</Helmet>
<ScrollIntoView top />
<div