diff --git a/src/main/index.js b/src/main/index.js index 898f53258916f..23b561cee10b4 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -720,7 +720,8 @@ function runApp() { }) ipcMain.handle(IpcChannels.GET_SYSTEM_LOCALE, () => { - return app.getLocale() + // we should switch to getPreferredSystemLanguages at some point and iterate through until we find a supported locale + return app.getSystemLocale() }) ipcMain.handle(IpcChannels.GET_USER_DATA_PATH, () => { diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index 12847e3df888c..9dd98a0a44e8d 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -316,18 +316,20 @@ const stateWithSideEffects = { let targetLocale = value if (value === 'system') { const systemLocaleName = (await getSystemLocale()).replace('-', '_') // ex: en_US - const systemLocaleLang = systemLocaleName.split('_')[0] // ex: en - const targetLocaleOptions = allLocales.filter((locale) => { // filter out other languages + const systemLocaleSplit = systemLocaleName.split('_') // ex: en + const targetLocaleOptions = allLocales.filter((locale) => { + // filter out other languages const localeLang = locale.replace('-', '_').split('_')[0] - return localeLang.includes(systemLocaleLang) + return localeLang.includes(systemLocaleSplit[0]) }).sort((a, b) => { const aLocaleName = a.replace('-', '_') const bLocaleName = b.replace('-', '_') const aLocale = aLocaleName.split('_') // ex: [en, US] const bLocale = bLocaleName.split('_') - if (aLocale.includes(systemLocaleName)) { // country & language match, prefer a + + if (aLocaleName === systemLocaleName) { // country & language match, prefer a return -1 - } else if (bLocale.includes(systemLocaleName)) { // country & language match, prefer b + } else if (bLocaleName === systemLocaleName) { // country & language match, prefer b return 1 } else if (aLocale.length === 1) { // no country code for a, prefer a return -1 @@ -337,12 +339,11 @@ const stateWithSideEffects = { return aLocaleName.localeCompare(bLocaleName) } }) + if (targetLocaleOptions.length > 0) { targetLocale = targetLocaleOptions[0] - } - - // Go back to default value if locale is unavailable - if (!targetLocale) { + } else { + // Go back to default value if locale is unavailable targetLocale = defaultLocale // Translating this string isn't necessary // because the user will always see it in the default locale diff --git a/static/locales/pt-PT.yaml b/static/locales/pt-PT.yaml index db16a516e4bab..276c3c1a06061 100644 --- a/static/locales/pt-PT.yaml +++ b/static/locales/pt-PT.yaml @@ -1,5 +1,5 @@ # Put the name of your locale in the same language -Locale Name: Português +Locale Name: Português (PT) FreeTube: FreeTube # Currently on Subscriptions, Playlists, and History 'This part of the app is not ready yet. Come back later when progress has been made.': >-