feat: Add base setup for Internationalization(i18n)

This commit is contained in:
dhinesh-m24
2026-02-09 12:24:28 +05:30
parent 1c8541cb1d
commit 444c1234c0
6 changed files with 162 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import Backend from "i18next-http-backend";
i18n
.use(LanguageDetector) // detects browser language
.use(initReactI18next)// passes i18n down to react-i18next
.use(Backend) // loads translations asynchoronusly from /locales/{{lng}}/{{ns}}.json
.init({
fallbackLng: "en", // fallback language
debug: true,
});
export default i18n;

View File

@@ -0,0 +1,5 @@
{
"welcome": "Welcome",
"login": "Login",
"logout": "Logout"
}

View File

@@ -0,0 +1,5 @@
{
"welcome": "Bienvenido",
"login": "Iniciar sesión",
"logout": "Cerrar sesión"
}

View File

@@ -2,9 +2,13 @@ import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
import "@/i18n"
import { Suspense } from 'react'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
<Suspense fallback={<div>Loading...</div>}>
<App />
</Suspense>
</StrictMode>,
)