new file: src/locales/de/translation.json

new file:   src/locales/en/translation.json
new file:   src/locales/fr/translation.json
modified:   src/main.tsx
This commit is contained in:
Dosseh91
2025-06-23 22:23:35 +02:00
committed by null
parent 942621a7c3
commit 0397d7ed08
5 changed files with 24 additions and 67 deletions

View File

@@ -1,66 +0,0 @@
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
// We will import the translations as we create them
// For now, we'll define them here and move them to JSON files in the next step
const resources = {
en: {
translation: {
// Navbar
"Home": "Home",
"Listings": "Listings",
"Categories": "Categories",
"SearchPlaceholder": "Search listings...",
"SignIn": "Sign in",
"Register": "Register",
// Add other keys here
}
},
fr: {
translation: {
// Navbar
"Home": "Accueil",
"Listings": "Annonces",
"Categories": "Catégories",
"SearchPlaceholder": "Rechercher des annonces...",
"SignIn": "Connexion",
"Register": "S'inscrire",
// Add other keys here
}
},
de: {
translation: {
// Navbar
"Home": "Startseite",
"Listings": "Angebote",
"Categories": "Kategorien",
"SearchPlaceholder": "Angebote suchen...",
"SignIn": "Anmelden",
"Register": "Registrieren",
// Add other keys here
}
}
};
i18n
// Detect user language
.use(LanguageDetector)
// Pass the i18n instance to react-i18next.
.use(initReactI18next)
// Init i18next
.init({
resources,
fallbackLng: 'en', // Use English if the detected language is not available
interpolation: {
escapeValue: false, // React already safes from xss
},
detection: {
// Order and from where user language should be detected
order: ['localStorage', 'navigator', 'htmlTag', 'path', 'subdomain'],
caches: ['localStorage'],
}
});
export default i18n;

View File

@@ -0,0 +1,8 @@
{
"Home": "Startseite",
"Listings": "Angebote",
"Categories": "Kategorien",
"SearchPlaceholder": "Angebote suchen...",
"SignIn": "Anmelden",
"Register": "Registrieren"
}

View File

@@ -0,0 +1,8 @@
{
"Home": "Home",
"Listings": "Listings",
"Categories": "Categories",
"SearchPlaceholder": "Search listings...",
"SignIn": "Sign in",
"Register": "Register"
}

View File

@@ -0,0 +1,8 @@
{
"Home": "Accueil",
"Listings": "Annonces",
"Categories": "Catégories",
"SearchPlaceholder": "Rechercher des annonces...",
"SignIn": "Connexion",
"Register": "S'inscrire"
}

View File

@@ -2,7 +2,6 @@ import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client'; import { createRoot } from 'react-dom/client';
import App from './App.tsx'; import App from './App.tsx';
import './index.css'; import './index.css';
import './i18n';
createRoot(document.getElementById('root')!).render( createRoot(document.getElementById('root')!).render(
<StrictMode> <StrictMode>