feat(i18n): add i18n missing key error (#8358)

feat(i18n): 添加缺失翻译键的日志记录

当检测到缺失的翻译键时,记录错误日志以便于调试和维护
This commit is contained in:
Phantom 2025-07-21 22:20:42 +08:00 committed by GitHub
parent 929f7445ed
commit 8c58060716
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,3 +1,4 @@
import { loggerService } from '@renderer/services/LoggerService'
import { defaultLanguage } from '@shared/config/constant'
import i18n from 'i18next'
import { initReactI18next } from 'react-i18next'
@ -14,6 +15,8 @@ import esES from './translate/es-es.json'
import frFR from './translate/fr-fr.json'
import ptPT from './translate/pt-pt.json'
const logger = loggerService.withContext('I18N')
const resources = {
'el-GR': elGR,
'en-US': enUS,
@ -37,9 +40,12 @@ export const getLanguageCode = () => {
i18n.use(initReactI18next).init({
resources,
lng: getLanguage(),
fallbackLng: defaultLanguage,
interpolation: {
escapeValue: false
},
saveMissing: true,
missingKeyHandler: (_1, _2, key) => {
logger.error(`Missing key: ${key}`)
}
})