Skip to content
Snippets Groups Projects
Commit 421d92f3 authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Fix broken language switch when moving in browser history (#59)

parent 36a9290f
No related branches found
No related tags found
No related merge requests found
Pipeline #50835 passed
...@@ -44,6 +44,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -44,6 +44,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
constructor() { constructor() {
super(); super();
this.lang = i18n.language; this.lang = i18n.language;
this.languages = [];
this.activeView = ''; this.activeView = '';
this.entryPointUrl = ''; this.entryPointUrl = '';
this.subtitle = ''; this.subtitle = '';
...@@ -270,8 +271,12 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -270,8 +271,12 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
* @param {string} lang * @param {string} lang
*/ */
updateLangIfChanged(lang) { updateLangIfChanged(lang) {
// if the language is switched to English then i18n.languages is ['en'], instead of ['en', 'de']
// so we are now only adding new ones to this.languages
this.languages = Array.from(new Set(this.languages.concat(i18n.languages)));
// in case the language is unknown, fall back to the default // in case the language is unknown, fall back to the default
if (!i18n.languages.includes(lang)) { if (!this.languages.includes(lang)) {
lang = this.lang; lang = this.lang;
} }
if (this.lang !== lang) { if (this.lang !== lang) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment