Refactoring i18n

This commit is contained in:
CELESTIFYX Team
2025-01-12 22:32:32 +02:00
committed by GitHub
parent c09cd6bd43
commit b6084343da
5 changed files with 30 additions and 25 deletions

View File

@@ -6,30 +6,18 @@ import {
} from "react-i18next"; } from "react-i18next";
import { import {
ENGLISH LOCALES
} from './locales/en'; } from './locales';
import { const resources = Object.fromEntries(
UKRAINIAN Object.entries(LOCALES).map(([key, value]) => [
} from './locales/uk'; key.toLowerCase(),
import { {
POLISH translation: value
} from './locales/pl'; }
])
const resources = { );
en: {
translation: ENGLISH
},
uk: {
translation: UKRAINIAN
},
pl: {
translation: POLISH
}
};
i18n.use(initReactI18next).use(LanguageDetector).init({ i18n.use(initReactI18next).use(LanguageDetector).init({
resources, resources,

View File

@@ -1,4 +1,4 @@
export const ENGLISH = { export const EN = {
// src/components/Header.tsx // src/components/Header.tsx
Header: { Header: {
"all-repositories": "All Repositories" "all-repositories": "All Repositories"

17
src/locales/index.tsx Normal file
View File

@@ -0,0 +1,17 @@
import {
EN
} from './en'; // English
import {
UK
} from './uk'; // Ukrainian
import {
PL
} from './pl'; // Polish
export const LOCALES = {
EN,
UK,
PL
};

View File

@@ -1,4 +1,4 @@
export const POLISH = { export const PL = {
// src/components/Header.tsx // src/components/Header.tsx
Header: { Header: {
"all-repositories": "Wszystkie repozytoria" "all-repositories": "Wszystkie repozytoria"

View File

@@ -1,4 +1,4 @@
export const UKRAINIAN = { export const UK = {
// src/components/Header.tsx // src/components/Header.tsx
Header: { Header: {
"all-repositories": "Усі репозиторії" "all-repositories": "Усі репозиторії"