Add html dir attribute

This commit is contained in:
ErickSkrauch 2021-03-25 04:35:50 +01:00
parent a2d4243bc3
commit 370725dd7e
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
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

View File

@ -3439,6 +3439,11 @@
"@types/prop-types" "*"
csstype "^3.0.2"
"@types/rtl-detect@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/rtl-detect/-/rtl-detect-1.0.0.tgz#5791e18a111f2b8b5b328160af97f3991a5697a5"
integrity sha512-lyYh44YgrejEK9/5rhASghvRUOxrSJyyyQmqK7L6F/V5qs6PY1RfCi1VbjSkY6kuDt7lzQyhd006slhda4Oypg==
"@types/sax@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@types/sax/-/sax-1.2.1.tgz#e0248be936ece791a82db1a57f3fb5f7c87e8172"
@ -14246,6 +14251,11 @@ rsvp@^4.8.4:
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734"
integrity sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==
rtl-detect@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/rtl-detect/-/rtl-detect-1.0.2.tgz#8eca316f5c6563d54df4e406171dd7819adda67f"
integrity sha512-5X1422hvphzg2a/bo4tIDbjFjbJUOaPZwqE6dnyyxqwFqfR+tBcvfqapJr0o0VygATVCGKiODEewhZtKF+90AA==
run-async@^2.2.0, run-async@^2.4.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455"