Skip to content

Commit

Permalink
Merge pull request #122 from maotoumao/dev
Browse files Browse the repository at this point in the history
修改默认语言
  • Loading branch information
maotoumao authored Jun 17, 2024
2 parents 6fa80b0 + 4fa5707 commit 62c1095
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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

0 comments on commit 62c1095

Please sign in to comment.