mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 18:50:56 +08:00
refactor(i18n): restructure translation resources and update logger context
Move translation files to new location and update resource structure to include translation namespace Update logger context to include module prefix for better debugging
This commit is contained in:
parent
b02678a714
commit
57206dd3b1
@ -5,31 +5,54 @@ import type { LanguageVarious } from '@shared/data/preference/preferenceTypes'
|
||||
import { app } from 'electron'
|
||||
import i18n from 'i18next'
|
||||
|
||||
import EnUs from '../../renderer/src/i18n/locales/en-us.json'
|
||||
import ZhCn from '../../renderer/src/i18n/locales/zh-cn.json'
|
||||
import ZhTw from '../../renderer/src/i18n/locales/zh-tw.json'
|
||||
// import deDE from '../../renderer/src/i18n/locales/de-de.json'
|
||||
// import elGR from '../../renderer/src/i18n/locales/el-gr.json'
|
||||
import EnUs from '../../renderer/src/i18n/locales/en-us.json'
|
||||
// import esES from '../../renderer/src/i18n/locales/es-es.json'
|
||||
// import frFR from '../../renderer/src/i18n/locales/fr-fr.json'
|
||||
// import JaJP from '../../renderer/src/i18n/locales/ja-jp.json'
|
||||
// import ptPT from '../../renderer/src/i18n/locales/pt-pt.json'
|
||||
// import RuRu from '../../renderer/src/i18n/locales/ru-ru.json'
|
||||
import ZhCn from '../../renderer/src/i18n/locales/zh-cn.json'
|
||||
import ZhTw from '../../renderer/src/i18n/locales/zh-tw.json'
|
||||
import deDE from '../../renderer/src/i18n/translate/de-de.json'
|
||||
import elGR from '../../renderer/src/i18n/translate/el-gr.json'
|
||||
import esES from '../../renderer/src/i18n/translate/es-es.json'
|
||||
import frFR from '../../renderer/src/i18n/translate/fr-fr.json'
|
||||
import JaJP from '../../renderer/src/i18n/translate/ja-jp.json'
|
||||
import ptPT from '../../renderer/src/i18n/translate/pt-pt.json'
|
||||
import RuRu from '../../renderer/src/i18n/translate/ru-ru.json'
|
||||
|
||||
const logger = loggerService.withContext('i18n')
|
||||
const logger = loggerService.withContext('main:i18n')
|
||||
|
||||
const resources = Object.fromEntries([
|
||||
['en-us', EnUs],
|
||||
['zh-cn', ZhCn],
|
||||
['zh-tw', ZhTw]
|
||||
// ['ja-JP', JaJP],
|
||||
// ['ru-RU', RuRu],
|
||||
// ['de-DE', deDE],
|
||||
// ['el-GR', elGR],
|
||||
// ['es-ES', esES],
|
||||
// ['fr-FR', frFR],
|
||||
// ['pt-PT', ptPT]
|
||||
] as const)
|
||||
// const resources = Object.fromEntries([
|
||||
// ['en-us', EnUs],
|
||||
// ['zh-cn', ZhCn],
|
||||
// ['zh-tw', ZhTw],
|
||||
// ['ja-JP', JaJP],
|
||||
// ['ru-RU', RuRu],
|
||||
// ['de-DE', deDE],
|
||||
// ['el-GR', elGR],
|
||||
// ['es-ES', esES],
|
||||
// ['fr-FR', frFR],
|
||||
// ['pt-PT', ptPT]
|
||||
// ] as const)
|
||||
const resources = Object.fromEntries(
|
||||
(
|
||||
[
|
||||
['en-us', EnUs],
|
||||
['zh-cn', ZhCn],
|
||||
['zh-tw', ZhTw],
|
||||
['ja-JP', JaJP],
|
||||
['ru-RU', RuRu],
|
||||
['de-DE', deDE],
|
||||
['el-GR', elGR],
|
||||
['es-ES', esES],
|
||||
['fr-FR', frFR],
|
||||
['pt-PT', ptPT]
|
||||
] as const
|
||||
).map(([key, translation]) => [key, { translation }])
|
||||
)
|
||||
|
||||
export const getAppLanguage = (): LanguageVarious => {
|
||||
const language = preferenceService.get('app.language')
|
||||
|
||||
@ -4,31 +4,54 @@ import { defaultLanguage } from '@shared/config/constant'
|
||||
import i18n from 'i18next'
|
||||
import { initReactI18next } from 'react-i18next'
|
||||
|
||||
import enUS from './locales/en-us.json'
|
||||
import zhCN from './locales/zh-cn.json'
|
||||
import zhTW from './locales/zh-tw.json'
|
||||
// import deDE from './locales/de-de.json'
|
||||
// import elGR from './locales/el-gr.json'
|
||||
import enUS from './locales/en-us.json'
|
||||
// import esES from './locales/es-es.json'
|
||||
// import frFR from './locales/fr-fr.json'
|
||||
// import jaJP from './locales/ja-jp.json'
|
||||
// import ptPT from './locales/pt-pt.json'
|
||||
// import ruRU from './locales/ru-ru.json'
|
||||
import zhCN from './locales/zh-cn.json'
|
||||
import zhTW from './locales/zh-tw.json'
|
||||
import deDE from './translate/de-de.json'
|
||||
import elGR from './translate/el-gr.json'
|
||||
import esES from './translate/es-es.json'
|
||||
import frFR from './translate/fr-fr.json'
|
||||
import jaJP from './translate/ja-jp.json'
|
||||
import ptPT from './translate/pt-pt.json'
|
||||
import ruRU from './translate/ru-ru.json'
|
||||
|
||||
const logger = loggerService.withContext('I18N')
|
||||
const logger = loggerService.withContext('renderer:i18n')
|
||||
|
||||
const resources = Object.fromEntries([
|
||||
['en-US', enUS],
|
||||
// ['ja-JP', jaJP],
|
||||
// ['ru-RU', ruRU],
|
||||
['zh-CN', zhCN],
|
||||
['zh-TW', zhTW]
|
||||
// ['de-DE', deDE],
|
||||
// ['el-GR', elGR],
|
||||
// ['es-ES', esES],
|
||||
// ['fr-FR', frFR],
|
||||
// ['pt-PT', ptPT]
|
||||
])
|
||||
// const resources = Object.fromEntries([
|
||||
// ['en-US', enUS],
|
||||
// ['zh-CN', zhCN],
|
||||
// ['zh-TW', zhTW],
|
||||
// ['de-DE', deDE],
|
||||
// ['el-GR', elGR],
|
||||
// ['es-ES', esES],
|
||||
// ['fr-FR', frFR],
|
||||
// ['ja-JP', jaJP],
|
||||
// ['pt-PT', ptPT],
|
||||
// ['ru-RU', ruRU]
|
||||
// ])
|
||||
const resources = Object.fromEntries(
|
||||
(
|
||||
[
|
||||
['en-US', enUS],
|
||||
['zh-CN', zhCN],
|
||||
['zh-TW', zhTW],
|
||||
['de-DE', deDE],
|
||||
['el-GR', elGR],
|
||||
['es-ES', esES],
|
||||
['fr-FR', frFR],
|
||||
['ja-JP', jaJP],
|
||||
['pt-PT', ptPT],
|
||||
['ru-RU', ruRU]
|
||||
] as const
|
||||
).map(([key, translation]) => [key, { translation }])
|
||||
)
|
||||
|
||||
export const getLanguage = async () => {
|
||||
return (await preferenceService.get('app.language')) || navigator.language || defaultLanguage
|
||||
|
||||
Loading…
Reference in New Issue
Block a user