enable i18n support for russian-only

This commit is contained in:
maxim
2025-02-19 14:17:48 +03:00
parent 5d3c6fe7f9
commit 774c01d9b7
5 changed files with 101 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import {Login} from './pages/login'
import {Register} from './pages/register'
import {ForgotPassword} from './pages/forgotPassword'
import {authProvider} from './authProvider'
import {i18nProvider} from './i18nProvider'
import {CountryList, CountryCreate, CountryEdit, CountryShow} from './pages/country'
import {CityList, CityCreate, CityEdit, CityShow} from './pages/city'
@ -43,6 +44,7 @@ function App() {
notificationProvider={useNotificationProvider}
routerProvider={routerBindings}
authProvider={authProvider}
i18nProvider={i18nProvider}
resources={[
{
name: 'country',

24
src/i18nProvider.ts Normal file
View File

@ -0,0 +1,24 @@
import i18n from 'i18next'
import {initReactI18next} from 'react-i18next'
import {I18nProvider} from '@refinedev/core'
import translationRU from './locales/ru/translation.json'
i18n.use(initReactI18next).init({
resources: {
ru: {
translation: translationRU,
},
},
lng: 'ru',
fallbackLng: 'ru',
interpolation: {
escapeValue: false,
},
})
export const i18nProvider: I18nProvider = {
translate: (key, options) => i18n.t(key, options) as string,
changeLocale: (locale: string) => i18n.changeLanguage(locale),
getLocale: () => i18n.language,
}

View File

@ -0,0 +1,18 @@
{
"actions": {
"create": "Создать",
"show": "Просмотр",
"edit": "Редактировать",
"delete": "Удалить",
"save": "Сохранить"
},
"buttons": {
"edit": "Редактировать",
"refresh": "Обновить",
"delete": "Удалить",
"save": "Сохранить",
"submit": "Отправить",
"create": "Создать",
"logout": "Выход"
}
}