mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 02:31:45 +00:00
fix: if locale is not present, set to unspecified
This commit is contained in:
@ -556,11 +556,14 @@ app.on('activate', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const getDefaultLocale = (locale: string) =>
|
const getDefaultLocale = (locale: string) =>
|
||||||
Object.keys(languageResources).includes(locale) ? locale : 'en';
|
Object.keys(languageResources).includes(locale) ? locale : null;
|
||||||
|
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
if (!config.get('options.language')) {
|
if (!config.get('options.language')) {
|
||||||
config.set('options.language', getDefaultLocale(app.getLocale()));
|
const locale = getDefaultLocale(app.getLocale());
|
||||||
|
if (locale) {
|
||||||
|
config.set('options.language', locale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await loadI18n().then(async () => {
|
await loadI18n().then(async () => {
|
||||||
|
|||||||
@ -379,7 +379,7 @@ export const mainMenuTemplate = async (
|
|||||||
(lang): Electron.MenuItemConstructorOptions => ({
|
(lang): Electron.MenuItemConstructorOptions => ({
|
||||||
label: `${languageResources[lang].translation.language.name} (${languageResources[lang].translation.language['local-name']})`,
|
label: `${languageResources[lang].translation.language.name} (${languageResources[lang].translation.language['local-name']})`,
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: config.get('options.language') === lang,
|
checked: (config.get('options.language') ?? 'en') === lang,
|
||||||
click() {
|
click() {
|
||||||
config.setMenuOption('options.language', lang);
|
config.setMenuOption('options.language', lang);
|
||||||
refreshMenu(win);
|
refreshMenu(win);
|
||||||
|
|||||||
Reference in New Issue
Block a user