Merge branch 'translate' into next

This commit is contained in:
schlagmichdoch 2023-12-12 19:10:12 +01:00
commit 037dab1e46
22 changed files with 814 additions and 381 deletions

View file

@ -1,7 +1,7 @@
class Localization {
constructor() {
Localization.defaultLocale = "en";
Localization.supportedLocales = ["ar", "de", "en", "es", "fr", "id", "it", "ja", "nb", "nl", "ro", "ru", "tr", "zh-CN"];
Localization.supportedLocales = ["ar", "de", "en", "es", "fr", "id", "it", "ja", "nb", "nl", "ro", "ru", "tr", "zh-CN","pt-BR"];
Localization.supportedLocalesRtl = ["ar"];
Localization.translations = {};

View file

@ -763,7 +763,7 @@ class LanguageSelectDialog extends Dialog {
this.$languageSelectBtn = $('language-selector');
this.$languageSelectBtn.addEventListener('click', _ => this.show());
this.$languageButtons = this.$el.querySelectorAll(".language-buttons button");
this.$languageButtons = this.$el.querySelectorAll(".language-buttons .btn");
this.$languageButtons.forEach($btn => {
$btn.addEventListener("click", e => this.selectLanguage(e));
})
@ -779,22 +779,22 @@ class LanguageSelectDialog extends Dialog {
}
show() {
if (Localization.isSystemLocale()) {
this.$languageButtons[0].focus();
}
else {
let locale = Localization.getLocale();
for (let i=0; i<this.$languageButtons.length; i++) {
const $btn = this.$languageButtons[i];
if ($btn.value === locale) {
$btn.focus();
break;
}
}
}
let locale = Localization.getLocale();
this.currentLanguageBtn = Localization.isSystemLocale()
? this.$languageButtons[0]
: this.$el.querySelector(`.btn[value="${locale}"]`);
this.currentLanguageBtn.classList.add("current");
super.show();
}
hide() {
this.currentLanguageBtn.classList.remove("current");
super.hide();
}
selectLanguage(e) {
e.preventDefault()
let languageCode = e.target.value;