fix(web): i18n race condition in load function (#10693)

This commit is contained in:
Michel Heusschen 2024-06-29 18:29:56 +02:00 committed by GitHub
parent 24c1855899
commit 8f553ddb39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 74 additions and 89 deletions

13
web/src/lib/utils/i18n.ts Normal file
View file

@ -0,0 +1,13 @@
import { locale, t, waitLocale } from 'svelte-i18n';
import { get, type Unsubscriber } from 'svelte/store';
export async function getFormatter() {
let unsubscribe: Unsubscriber | undefined;
await new Promise((resolve) => {
unsubscribe = locale.subscribe((value) => value && resolve(value));
});
unsubscribe?.();
await waitLocale();
return get(t);
}