fix: page Configurations inutilisable en mode mobile BUG-071
This commit is contained in:
+13
-6
@@ -5,6 +5,7 @@
|
||||
* Static DOM: data-i18n="key" → textContent
|
||||
* data-i18n-placeholder="key" → placeholder
|
||||
* data-i18n-attr:title="key" → title attribute
|
||||
* data-i18n-attr="a:k1;b:k2" → several attributes (";"-separated)
|
||||
* data-i18n-html="key" → innerHTML (use sparingly)
|
||||
* Dynamic JS: import { t } from './i18n.js'; t('key', {param: 'val'})
|
||||
* Live reload: setLocale('en') updates every data-i18n element instantly.
|
||||
@@ -183,13 +184,19 @@ function _applyDOM() {
|
||||
el.innerHTML = t(key);
|
||||
});
|
||||
|
||||
// data-i18n-attr:TITLE → sets any attribute
|
||||
// data-i18n-attr:ATTR:key[;ATTR:key…] → sets any attribute(s).
|
||||
// Single-pair form (data-i18n-attr="title:key") is preserved; multiple
|
||||
// pairs are separated with ";" (BUG-071: the config TOC toggle needs both
|
||||
// title and aria-label translated).
|
||||
document.querySelectorAll('[data-i18n-attr]').forEach(function (el) {
|
||||
const raw = el.getAttribute('data-i18n-attr');
|
||||
const colon = raw.indexOf(':');
|
||||
if (colon === -1) return;
|
||||
const attr = raw.substring(0, colon);
|
||||
const key = raw.substring(colon + 1);
|
||||
el.setAttribute(attr, t(key));
|
||||
raw.split(';').forEach(function (pair) {
|
||||
const colon = pair.indexOf(':');
|
||||
if (colon === -1) return;
|
||||
const attr = pair.substring(0, colon).trim();
|
||||
const key = pair.substring(colon + 1).trim();
|
||||
if (!attr || !key) return;
|
||||
el.setAttribute(attr, t(key));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user