Skip to content

Commit

Permalink
Pass locale property to ANTD config provider component
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitryashutov committed Feb 7, 2025
1 parent 5e7ca9d commit d6c05aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/services/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { i18n } from '@lingui/core';
import { Locale } from 'antd/es/locale';
import enAntdLocale from 'antd/es/locale/en_US';
import esAntdLocale from 'antd/es/locale/es_ES';
import ruAntdLocale from 'antd/es/locale/ru_RU';

import { en, es, ru } from 'make-plural/plurals';

import { messages as enMessages } from 'src/locale/en/messages';
Expand Down Expand Up @@ -42,3 +47,9 @@ export function dynamicActivate(locale: LocaleCode) {

i18n.activate(locale);
}

export const antdLocaleMap: { [localeCode in LocaleCode]: Locale } = {
en: enAntdLocale,
es: esAntdLocale,
ru: ruAntdLocale,
};
3 changes: 2 additions & 1 deletion src/theme/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ThemeProvider as StyledComponentsThemeProvider, createGlobalStyle } fro

import { getAppTheme, getANTDTheme } from './';
import { useTheme } from '../utils/theme';
import { antdLocaleMap, getCurrentLocale } from 'src/services/i18n';

interface Props {
theme?: 'dark' | 'light';
Expand Down Expand Up @@ -36,7 +37,7 @@ export function ThemeProvider(props: Props) {
};

return (
<ANTDConfigProvider theme={antdTheme}>
<ANTDConfigProvider theme={antdTheme} locale={antdLocaleMap[getCurrentLocale()]}>
<StyledComponentsThemeProvider theme={appTheme}>
<GlobalStyle />
{children}
Expand Down

0 comments on commit d6c05aa

Please sign in to comment.