Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(i18n): guard the data-i18n-html loop against clobbering a live display name too

nirholas5bdcb7e36631
diff --git a/src/i18n.js b/src/i18n.js
index 9a8df20bb..d38320298 100644
--- a/src/i18n.js
+++ b/src/i18n.js
@@ -93,7 +93,14 @@ export function applyCatalog(root, t) {
});
root.querySelectorAll?.('[data-i18n-html]').forEach((el) => {
const v = t(el.getAttribute('data-i18n-html'));
- if (v != null) el.innerHTML = v;
+ if (v == null) return;
+ // Same nav-auth ownership rule as the textContent loop above: never let a
+ // translated markup value overwrite a live display name.
+ if (el.hasAttribute('data-auth-name')) {
+ el.dataset.authNameOriginal = v;
+ if (el.dataset.authNamed === '1') return;
+ }
+ el.innerHTML = v;
});
root.querySelectorAll?.('[data-i18n-attr]').forEach((el) => {
for (const pair of el.getAttribute('data-i18n-attr').split(';')) {
diff --git a/tests/i18n-nav-auth-cooperation.test.js b/tests/i18n-nav-auth-cooperation.test.js
index 6ad977d05..02cc4db80 100644
--- a/tests/i18n-nav-auth-cooperation.test.js
+++ b/tests/i18n-nav-auth-cooperation.test.js
@@ -62,6 +62,17 @@ describe('nav-auth ⇄ i18n cooperation on a shared element', () => {
expect(el.textContent).toBe('Ada');
});
+ it('the data-i18n-html loop also refuses to clobber a live name', () => {
+ document.body.innerHTML =
+ '<a class="console" data-auth-name data-i18n-html="nav.console">Dashboard →</a>';
+ const el = document.querySelector('.console');
+ const esHtml = (key) => (key === 'nav.console' ? '<span>Panel</span> →' : key);
+ applyAuthState(document, true, 'Marie Curie');
+ applyCatalog(document, esHtml);
+ expect(el.textContent).toBe('Marie Curie');
+ expect(el.querySelector('span')).toBeNull(); // markup never painted over the name
+ });
+
it('a runtime locale switch keeps the name and refreshes the fallback', () => {
const el = pill();
applyAuthState(document, true, 'Grace');