feat: yup locale.

This commit is contained in:
elforjani3
2021-06-12 18:13:49 +02:00
parent 7d5bb95e75
commit 3fe85c519d
4 changed files with 79 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
import React from 'react';
import moment from 'moment';
import { setLocale } from 'yup';
import intl from 'react-intl-universal';
import { find } from 'lodash';
import rtlDetect from 'rtl-detect';
@@ -32,6 +33,10 @@ function loadLocales(currentLocale) {
return import(`../lang/${currentLocale}/index.json`);
}
function loadYupLocales(currentLocale) {
return import(`../lang/${currentLocale}/locale`);
}
/**
* Modifies the html document direction to RTl if it was rtl-language.
*/
@@ -74,6 +79,14 @@ export default function AppIntlLoader({ children }) {
});
}, [currentLocale, setIsLoading]);
React.useEffect(() => {
loadYupLocales(currentLocale)
.then(({ locale }) => {
setLocale(locale);
})
.then(() => {});
}, [currentLocale]);
return (
<DashboardLoadingIndicator isLoading={isLoading}>
{children}