From 5259d007c9e517ff1eab0e89ba99fd2fc9b2acf7 Mon Sep 17 00:00:00 2001 From: Dobrovolskyi Bohdan <14891109+dobrovolsky@users.noreply.github.com> Date: Tue, 21 Jul 2026 13:04:42 +0300 Subject: [PATCH] Fix Locale subscription (#369) --- website/src/lib/i18n.svelte.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/website/src/lib/i18n.svelte.ts b/website/src/lib/i18n.svelte.ts index 433df3c19..f1aee7ad1 100644 --- a/website/src/lib/i18n.svelte.ts +++ b/website/src/lib/i18n.svelte.ts @@ -1,3 +1,5 @@ +import { writable } from 'svelte/store'; + type Dictionary = { [key: string]: string | Dictionary; }; @@ -10,6 +12,7 @@ function getDateFormatter(locale: string) { } class Locale { + private _store = writable(this); private _lang = $state(''); private _isLoadingInitial = $state(true); private _isLoading = $state(true); @@ -38,6 +41,7 @@ class Locale { } import(`../locales/${this._lang}.json`).then((module) => { this.dictionary = module.default; + this._store.set(this); if (this._isLoadingInitial) { this._isLoadingInitial = false; } @@ -67,6 +71,10 @@ class Locale { public get df() { return this._df; } + + public subscribe(run: (value: Locale) => void, invalidate?: (value?: Locale) => void) { + return this._store.subscribe(run, invalidate); + } } export const i18n = new Locale();