fix(electrobun): remove i18n cycle — move lang/dir sync into setLocale()

This commit is contained in:
Hibryda 2026-03-23 21:35:47 +01:00
parent 805d1e533d
commit 85f55c19a6
2 changed files with 8 additions and 5 deletions

View file

@ -161,11 +161,7 @@
};
});
// ── i18n: keep <html> lang and dir in sync ──────────────────
$effect(() => {
document.documentElement.lang = getLocale();
document.documentElement.dir = getDir();
});
// ── i18n: lang/dir sync is handled inside setLocale() — no $effect needed ──
// ── Init ────────────────────────────────────────────────────
onMount(() => {

View file

@ -86,6 +86,13 @@ export async function setLocale(tag: string): Promise<void> {
_intl = createIntl({ locale: tag, messages: _messages }, cache);
_v++;
// Sync <html> lang and dir attributes
if (typeof document !== 'undefined') {
document.documentElement.lang = tag;
const meta = AVAILABLE_LOCALES.find(l => l.tag === tag);
document.documentElement.dir = meta?.dir ?? 'ltr';
}
// Persist preference
try {
await appRpc?.request['settings.set']({ key: 'locale', value: tag });