mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-05 07:28:42 +08:00
✨ Feature(custom): update i18n force update
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { ipcRenderer } from 'electron'
|
||||
import { ObjectAdapter, I18n } from '@picgo/i18n'
|
||||
|
||||
import bus from '@/utils/bus'
|
||||
import { sendRPC } from '@/utils/common'
|
||||
import { sendRPC, sendRpcSync } from '@/utils/common'
|
||||
|
||||
import { GET_CURRENT_LANGUAGE, SET_CURRENT_LANGUAGE, FORCE_UPDATE, GET_LANGUAGE_LIST } from '#/events/constants'
|
||||
import { SET_CURRENT_LANGUAGE } from '#/events/constants'
|
||||
import { builtinI18nList } from '#/i18n'
|
||||
import { IRPCActionType } from '#/types/enum'
|
||||
import { updatePageReloadCount } from '@/utils/global'
|
||||
|
||||
export class I18nManager {
|
||||
#i18n: I18n | null = null
|
||||
@@ -17,23 +17,17 @@ export class I18nManager {
|
||||
this.#getLanguageList()
|
||||
ipcRenderer.on(SET_CURRENT_LANGUAGE, (_, lang: string, locales: ILocales) => {
|
||||
this.#setLocales(lang, locales)
|
||||
bus.emit(FORCE_UPDATE)
|
||||
updatePageReloadCount()
|
||||
})
|
||||
}
|
||||
|
||||
#getLanguageList () {
|
||||
sendRPC(IRPCActionType.GET_LANGUAGE_LIST)
|
||||
ipcRenderer.once(GET_LANGUAGE_LIST, (_, list: II18nItem[]) => {
|
||||
this.#i18nFileList = list
|
||||
})
|
||||
this.#i18nFileList = sendRpcSync(IRPCActionType.GET_LANGUAGE_LIST)
|
||||
}
|
||||
|
||||
#getCurrentLanguage () {
|
||||
sendRPC(IRPCActionType.GET_CURRENT_LANGUAGE)
|
||||
ipcRenderer.once(GET_CURRENT_LANGUAGE, (_, lang: string, locales: ILocales) => {
|
||||
this.#setLocales(lang, locales)
|
||||
bus.emit(FORCE_UPDATE)
|
||||
})
|
||||
const [lang, locales] = sendRpcSync(IRPCActionType.GET_CURRENT_LANGUAGE)
|
||||
this.#setLocales(lang, locales)
|
||||
}
|
||||
|
||||
#setLocales (lang: string, locales: ILocales) {
|
||||
|
||||
Reference in New Issue
Block a user