fix(electrobun): remove i18n cycle — move lang/dir sync into setLocale()
This commit is contained in:
parent
805d1e533d
commit
85f55c19a6
2 changed files with 8 additions and 5 deletions
|
|
@ -161,11 +161,7 @@
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// ── i18n: keep <html> lang and dir in sync ──────────────────
|
// ── i18n: lang/dir sync is handled inside setLocale() — no $effect needed ──
|
||||||
$effect(() => {
|
|
||||||
document.documentElement.lang = getLocale();
|
|
||||||
document.documentElement.dir = getDir();
|
|
||||||
});
|
|
||||||
|
|
||||||
// ── Init ────────────────────────────────────────────────────
|
// ── Init ────────────────────────────────────────────────────
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,13 @@ export async function setLocale(tag: string): Promise<void> {
|
||||||
_intl = createIntl({ locale: tag, messages: _messages }, cache);
|
_intl = createIntl({ locale: tag, messages: _messages }, cache);
|
||||||
_v++;
|
_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
|
// Persist preference
|
||||||
try {
|
try {
|
||||||
await appRpc?.request['settings.set']({ key: 'locale', value: tag });
|
await appRpc?.request['settings.set']({ key: 'locale', value: tag });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue