mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 17:59:28 +08:00
include english in main bundle (fixes fallback lang)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import i18n from "i18next"
|
import i18n from "i18next"
|
||||||
import { initReactI18next } from "react-i18next"
|
import { initReactI18next } from "react-i18next"
|
||||||
|
import enTranslations from "../locales/en/translation.json"
|
||||||
|
|
||||||
// Custom language detector to use localStorage
|
// Custom language detector to use localStorage
|
||||||
const languageDetector: any = {
|
const languageDetector: any = {
|
||||||
@@ -30,13 +31,14 @@ const languageDetector: any = {
|
|||||||
// Function to dynamically load translation files
|
// Function to dynamically load translation files
|
||||||
async function loadMessages(locale: string) {
|
async function loadMessages(locale: string) {
|
||||||
try {
|
try {
|
||||||
|
if (locale === "en") {
|
||||||
|
return enTranslations
|
||||||
|
}
|
||||||
const translation = await import(`../locales/${locale}/translation.json`)
|
const translation = await import(`../locales/${locale}/translation.json`)
|
||||||
return translation.default
|
return translation.default
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error loading ${locale}`, error)
|
console.error(`Error loading ${locale}`, error)
|
||||||
// Fallback to English if translation fails to load
|
return enTranslations
|
||||||
const enTranslation = await import(`../locales/en/translation.json`)
|
|
||||||
return enTranslation.default
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +46,11 @@ i18n
|
|||||||
.use(languageDetector)
|
.use(languageDetector)
|
||||||
.use(initReactI18next)
|
.use(initReactI18next)
|
||||||
.init({
|
.init({
|
||||||
resources: {}, // Start with empty resources
|
resources: {
|
||||||
|
en: {
|
||||||
|
translation: enTranslations,
|
||||||
|
},
|
||||||
|
},
|
||||||
fallbackLng: "en",
|
fallbackLng: "en",
|
||||||
interpolation: {
|
interpolation: {
|
||||||
escapeValue: false,
|
escapeValue: false,
|
||||||
|
Reference in New Issue
Block a user