Merge main into PR-D
This commit is contained in:
@@ -2517,10 +2517,23 @@ export function setLang(lang: Lang) {
|
||||
localStorage.setItem(STORAGE_KEY, lang);
|
||||
document.documentElement.lang = lang;
|
||||
applyTranslations();
|
||||
applyLangToInputs();
|
||||
updateToggle();
|
||||
for (const cb of changeCallbacks) cb();
|
||||
}
|
||||
|
||||
// Native <input type="date|time|datetime-local"> follows the browser locale
|
||||
// for display formatting unless `lang` is set on the element itself — the
|
||||
// `lang` attribute on <html> is not enough in Chrome/Safari. Stamp the
|
||||
// current locale on every such input so DE users see dd.mm.yyyy and 24h.
|
||||
function applyLangToInputs() {
|
||||
document.querySelectorAll<HTMLInputElement>(
|
||||
'input[type="date"], input[type="time"], input[type="datetime-local"]',
|
||||
).forEach((el) => {
|
||||
el.lang = currentLang;
|
||||
});
|
||||
}
|
||||
|
||||
function applyTranslations() {
|
||||
// When a key is missing from every locale, preserve whatever static text
|
||||
// the HTML was authored with — never overwrite with the raw key string.
|
||||
@@ -2577,5 +2590,6 @@ export function initI18n() {
|
||||
});
|
||||
|
||||
applyTranslations();
|
||||
applyLangToInputs();
|
||||
updateToggle();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user