Internationalization
This commit is contained in:
+20
-20
@@ -5,15 +5,15 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
|
||||
|
||||
const DROPDOWN_ANIMATION_MS = 180;
|
||||
const pageTitles = Object.freeze({
|
||||
privacy: 'Datenschutzerklärung',
|
||||
imprint: 'Impressum',
|
||||
technology: 'Cookies und Technik'
|
||||
get privacy() { return ns.I18n.t("legal-ui.datenschutzerklarung"); },
|
||||
get imprint() { return ns.I18n.t("legal-ui.impressum"); },
|
||||
get technology() { return ns.I18n.t("legal-ui.speichern.und.berechtigungen"); }
|
||||
});
|
||||
const menuEntries = Object.freeze([
|
||||
['privacy', 'Datenschutzerklärung'],
|
||||
['imprint', 'Impressum'],
|
||||
['technology', 'Cookies und verwendete JavaScripts']
|
||||
]);
|
||||
function menuEntries() { return [
|
||||
['privacy', ns.I18n.t("legal-ui.datenschutzerklarung")],
|
||||
['imprint', ns.I18n.t("legal-ui.impressum")],
|
||||
['technology', ns.I18n.t("legal-ui.speichern.und.berechtigungen")]
|
||||
]; }
|
||||
const selectors = Object.freeze({
|
||||
content: '.info-dialog-content',
|
||||
cookieToggle: '.cookie-toggle',
|
||||
@@ -159,8 +159,8 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
|
||||
id: 'info-button',
|
||||
className: 'info-button',
|
||||
type: 'button',
|
||||
'aria-label': 'Informationsmenü öffnen',
|
||||
title: 'Informationen'
|
||||
'aria-label': ns.I18n.t("legal-ui.hilfe.und.informationen.offnen"),
|
||||
title: ns.I18n.t("legal-ui.informationen")
|
||||
});
|
||||
append(infoButton, createElement('span', { 'aria-hidden': 'true' }, 'i'));
|
||||
append(control, infoButton);
|
||||
@@ -173,7 +173,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
|
||||
const dropdown = createElement('nav', {
|
||||
id: 'info-dropdown',
|
||||
className: 'info-dropdown',
|
||||
'aria-label': 'Rechtliche und technische Informationen'
|
||||
'aria-label': ns.I18n.t("legal-ui.rechtliche.und.technische.informationen")
|
||||
});
|
||||
append(control, dropdown);
|
||||
return dropdown;
|
||||
@@ -191,7 +191,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
|
||||
|
||||
function setInfoButtonLabel(infoButton) {
|
||||
if (typeof infoButton.getAttribute === 'function' && infoButton.getAttribute('aria-label')) return;
|
||||
setAttribute(infoButton, 'aria-label', 'Informationsmenü öffnen');
|
||||
setAttribute(infoButton, 'aria-label', ns.I18n.t("legal-ui.hilfe.und.informationen.offnen"));
|
||||
}
|
||||
|
||||
function ensureInfoButtonIcon(infoButton) {
|
||||
@@ -201,9 +201,9 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
|
||||
|
||||
function configureDropdown(dropdown) {
|
||||
if (!dropdown) return;
|
||||
setAttribute(dropdown, 'aria-label', 'Rechtliche und technische Informationen');
|
||||
setAttribute(dropdown, 'aria-label', ns.I18n.t("legal-ui.rechtliche.und.technische.informationen"));
|
||||
setHidden(dropdown, true);
|
||||
menuEntries.forEach(([target, label]) => ensureMenuButton(dropdown, target, label));
|
||||
menuEntries().forEach(([target, label]) => ensureMenuButton(dropdown, target, label));
|
||||
}
|
||||
|
||||
function ensureMenuButton(dropdown, target, label) {
|
||||
@@ -277,7 +277,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
|
||||
|
||||
function configureBackButton(backButton) {
|
||||
setAttribute(backButton, 'type', 'button');
|
||||
setAttribute(backButton, 'aria-label', 'Zurück zum Informationsmenü');
|
||||
setAttribute(backButton, 'aria-label', ns.I18n.t("legal-ui.zuruck.zum.informationsmenu"));
|
||||
setHidden(backButton, true);
|
||||
return backButton;
|
||||
}
|
||||
@@ -293,8 +293,8 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
|
||||
const closeButton = createElement('button', {
|
||||
id: 'info-close',
|
||||
type: 'button',
|
||||
'aria-label': 'Informationsfenster schließen',
|
||||
title: 'Schließen'
|
||||
'aria-label': ns.I18n.t("legal-ui.informationsfenster.schliessen"),
|
||||
title: ns.I18n.t("legal-ui.schliessen")
|
||||
}, '×');
|
||||
append(header, closeButton);
|
||||
return configureCloseButton(closeButton);
|
||||
@@ -302,7 +302,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
|
||||
|
||||
function configureCloseButton(closeButton) {
|
||||
setAttribute(closeButton, 'type', 'button');
|
||||
setAttribute(closeButton, 'aria-label', 'Informationsfenster schließen');
|
||||
setAttribute(closeButton, 'aria-label', ns.I18n.t("legal-ui.informationsfenster.schliessen"));
|
||||
if (closeButton && !String(closeButton.textContent ?? '').trim()) closeButton.textContent = '×';
|
||||
return closeButton;
|
||||
}
|
||||
@@ -335,7 +335,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
|
||||
|
||||
function createFallbackPage(content, name) {
|
||||
const page = createElement('article', { className: 'info-page', dataset: { infoPage: name } });
|
||||
append(page, createElement('p', {}, `${pageTitles[name]} ist noch nicht hinterlegt.`));
|
||||
append(page, createElement('p', {}, ns.I18n.t("info.missing", { value1: pageTitles[name] })));
|
||||
append(content, page);
|
||||
return page;
|
||||
}
|
||||
@@ -436,7 +436,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
|
||||
}
|
||||
|
||||
function updateDialogTitle(pageName) {
|
||||
if (elements?.title) elements.title.textContent = pageTitles[pageName] ?? 'Informationen';
|
||||
if (elements?.title) elements.title.textContent = pageTitles[pageName] ?? ns.I18n.t("legal-ui.informationen");
|
||||
}
|
||||
|
||||
function focusSafely(element) {
|
||||
|
||||
Reference in New Issue
Block a user