Skip to content

Commit

Permalink
Merge branch 'pr/desktop/accessibility/declare-app-lang' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
personalizedrefrigerator committed Oct 23, 2024
2 parents 549934b + 8d4a946 commit 1b00c77
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/app-desktop/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,23 @@ class Application extends BaseApplication {
}
}

private updateLanguage() {
setLocale(Setting.value('locale'));
// The bridge runs within the main process, with its own instance of locale.js
// so it needs to be set too here.
bridge().setLocale(Setting.value('locale'));

const htmlContainer = document.querySelector('html');
// HTML expects the lang attribute to be in BCP47 format, with a dash rather than
// an underscore:
const htmlLang = Setting.value('locale').replace(/_/g, '-');
htmlContainer.setAttribute('lang', htmlLang);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
protected async generalMiddleware(store: any, next: any, action: any) {
if (action.type === 'SETTING_UPDATE_ONE' && action.key === 'locale' || action.type === 'SETTING_UPDATE_ALL') {
setLocale(Setting.value('locale'));
// The bridge runs within the main process, with its own instance of locale.js
// so it needs to be set too here.
bridge().setLocale(Setting.value('locale'));
this.updateLanguage();
}

if (action.type === 'SETTING_UPDATE_ONE' && action.key === 'showTrayIcon' || action.type === 'SETTING_UPDATE_ALL') {
Expand Down

0 comments on commit 1b00c77

Please sign in to comment.