Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

修改默认语言 #122

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion res/lang/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
"play_lower_quality_version": "播放更低音质",
"play_higher_quality_version": "播放更高音质",
"when_play_error": "播放失败时",
"pause": "暂停",
"pause": "暂停播放",
"skip_to_next": "自动播放下一首",
"double_click_music_list": "双击音乐列表时",
"add_music_to_playlist": "将目标单曲添加到播放队列",
Expand Down
13 changes: 11 additions & 2 deletions src/shared/i18n/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,18 @@ export async function setupI18n(options?: ISetupI18nOptions) {
if (defaultLang && !allLangs.includes(defaultLang)) {
defaultLang = undefined;
}

if (!defaultLang) {
defaultLang =
app.getLocale() || allLangs.includes("en-US") ? "en-US" : allLangs[0];
const appLocale = app.getLocale();
if (allLangs.includes(appLocale)) {
defaultLang = appLocale;
} else if (appLocale.includes("zh") && allLangs.includes("zh-CN")) {
defaultLang = "zh-CN";
} else if (allLangs.includes("en-US")) {
defaultLang = "en-US";
} else {
defaultLang = allLangs[0];
}
}

const langContent = await readLangContent(defaultLang);
Expand Down
Loading