mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 20:57:13 -05:00
update tr store in +page.svelte
This commit is contained in:
parent
6f06f81f06
commit
179968d0dc
2 changed files with 5 additions and 10 deletions
|
|
@ -7,11 +7,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { PageProps } from "./$types";
|
import type { PageProps } from "./$types";
|
||||||
|
import * as _tr from "@generated/ftl-launcher";
|
||||||
import { setLang, windowReady, zoomWebview } from "@generated/backend-launcher";
|
import { setLang, windowReady, zoomWebview } from "@generated/backend-launcher";
|
||||||
import { getMirrors } from "@generated/backend-launcher";
|
import { getMirrors } from "@generated/backend-launcher";
|
||||||
import { ModuleName, setupI18n } from "@tslib/i18n";
|
import { ModuleName, setupI18n } from "@tslib/i18n";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import { currentLang, zoomFactor } from "./stores";
|
import { tr, zoomFactor } from "./stores";
|
||||||
import Start from "./Start.svelte";
|
import Start from "./Start.svelte";
|
||||||
|
|
||||||
const { data }: PageProps = $props();
|
const { data }: PageProps = $props();
|
||||||
|
|
@ -22,21 +23,17 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
let selectedLang = $state(data.userLocale);
|
let selectedLang = $state(data.userLocale);
|
||||||
|
|
||||||
async function onLangChange(lang: string) {
|
async function onLangChange(lang: string) {
|
||||||
// TODO: setLang could call setupI18n?
|
|
||||||
await setLang({ val: lang });
|
await setLang({ val: lang });
|
||||||
await setupI18n({ modules: [ModuleName.LAUNCHER] }, true);
|
await setupI18n({ modules: [ModuleName.LAUNCHER] }, true);
|
||||||
$currentLang = lang;
|
|
||||||
|
$tr = _tr;
|
||||||
|
mirrors = (await getMirrors({})).mirrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
onLangChange(selectedLang);
|
onLangChange(selectedLang);
|
||||||
});
|
});
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
$currentLang; // rerun on i18n reinit
|
|
||||||
getMirrors({}).then(({ mirrors: _mirrors }) => (mirrors = _mirrors));
|
|
||||||
});
|
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
zoomWebview({ scaleFactor: $zoomFactor });
|
zoomWebview({ scaleFactor: $zoomFactor });
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,4 @@ export const mirrorsStore = writable<GetMirrorsResponse_Pair[]>([]);
|
||||||
export const currentLang = writable("");
|
export const currentLang = writable("");
|
||||||
export const initialLang = writable("");
|
export const initialLang = writable("");
|
||||||
export const versionsStore = writable<GetVersionsResponse | undefined>(undefined);
|
export const versionsStore = writable<GetVersionsResponse | undefined>(undefined);
|
||||||
|
|
||||||
export const tr = writable(_tr);
|
export const tr = writable(_tr);
|
||||||
currentLang.subscribe(() => tr.set(_tr));
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue