From 545f0d8223e88631f8d7c13077ffe5bae78716cb Mon Sep 17 00:00:00 2001 From: rahighi Date: Sat, 28 Aug 2021 09:41:25 +0430 Subject: Only multiple language support feature --- modern/src/common/localization.js | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'modern/src/common/localization.js') diff --git a/modern/src/common/localization.js b/modern/src/common/localization.js index 26b90e57..6f3e5855 100644 --- a/modern/src/common/localization.js +++ b/modern/src/common/localization.js @@ -1,7 +1,5 @@ import React, { useState, createContext, useContext, useEffect } from "react"; import { create } from 'jss'; -import rtl from 'jss-rtl'; -import { StylesProvider, jssPreset, useTheme, ThemeProvider } from '@material-ui/core/styles'; import af from '../../../web/l10n/af.json'; import ar from '../../../web/l10n/ar.json'; @@ -149,47 +147,28 @@ export default key => { return selectedLanguage.data[key]; }; -const rtlLangueges = ['ar', 'he', 'fa']; -const isRtl = (language) => rtlLangueges.indexOf(language) > -1; - export const setSelectedLanguage = (language) => { selectedLanguage = supportedLanguages[language]; localStorage.setItem('language', language); - localStorage.setItem('direction', isRtl(language) ? 'rtl' : 'ltr'); } export const defaultLanguage = language; -const defaultDirection = localStorage.getItem('direction') || 'ltr'; export const LocalizationContext = createContext({ - direction: defaultDirection, language }); -const jss = create({ plugins: [...jssPreset().plugins, rtl()] }); export function LocalizationProvider(props) { const [language, setLanguage] = useState(defaultLanguage); - const [direction, setDirection] = useState(defaultDirection); - const handleLanguageChange = (nextLanguage) => { setSelectedLanguage(nextLanguage); setLanguage(nextLanguage); - setDirection(isRtl(nextLanguage) ? 'rtl' : 'ltr'); }; - useEffect(() => { - theme.direction = direction; - window.document.body.dir = direction - }, [direction]) - - return - - - {props.children} - - + return + {props.children} } -- cgit v1.2.3