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";
import {
ENGLISH
} from './locales/en';
LOCALES
} from './locales';
import {
UKRAINIAN
} from './locales/uk';
const resources = Object.fromEntries(
Object.entries(LOCALES).map(([key, value]) => [
key.toLowerCase(),
import {
POLISH
} from './locales/pl';
const resources = {
en: {
translation: ENGLISH
},
uk: {
translation: UKRAINIAN
},
pl: {
translation: POLISH
}
};
{
translation: value
}
])
);
i18n.use(initReactI18next).use(LanguageDetector).init({
resources,

View File

@@ -1,4 +1,4 @@
export const ENGLISH = {
export const EN = {
// src/components/Header.tsx
Header: {
"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
Header: {
"all-repositories": "Wszystkie repozytoria"

View File

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