This commit is contained in:
Baobhan Sith
2025-04-15 19:55:57 +08:00
parent c026a42d06
commit 37eb5ee9ab
20 changed files with 898 additions and 333 deletions
+27
View File
@@ -0,0 +1,27 @@
import i18next from 'i18next';
import Backend from 'i18next-fs-backend';
import path from 'path';
// 定义支持的语言
export const supportedLngs = ['en', 'zh'];
export const defaultLng = 'en';
i18next
.use(Backend)
.init({
// debug: process.env.NODE_ENV === 'development', // 可选:开发模式下开启调试
supportedLngs,
fallbackLng: defaultLng,
lng: defaultLng, // 默认语言
ns: ['notifications'], // 命名空间,用于组织翻译
defaultNS: 'notifications',
backend: {
// path where resources get loaded from
loadPath: path.join(__dirname, 'locales/{{lng}}/{{ns}}.json'),
},
interpolation: {
escapeValue: false, // 不对插值进行转义,因为我们可能需要 HTML 或 Markdown
},
});
export default i18next;