mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-21 16:20:46 +08:00
✨ Feature: add i18n for en
This commit is contained in:
@@ -11,6 +11,24 @@
|
||||
label-width="10"
|
||||
size="small"
|
||||
>
|
||||
<el-form-item
|
||||
:label="$T('SETTINGS_CHOOSE_LANGUAGE')"
|
||||
>
|
||||
<!-- <el-button type="primary" round size="mini" @click="openFile('data.json')">{{ $T('SETTINGS_CLICK_TO_OPEN') }}</el-button> -->
|
||||
<el-select
|
||||
v-model="currentLanguage"
|
||||
size="mini"
|
||||
style="width: 100%"
|
||||
@change="handleLanguageChange"
|
||||
:placeholder="$T('SETTINGS_CHOOSE_LANGUAGE')">
|
||||
<el-option
|
||||
v-for="item in languageList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$T('SETTINGS_OPEN_CONFIG_FILE')"
|
||||
>
|
||||
@@ -350,12 +368,12 @@
|
||||
import keyDetect from '@/utils/key-binding'
|
||||
import pkg from 'root/package.json'
|
||||
import { IConfig } from 'picgo'
|
||||
import { PICGO_OPEN_FILE, OPEN_URL } from '#/events/constants'
|
||||
import { PICGO_OPEN_FILE, OPEN_URL, CHANGE_LANGUAGE } from '#/events/constants'
|
||||
import {
|
||||
ipcRenderer
|
||||
} from 'electron'
|
||||
import { Component, Vue } from 'vue-property-decorator'
|
||||
import { T } from '~/universal/i18n'
|
||||
import { T, languageList } from '~/universal/i18n'
|
||||
// import db from '#/datastore'
|
||||
const releaseUrl = 'https://api.github.com/repos/Molunerfinn/PicGo/releases/latest'
|
||||
const releaseUrlBackup = 'https://cdn.jsdelivr.net/gh/Molunerfinn/PicGo@latest/package.json'
|
||||
@@ -383,9 +401,16 @@ export default class extends Vue {
|
||||
logLevel: ['all'],
|
||||
autoCopyUrl: true,
|
||||
checkBetaUpdate: true,
|
||||
useBuiltinClipboard: false
|
||||
useBuiltinClipboard: false,
|
||||
language: 'zh-CN'
|
||||
}
|
||||
|
||||
languageList = languageList.map(item => ({
|
||||
label: item,
|
||||
value: item
|
||||
}))
|
||||
|
||||
currentLanguage = 'zh-CN'
|
||||
picBed: IPicBedType[] = []
|
||||
logFileVisible = false
|
||||
keyBindingVisible = false
|
||||
@@ -459,7 +484,8 @@ export default class extends Vue {
|
||||
this.form.autoCopyUrl = settings.autoCopy === undefined ? true : settings.autoCopy
|
||||
this.form.checkBetaUpdate = settings.checkBetaUpdate === undefined ? true : settings.checkBetaUpdate
|
||||
this.form.useBuiltinClipboard = settings.useBuiltinClipboard === undefined ? false : settings.useBuiltinClipboard
|
||||
|
||||
this.form.language = settings.language ?? 'zh-CN'
|
||||
this.currentLanguage = settings.language ?? 'zh-CN'
|
||||
this.customLink.value = settings.customLink || '$url'
|
||||
this.shortKey.upload = settings.shortKey.upload
|
||||
this.proxy = picBed.proxy || ''
|
||||
@@ -725,6 +751,15 @@ export default class extends Vue {
|
||||
return false
|
||||
}
|
||||
|
||||
handleLanguageChange (val: string) {
|
||||
this.$i18n.setLanguage(val)
|
||||
this.forceUpdate()
|
||||
ipcRenderer.send(CHANGE_LANGUAGE, val)
|
||||
this.saveConfig({
|
||||
'settings.language': val
|
||||
})
|
||||
}
|
||||
|
||||
goConfigPage () {
|
||||
ipcRenderer.send(OPEN_URL, 'https://picgo.github.io/PicGo-Doc/zh/guide/config.html#picgo设置')
|
||||
}
|
||||
|
||||
10
src/renderer/utils/beforeOpen.ts
Normal file
10
src/renderer/utils/beforeOpen.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { i18n } from '~/universal/i18n'
|
||||
|
||||
export const handleURLParams = () => {
|
||||
const url = new URL(location.href)
|
||||
const search = new URLSearchParams(url.search)
|
||||
if (search.has('lang')) {
|
||||
const lang = search.get('lang') || 'zh-CN'
|
||||
i18n.setLanguage(lang)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
import { Component, Vue } from 'vue-property-decorator'
|
||||
import { ipcRenderer, IpcRendererEvent } from 'electron'
|
||||
import { PICGO_SAVE_CONFIG, PICGO_GET_CONFIG } from '#/events/constants'
|
||||
import { PICGO_SAVE_CONFIG, PICGO_GET_CONFIG, FORCE_UPDATE } from '#/events/constants'
|
||||
import { uuid } from 'uuidv4'
|
||||
@Component
|
||||
export default class extends Vue {
|
||||
created () {
|
||||
this.$bus.$on(FORCE_UPDATE, () => {
|
||||
this.$forceUpdate()
|
||||
})
|
||||
}
|
||||
|
||||
// support string key + value or object config
|
||||
saveConfig (config: IObj | string, value?: any) {
|
||||
if (typeof config === 'string') {
|
||||
@@ -27,4 +33,8 @@ export default class extends Vue {
|
||||
ipcRenderer.send(PICGO_GET_CONFIG, key, callbackId)
|
||||
})
|
||||
}
|
||||
|
||||
forceUpdate () {
|
||||
this.$bus.$emit(FORCE_UPDATE)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user