From 8f553ddb39ec9736f075e6d5fcb5c9e7671b8a83 Mon Sep 17 00:00:00 2001 From: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> Date: Sat, 29 Jun 2024 18:29:56 +0200 Subject: [PATCH] fix(web): i18n race condition in load function (#10693) --- web/src/lib/utils/i18n.ts | 13 +++++++++++++ web/src/routes/(user)/albums/+page.ts | 5 ++--- .../[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++--- web/src/routes/(user)/explore/+page.ts | 5 ++--- .../[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++--- .../map/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++--- .../[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++--- .../[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++--- web/src/routes/(user)/people/+page.ts | 5 ++--- .../[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++--- .../routes/(user)/photos/[[assetId=id]]/+page.ts | 5 ++--- web/src/routes/(user)/places/+page.ts | 5 ++--- .../[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++--- .../[key]/[[photos=photos]]/[[assetId=id]]/+page.ts | 6 +++--- web/src/routes/(user)/sharing/+page.ts | 5 ++--- web/src/routes/(user)/sharing/sharedlinks/+page.ts | 5 ++--- .../trash/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++--- web/src/routes/(user)/user-settings/+page.ts | 5 ++--- web/src/routes/(user)/utilities/+page.ts | 5 ++--- .../[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++--- web/src/routes/+page.ts | 5 ++--- web/src/routes/admin/jobs-status/+page.ts | 5 ++--- web/src/routes/admin/library-management/+page.ts | 5 ++--- web/src/routes/admin/repair/+page.ts | 5 ++--- web/src/routes/admin/server-status/+page.ts | 5 ++--- web/src/routes/admin/system-settings/+page.ts | 5 ++--- web/src/routes/admin/user-management/+page.ts | 5 ++--- web/src/routes/auth/change-password/+page.ts | 4 ++-- web/src/routes/auth/login/+page.ts | 5 ++--- web/src/routes/auth/onboarding/+page.ts | 5 ++--- web/src/routes/auth/register/+page.ts | 5 ++--- 31 files changed, 74 insertions(+), 89 deletions(-) create mode 100644 web/src/lib/utils/i18n.ts diff --git a/web/src/lib/utils/i18n.ts b/web/src/lib/utils/i18n.ts new file mode 100644 index 0000000000000..fae44549227b2 --- /dev/null +++ b/web/src/lib/utils/i18n.ts @@ -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); +} diff --git a/web/src/routes/(user)/albums/+page.ts b/web/src/routes/(user)/albums/+page.ts index 50f3696123224..e56d0f06b7804 100644 --- a/web/src/routes/(user)/albums/+page.ts +++ b/web/src/routes/(user)/albums/+page.ts @@ -1,14 +1,13 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAllAlbums } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate(); const sharedAlbums = await getAllAlbums({ shared: true }); const albums = await getAllAlbums({}); - const $t = get(t); + const $t = await getFormatter(); return { albums, diff --git a/web/src/routes/(user)/archive/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/archive/[[photos=photos]]/[[assetId=id]]/+page.ts index 1739cc7cd0789..c44ba64d5bd2c 100644 --- a/web/src/routes/(user)/archive/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/archive/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,13 +1,12 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAssetInfoFromParam } from '$lib/utils/navigation'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { await authenticate(); const asset = await getAssetInfoFromParam(params); - const $t = get(t); + const $t = await getFormatter(); return { asset, diff --git a/web/src/routes/(user)/explore/+page.ts b/web/src/routes/(user)/explore/+page.ts index 8651acfe8360d..84ec944efed62 100644 --- a/web/src/routes/(user)/explore/+page.ts +++ b/web/src/routes/(user)/explore/+page.ts @@ -1,13 +1,12 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAllPeople, getExploreData } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate(); const [items, response] = await Promise.all([getExploreData(), getAllPeople({ withHidden: false })]); - const $t = get(t); + const $t = await getFormatter(); return { items, diff --git a/web/src/routes/(user)/favorites/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/favorites/[[photos=photos]]/[[assetId=id]]/+page.ts index 85266fbed7ec3..be828b69dd523 100644 --- a/web/src/routes/(user)/favorites/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/favorites/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,13 +1,12 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAssetInfoFromParam } from '$lib/utils/navigation'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { await authenticate(); const asset = await getAssetInfoFromParam(params); - const $t = get(t); + const $t = await getFormatter(); return { asset, diff --git a/web/src/routes/(user)/map/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/map/[[photos=photos]]/[[assetId=id]]/+page.ts index b09a500f41218..490e1430e6a61 100644 --- a/web/src/routes/(user)/map/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/map/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,13 +1,12 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAssetInfoFromParam } from '$lib/utils/navigation'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { await authenticate(); const asset = await getAssetInfoFromParam(params); - const $t = get(t); + const $t = await getFormatter(); return { asset, diff --git a/web/src/routes/(user)/memory/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/memory/[[photos=photos]]/[[assetId=id]]/+page.ts index 1c127d25881e2..e323fca1826f7 100644 --- a/web/src/routes/(user)/memory/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/memory/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,13 +1,12 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAssetInfoFromParam } from '$lib/utils/navigation'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { const user = await authenticate(); const asset = await getAssetInfoFromParam(params); - const $t = get(t); + const $t = await getFormatter(); return { user, diff --git a/web/src/routes/(user)/partners/[userId]/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/partners/[userId]/[[photos=photos]]/[[assetId=id]]/+page.ts index 194fb53f7b574..1395a3e8d3ac3 100644 --- a/web/src/routes/(user)/partners/[userId]/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/partners/[userId]/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,8 +1,7 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAssetInfoFromParam } from '$lib/utils/navigation'; import { getUser } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { @@ -10,7 +9,7 @@ export const load = (async ({ params }) => { const partner = await getUser({ id: params.userId }); const asset = await getAssetInfoFromParam(params); - const $t = get(t); + const $t = await getFormatter(); return { asset, diff --git a/web/src/routes/(user)/people/+page.ts b/web/src/routes/(user)/people/+page.ts index 95dfef7646364..305ba31da6394 100644 --- a/web/src/routes/(user)/people/+page.ts +++ b/web/src/routes/(user)/people/+page.ts @@ -1,14 +1,13 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAllPeople } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate(); const people = await getAllPeople({ withHidden: true }); - const $t = get(t); + const $t = await getFormatter(); return { people, diff --git a/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.ts index fbb2e763aaa0a..88e223640f54e 100644 --- a/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,8 +1,7 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAssetInfoFromParam } from '$lib/utils/navigation'; import { getPerson, getPersonStatistics } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { @@ -13,7 +12,7 @@ export const load = (async ({ params }) => { getPersonStatistics({ id: params.personId }), getAssetInfoFromParam(params), ]); - const $t = get(t); + const $t = await getFormatter(); return { person, diff --git a/web/src/routes/(user)/photos/[[assetId=id]]/+page.ts b/web/src/routes/(user)/photos/[[assetId=id]]/+page.ts index 31373ef62138f..6e9384f853fb2 100644 --- a/web/src/routes/(user)/photos/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/photos/[[assetId=id]]/+page.ts @@ -1,13 +1,12 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAssetInfoFromParam } from '$lib/utils/navigation'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { await authenticate(); const asset = await getAssetInfoFromParam(params); - const $t = get(t); + const $t = await getFormatter(); return { asset, diff --git a/web/src/routes/(user)/places/+page.ts b/web/src/routes/(user)/places/+page.ts index 055a8dcae08db..a0c421ef3a767 100644 --- a/web/src/routes/(user)/places/+page.ts +++ b/web/src/routes/(user)/places/+page.ts @@ -1,13 +1,12 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAssetsByCity } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate(); const items = await getAssetsByCity(); - const $t = get(t); + const $t = await getFormatter(); return { items, diff --git a/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.ts index c282577c8d6eb..23871d8bdfd5d 100644 --- a/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,13 +1,12 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAssetInfoFromParam } from '$lib/utils/navigation'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { await authenticate(); const asset = await getAssetInfoFromParam(params); - const $t = get(t); + const $t = await getFormatter(); return { asset, diff --git a/web/src/routes/(user)/share/[key]/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/share/[key]/[[photos=photos]]/[[assetId=id]]/+page.ts index 06e9b2905e3ca..b19b18a8daaee 100644 --- a/web/src/routes/(user)/share/[key]/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/share/[key]/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,22 +1,21 @@ import { getAssetThumbnailUrl, setSharedLink } from '$lib/utils'; import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAssetInfoFromParam } from '$lib/utils/navigation'; import { getMySharedLink, isHttpError } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { const { key } = params; await authenticate({ public: true }); const asset = await getAssetInfoFromParam(params); - const $t = get(t); try { const sharedLink = await getMySharedLink({ key }); setSharedLink(sharedLink); const assetCount = sharedLink.assets.length; const assetId = sharedLink.album?.albumThumbnailAssetId || sharedLink.assets[0]?.id; + const $t = await getFormatter(); return { sharedLink, @@ -30,6 +29,7 @@ export const load = (async ({ params }) => { }; } catch (error) { if (isHttpError(error) && error.data.message === 'Invalid password') { + const $t = await getFormatter(); return { passwordRequired: true, sharedLinkKey: key, diff --git a/web/src/routes/(user)/sharing/+page.ts b/web/src/routes/(user)/sharing/+page.ts index fc2d90d95e360..be025d984605c 100644 --- a/web/src/routes/(user)/sharing/+page.ts +++ b/web/src/routes/(user)/sharing/+page.ts @@ -1,14 +1,13 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAllAlbums, getPartners } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate(); const sharedAlbums = await getAllAlbums({ shared: true }); const partners = await getPartners({ direction: 'shared-with' }); - const $t = get(t); + const $t = await getFormatter(); return { sharedAlbums, diff --git a/web/src/routes/(user)/sharing/sharedlinks/+page.ts b/web/src/routes/(user)/sharing/sharedlinks/+page.ts index 027276d538fd9..920e5bdba4792 100644 --- a/web/src/routes/(user)/sharing/sharedlinks/+page.ts +++ b/web/src/routes/(user)/sharing/sharedlinks/+page.ts @@ -1,11 +1,10 @@ import { authenticate } from '$lib/utils/auth'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; +import { getFormatter } from '$lib/utils/i18n'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate(); - const $t = get(t); + const $t = await getFormatter(); return { meta: { diff --git a/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.ts index fe363d224054f..926af322ca9f5 100644 --- a/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,13 +1,12 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAssetInfoFromParam } from '$lib/utils/navigation'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { await authenticate(); const asset = await getAssetInfoFromParam(params); - const $t = get(t); + const $t = await getFormatter(); return { asset, diff --git a/web/src/routes/(user)/user-settings/+page.ts b/web/src/routes/(user)/user-settings/+page.ts index cead4723f0d3b..15b8d8125c826 100644 --- a/web/src/routes/(user)/user-settings/+page.ts +++ b/web/src/routes/(user)/user-settings/+page.ts @@ -1,7 +1,6 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getApiKeys, getSessions } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { @@ -9,7 +8,7 @@ export const load = (async () => { const keys = await getApiKeys(); const sessions = await getSessions(); - const $t = get(t); + const $t = await getFormatter(); return { keys, diff --git a/web/src/routes/(user)/utilities/+page.ts b/web/src/routes/(user)/utilities/+page.ts index 23e3fc450df93..a0420a575b696 100644 --- a/web/src/routes/(user)/utilities/+page.ts +++ b/web/src/routes/(user)/utilities/+page.ts @@ -1,13 +1,12 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAssetInfoFromParam } from '$lib/utils/navigation'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { await authenticate(); const asset = await getAssetInfoFromParam(params); - const $t = get(t); + const $t = await getFormatter(); return { asset, diff --git a/web/src/routes/(user)/utilities/duplicates/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/utilities/duplicates/[[photos=photos]]/[[assetId=id]]/+page.ts index 9968b73d9073a..a7faaed3c3013 100644 --- a/web/src/routes/(user)/utilities/duplicates/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/utilities/duplicates/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,15 +1,14 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAssetInfoFromParam } from '$lib/utils/navigation'; import { getAssetDuplicates } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async ({ params }) => { await authenticate(); const asset = await getAssetInfoFromParam(params); const duplicates = await getAssetDuplicates(); - const $t = get(t); + const $t = await getFormatter(); return { asset, diff --git a/web/src/routes/+page.ts b/web/src/routes/+page.ts index ed10f6020bb8e..f9897336af75c 100644 --- a/web/src/routes/+page.ts +++ b/web/src/routes/+page.ts @@ -1,8 +1,7 @@ import { AppRoute } from '$lib/constants'; +import { getFormatter } from '$lib/utils/i18n'; import { getServerConfig } from '@immich/sdk'; import { redirect } from '@sveltejs/kit'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import { loadUser } from '../lib/utils/auth'; import type { PageLoad } from './$types'; @@ -21,7 +20,7 @@ export const load = (async () => { redirect(302, AppRoute.AUTH_LOGIN); } - const $t = get(t); + const $t = await getFormatter(); return { meta: { diff --git a/web/src/routes/admin/jobs-status/+page.ts b/web/src/routes/admin/jobs-status/+page.ts index 1d5a445cd58c8..8044b61861a9a 100644 --- a/web/src/routes/admin/jobs-status/+page.ts +++ b/web/src/routes/admin/jobs-status/+page.ts @@ -1,14 +1,13 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAllJobsStatus } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate({ admin: true }); const jobs = await getAllJobsStatus(); - const $t = get(t); + const $t = await getFormatter(); return { jobs, diff --git a/web/src/routes/admin/library-management/+page.ts b/web/src/routes/admin/library-management/+page.ts index b7d86666a2f0f..71bc835a6fb59 100644 --- a/web/src/routes/admin/library-management/+page.ts +++ b/web/src/routes/admin/library-management/+page.ts @@ -1,14 +1,13 @@ import { authenticate, requestServerInfo } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { searchUsersAdmin } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate({ admin: true }); await requestServerInfo(); const allUsers = await searchUsersAdmin({ withDeleted: false }); - const $t = get(t); + const $t = await getFormatter(); return { allUsers, diff --git a/web/src/routes/admin/repair/+page.ts b/web/src/routes/admin/repair/+page.ts index 119f4b1698a8d..9e52abb573494 100644 --- a/web/src/routes/admin/repair/+page.ts +++ b/web/src/routes/admin/repair/+page.ts @@ -1,13 +1,12 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getAuditFiles } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate({ admin: true }); const { orphans, extras } = await getAuditFiles(); - const $t = get(t); + const $t = await getFormatter(); return { orphans, diff --git a/web/src/routes/admin/server-status/+page.ts b/web/src/routes/admin/server-status/+page.ts index 427cdfe67f33f..39ce96ae411a3 100644 --- a/web/src/routes/admin/server-status/+page.ts +++ b/web/src/routes/admin/server-status/+page.ts @@ -1,13 +1,12 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getServerStatistics } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate({ admin: true }); const stats = await getServerStatistics(); - const $t = get(t); + const $t = await getFormatter(); return { stats, diff --git a/web/src/routes/admin/system-settings/+page.ts b/web/src/routes/admin/system-settings/+page.ts index 1274f2316f68e..555835e017d9a 100644 --- a/web/src/routes/admin/system-settings/+page.ts +++ b/web/src/routes/admin/system-settings/+page.ts @@ -1,13 +1,12 @@ import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { getConfig } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate({ admin: true }); const configs = await getConfig(); - const $t = get(t); + const $t = await getFormatter(); return { configs, diff --git a/web/src/routes/admin/user-management/+page.ts b/web/src/routes/admin/user-management/+page.ts index 5fdee6d455672..0a6af40c69546 100644 --- a/web/src/routes/admin/user-management/+page.ts +++ b/web/src/routes/admin/user-management/+page.ts @@ -1,14 +1,13 @@ import { authenticate, requestServerInfo } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { searchUsersAdmin } from '@immich/sdk'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate({ admin: true }); await requestServerInfo(); const allUsers = await searchUsersAdmin({ withDeleted: true }); - const $t = get(t); + const $t = await getFormatter(); return { allUsers, diff --git a/web/src/routes/auth/change-password/+page.ts b/web/src/routes/auth/change-password/+page.ts index 0e961d253cb50..19abb2e832e5c 100644 --- a/web/src/routes/auth/change-password/+page.ts +++ b/web/src/routes/auth/change-password/+page.ts @@ -1,8 +1,8 @@ import { AppRoute } from '$lib/constants'; import { user } from '$lib/stores/user.store'; import { authenticate } from '$lib/utils/auth'; +import { getFormatter } from '$lib/utils/i18n'; import { redirect } from '@sveltejs/kit'; -import { t } from 'svelte-i18n'; import { get } from 'svelte/store'; import type { PageLoad } from './$types'; @@ -12,7 +12,7 @@ export const load = (async () => { redirect(302, AppRoute.PHOTOS); } - const $t = get(t); + const $t = await getFormatter(); return { meta: { diff --git a/web/src/routes/auth/login/+page.ts b/web/src/routes/auth/login/+page.ts index 397b945661b35..427287c8eafb9 100644 --- a/web/src/routes/auth/login/+page.ts +++ b/web/src/routes/auth/login/+page.ts @@ -1,8 +1,7 @@ import { AppRoute } from '$lib/constants'; +import { getFormatter } from '$lib/utils/i18n'; import { defaults, getServerConfig } from '@immich/sdk'; import { redirect } from '@sveltejs/kit'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async ({ fetch }) => { @@ -13,7 +12,7 @@ export const load = (async ({ fetch }) => { redirect(302, AppRoute.AUTH_REGISTER); } - const $t = get(t); + const $t = await getFormatter(); return { meta: { title: $t('login'), diff --git a/web/src/routes/auth/onboarding/+page.ts b/web/src/routes/auth/onboarding/+page.ts index c578acc2e7e09..7bd307a3ee9ef 100644 --- a/web/src/routes/auth/onboarding/+page.ts +++ b/web/src/routes/auth/onboarding/+page.ts @@ -1,14 +1,13 @@ import { loadConfig } from '$lib/stores/server-config.store'; import { authenticate } from '$lib/utils/auth'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; +import { getFormatter } from '$lib/utils/i18n'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate({ admin: true }); await loadConfig(); - const $t = get(t); + const $t = await getFormatter(); return { meta: { diff --git a/web/src/routes/auth/register/+page.ts b/web/src/routes/auth/register/+page.ts index 9ecf1fda967d5..00574043c1381 100644 --- a/web/src/routes/auth/register/+page.ts +++ b/web/src/routes/auth/register/+page.ts @@ -1,8 +1,7 @@ import { AppRoute } from '$lib/constants'; +import { getFormatter } from '$lib/utils/i18n'; import { getServerConfig } from '@immich/sdk'; import { redirect } from '@sveltejs/kit'; -import { t } from 'svelte-i18n'; -import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { @@ -12,7 +11,7 @@ export const load = (async () => { redirect(302, AppRoute.AUTH_LOGIN); } - const $t = get(t); + const $t = await getFormatter(); return { meta: {