fix(theme): load language-specific font and fix font not updating on language change
This commit is contained in:
@@ -10,7 +10,10 @@ export const CustomThemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||
const { i18n } = useTranslation();
|
||||
|
||||
const theme = useMemo(() => {
|
||||
console.log('Theme recalculated, lang:', i18n.language);
|
||||
const direction = i18n.dir(i18n.language);
|
||||
const isEnglish = i18n.language?.startsWith('en');
|
||||
const fontFamily = isEnglish ? 'iranyekanEnNum' : 'iranyekan';
|
||||
|
||||
return createTheme({
|
||||
direction: direction,
|
||||
@@ -29,7 +32,10 @@ export const CustomThemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||
shape: {
|
||||
borderRadius: 8,
|
||||
},
|
||||
typography: typography,
|
||||
typography: {
|
||||
fontFamily: [fontFamily, 'sans-serif'].join(','),
|
||||
...typography,
|
||||
},
|
||||
components: {
|
||||
MuiButton: {
|
||||
defaultProps: {
|
||||
@@ -59,7 +65,7 @@ export const CustomThemeProvider: React.FC<{ children: React.ReactNode }> = ({
|
||||
},
|
||||
},
|
||||
});
|
||||
}, [i18n]);
|
||||
}, [i18n, i18n.language]);
|
||||
|
||||
return (
|
||||
<ThemeProvider theme={theme} defaultMode="light">
|
||||
|
||||
Reference in New Issue
Block a user