mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
🎨 改进桌面端初始化时使用的外观语言 Fix https://github.com/siyuan-note/siyuan/issues/6803
This commit is contained in:
parent
e11886923c
commit
0ac9b7499a
2 changed files with 25 additions and 12 deletions
|
|
@ -205,10 +205,11 @@
|
||||||
<div class="fn__space"></div>
|
<div class="fn__space"></div>
|
||||||
<div class="fn__flex-1"></div>
|
<div class="fn__flex-1"></div>
|
||||||
<select class="b3-select lang">
|
<select class="b3-select lang">
|
||||||
<option value="en-US">English</option>
|
<option value="en_US">English</option>
|
||||||
<option value="fr-FR">Français</option>
|
<option value="es_ES">Español</option>
|
||||||
<option value="zh-CN">简体中文</option>
|
<option value="fr_FR">Français</option>
|
||||||
<option value="zh-CHT">繁體中文</option>
|
<option value="zh_CN">简体中文</option>
|
||||||
|
<option value="zh_CHT">繁體中文</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label class="b3-label">
|
<label class="b3-label">
|
||||||
|
|
@ -247,10 +248,11 @@
|
||||||
<div class="fn__space"></div>
|
<div class="fn__space"></div>
|
||||||
<div class="fn__flex-1"></div>
|
<div class="fn__flex-1"></div>
|
||||||
<select class="b3-select lang">
|
<select class="b3-select lang">
|
||||||
<option value="en-US">English</option>
|
<option value="en_US">English</option>
|
||||||
<option value="fr-FR">Français</option>
|
<option value="es_ES">Español</option>
|
||||||
<option value="zh-CN">简体中文</option>
|
<option value="fr_FR">Français</option>
|
||||||
<option value="zh-CHT">繁體中文</option>
|
<option value="zh_CN">简体中文</option>
|
||||||
|
<option value="zh_CHT">繁體中文</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label class="b3-label">
|
<label class="b3-label">
|
||||||
|
|
@ -300,7 +302,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const setLang = (lang) => {
|
const setLang = (lang) => {
|
||||||
if (lang === 'zh-CN') {
|
if (lang === 'zh_CN') {
|
||||||
document.title = `思源笔记 v${getSearch('v')}`
|
document.title = `思源笔记 v${getSearch('v')}`
|
||||||
document.getElementById('zhCN').classList.remove('fn__none')
|
document.getElementById('zhCN').classList.remove('fn__none')
|
||||||
document.getElementById('enUS').classList.add('fn__none')
|
document.getElementById('enUS').classList.add('fn__none')
|
||||||
|
|
@ -311,7 +313,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setLang(navigator.language)
|
let lang = decodeURIComponent(getSearch('lang'));
|
||||||
|
setLang(lang)
|
||||||
|
|
||||||
document.querySelectorAll('.version').forEach(item => {
|
document.querySelectorAll('.version').forEach(item => {
|
||||||
item.textContent = `🔖 v${getSearch('v')}`
|
item.textContent = `🔖 v${getSearch('v')}`
|
||||||
|
|
@ -322,7 +325,7 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
document.querySelectorAll('.lang').forEach(item => {
|
document.querySelectorAll('.lang').forEach(item => {
|
||||||
item.value = navigator.language
|
item.value = lang
|
||||||
item.addEventListener('change', () => {
|
item.addEventListener('change', () => {
|
||||||
document.querySelectorAll('.lang').forEach(item1 => {
|
document.querySelectorAll('.lang').forEach(item1 => {
|
||||||
item1.value = item.value
|
item1.value = item.value
|
||||||
|
|
@ -355,7 +358,7 @@
|
||||||
if (!fs.existsSync(initPath)) {
|
if (!fs.existsSync(initPath)) {
|
||||||
fs.mkdirSync(initPath, {mode: 0o755, recursive: true})
|
fs.mkdirSync(initPath, {mode: 0o755, recursive: true})
|
||||||
}
|
}
|
||||||
const lang = document.querySelector('.lang').value.replaceAll('-', '_')
|
const lang = document.querySelector('.lang').value
|
||||||
ipcRenderer.send('siyuan-first-init', `${initPath}-${lang}`)
|
ipcRenderer.send('siyuan-first-init', `${initPath}-${lang}`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -710,9 +710,19 @@ app.whenReady().then(() => {
|
||||||
if (isDevEnv) {
|
if (isDevEnv) {
|
||||||
initHTMLPath = path.join(appDir, 'electron', 'init.html')
|
initHTMLPath = path.join(appDir, 'electron', 'init.html')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let languages = app.getPreferredSystemLanguages();
|
||||||
|
let language = "en_US";
|
||||||
|
if (languages && 0 < languages.length) {
|
||||||
|
if ("zh-Hans-CN" === languages[0]) {
|
||||||
|
language = "zh_CN"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
firstOpenWindow.loadFile(
|
firstOpenWindow.loadFile(
|
||||||
initHTMLPath, {
|
initHTMLPath, {
|
||||||
query: {
|
query: {
|
||||||
|
lang: language,
|
||||||
home: app.getPath('home'),
|
home: app.getPath('home'),
|
||||||
v: appVer,
|
v: appVer,
|
||||||
icon: path.join(appDir, 'stage', 'icon-large.png'),
|
icon: path.join(appDir, 'stage', 'icon-large.png'),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue