Update src/i18n.ts

This commit is contained in:
2026-06-03 21:48:10 +00:00
parent b6fc31affc
commit d24529c85e

View File

@@ -1,14 +1,24 @@
import { notFound } from 'next/navigation';
// @ts-ignore
import { getRequestConfig } from 'next-intl';
import i18n from 'i18next';
// @ts-expect-error
import Backend from 'i18next-http-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';
// Can be imported from a shared config
const locales = ['en', 'de'];
i18n
.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng: 'en',
debug: false,
interpolation: {
escapeValue: false,
},
backend: {
loadPath: '/locales/{{lng}}/{{ns}}.json',
},
ns: ['common', 'home'],
defaultNS: 'common',
});
export default getRequestConfig(async ({ locale }) => {
if (!locales.includes(locale as any)) notFound();
return {
messages: (await import(`../messages/${locale}.json`)).default,
};
});
export default i18n;