Skip to content

Commit

Permalink
fix: fallback to en-US when locale is not supported #177
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm committed Aug 30, 2024
1 parent 5cb0f57 commit c7538d6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,17 @@ async function detectLocaleAndSetAsDefault() {
}

let uiLocale = messenger.i18n.getUILanguage();
let selected = rwhI18n.i18n.lang[uiLocale] ?? 'en-US';
let selected = rwhI18n.i18n.lang[uiLocale];
rwhLogger.debug('uiLocale:', uiLocale, 'selected:', selected);
if (typeof selected === 'undefined') {
rwhLogger.info(`Currently does not have support for locale '${uiLocale}', fallback to 'en-US'`);
await rwhSettings.set('header.locale', 'en-US');
return;
}

let currentLocale = await rwhSettings.getHeaderLocale();
rwhLogger.debug('currentLocale:', currentLocale, 'uiLocale:', uiLocale, 'selected:', selected);
if (selected !== 'undefined' && currentLocale !== uiLocale) {
rwhLogger.debug('currentLocale:', currentLocale);
if (currentLocale !== uiLocale) {
await rwhSettings.set('header.locale', uiLocale);
}
}
Expand Down

0 comments on commit c7538d6

Please # to comment.