WIP i18next
This commit is contained in:
31
src/i18n/i18n.js
Normal file
31
src/i18n/i18n.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import i18next from 'i18next';
|
||||
import LanguageDetector from 'i18next-browser-languagedetector';
|
||||
import enLocale from './en.json';
|
||||
|
||||
|
||||
i18next
|
||||
.use(LanguageDetector)
|
||||
.init({
|
||||
// 配置你的本地化選項
|
||||
resources: {
|
||||
en: enLocale,
|
||||
de: {
|
||||
translation: {
|
||||
greeting: 'Hallo!'
|
||||
}
|
||||
}
|
||||
// 添加其他語言的翻譯
|
||||
},
|
||||
// 選擇默認的語言
|
||||
fallbackLng: 'en',
|
||||
|
||||
// 在初始化時自動檢測用戶的語言
|
||||
detection: {
|
||||
order: ['localStorage', 'navigator'],
|
||||
caches: ['localStorage']
|
||||
},
|
||||
|
||||
// 選擇性配置其他選項...
|
||||
});
|
||||
|
||||
export default i18next;
|
||||
Reference in New Issue
Block a user