From 212ba35aef689f7a6f3d786d85df77ff47244082 Mon Sep 17 00:00:00 2001 From: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:23:52 +0200 Subject: [PATCH] chore(web): translations in page load functions (#10260) --- web/src/lib/i18n/en.json | 4 ++++ web/src/routes/(user)/albums/+page.ts | 5 ++++- .../archive/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++++- web/src/routes/(user)/explore/+page.ts | 5 ++++- .../favorites/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++++- .../(user)/map/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++++- .../memory/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++++- .../[userId]/[[photos=photos]]/[[assetId=id]]/+page.ts | 6 +++++- web/src/routes/(user)/people/+page.ts | 6 +++++- .../[personId]/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++++- web/src/routes/(user)/photos/[[assetId=id]]/+page.ts | 6 +++++- web/src/routes/(user)/places/+page.ts | 5 ++++- .../search/[[photos=photos]]/[[assetId=id]]/+page.ts | 6 +++++- .../[key]/[[photos=photos]]/[[assetId=id]]/+page.ts | 9 ++++++--- web/src/routes/(user)/sharing/+page.ts | 5 ++++- web/src/routes/(user)/sharing/sharedlinks/+page.ts | 6 +++++- .../trash/[[photos=photos]]/[[assetId=id]]/+page.ts | 6 +++++- web/src/routes/(user)/utilities/+page.ts | 5 ++++- .../[[photos=photos]]/[[assetId=id]]/+page.ts | 5 ++++- web/src/routes/+page.ts | 8 ++++++-- 20 files changed, 90 insertions(+), 22 deletions(-) diff --git a/web/src/lib/i18n/en.json b/web/src/lib/i18n/en.json index 0cb9c122ed..df69fa623c 100644 --- a/web/src/lib/i18n/en.json +++ b/web/src/lib/i18n/en.json @@ -410,6 +410,7 @@ "done": "Done", "download": "Download", "downloading": "Downloading", + "duplicates": "Duplicates", "duration": "Duration", "durations": { "days": "{days, plural, one {day} other {{days, number} days}}", @@ -551,6 +552,7 @@ "hour": "Hour", "image": "Image", "immich_logo": "Immich Logo", + "immich_web_interface": "Immich Web Interface", "import_from_json": "Import from JSON", "import_path": "Import path", "in_archive": "In archive", @@ -793,6 +795,7 @@ "shared_by_you": "Shared by you", "shared_from_partner": "Photos from {partner}", "shared_links": "Shared links", + "shared_photos_and_videos_count": "{assetCount} shared photos & videos.", "shared_with_partner": "Shared with {partner}", "sharing": "Sharing", "sharing_sidebar_description": "Display a link to Sharing in the sidebar", @@ -896,6 +899,7 @@ "viewer": "Viewer", "waiting": "Waiting", "week": "Week", + "welcome": "Welcome", "welcome_to_immich": "Welcome to immich", "year": "Year", "yes": "Yes", diff --git a/web/src/routes/(user)/albums/+page.ts b/web/src/routes/(user)/albums/+page.ts index a76231485d..50f3696123 100644 --- a/web/src/routes/(user)/albums/+page.ts +++ b/web/src/routes/(user)/albums/+page.ts @@ -1,17 +1,20 @@ import { authenticate } from '$lib/utils/auth'; 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); return { albums, sharedAlbums, meta: { - title: 'Albums', + title: $t('albums'), }, }; }) satisfies PageLoad; 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 0c608506c2..1739cc7cd0 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,15 +1,18 @@ import { authenticate } from '$lib/utils/auth'; 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); return { asset, meta: { - title: 'Archive', + title: $t('archive'), }, }; }) satisfies PageLoad; diff --git a/web/src/routes/(user)/explore/+page.ts b/web/src/routes/(user)/explore/+page.ts index 4894714a24..8651acfe83 100644 --- a/web/src/routes/(user)/explore/+page.ts +++ b/web/src/routes/(user)/explore/+page.ts @@ -1,16 +1,19 @@ import { authenticate } from '$lib/utils/auth'; 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); return { items, response, meta: { - title: 'Explore', + title: $t('explore'), }, }; }) satisfies PageLoad; 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 f11e352bd9..85266fbed7 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,15 +1,18 @@ import { authenticate } from '$lib/utils/auth'; 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); return { asset, meta: { - title: 'Favorites', + title: $t('favorites'), }, }; }) satisfies PageLoad; 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 4367dd9896..b09a500f41 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,15 +1,18 @@ import { authenticate } from '$lib/utils/auth'; 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); return { asset, meta: { - title: 'Map', + title: $t('map'), }, }; }) satisfies PageLoad; 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 2e5e891579..1c127d2588 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,16 +1,19 @@ import { authenticate } from '$lib/utils/auth'; 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); return { user, asset, meta: { - title: 'Memory', + title: $t('memory'), }, }; }) satisfies PageLoad; 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 a01c79a93c..194fb53f7b 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,6 +1,8 @@ import { authenticate } from '$lib/utils/auth'; 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 }) => { @@ -8,11 +10,13 @@ export const load = (async ({ params }) => { const partner = await getUser({ id: params.userId }); const asset = await getAssetInfoFromParam(params); + const $t = get(t); + return { asset, partner, meta: { - title: 'Partner', + title: $t('partner'), }, }; }) satisfies PageLoad; diff --git a/web/src/routes/(user)/people/+page.ts b/web/src/routes/(user)/people/+page.ts index c7ac50a493..95dfef7646 100644 --- a/web/src/routes/(user)/people/+page.ts +++ b/web/src/routes/(user)/people/+page.ts @@ -1,15 +1,19 @@ import { authenticate } from '$lib/utils/auth'; 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); + return { people, meta: { - title: 'People', + title: $t('people'), }, }; }) satisfies PageLoad; 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 1f9f9e26c9..fbb2e763aa 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,6 +1,8 @@ import { authenticate } from '$lib/utils/auth'; 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 }) => { @@ -11,13 +13,14 @@ export const load = (async ({ params }) => { getPersonStatistics({ id: params.personId }), getAssetInfoFromParam(params), ]); + const $t = get(t); return { person, statistics, asset, meta: { - title: person.name || 'Person', + title: person.name || $t('person'), }, }; }) satisfies PageLoad; diff --git a/web/src/routes/(user)/photos/[[assetId=id]]/+page.ts b/web/src/routes/(user)/photos/[[assetId=id]]/+page.ts index 663e3cebba..31373ef621 100644 --- a/web/src/routes/(user)/photos/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/photos/[[assetId=id]]/+page.ts @@ -1,14 +1,18 @@ import { authenticate } from '$lib/utils/auth'; 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); + return { asset, meta: { - title: 'Photos', + title: $t('photos'), }, }; }) satisfies PageLoad; diff --git a/web/src/routes/(user)/places/+page.ts b/web/src/routes/(user)/places/+page.ts index 1f3a15fb64..055a8dcae0 100644 --- a/web/src/routes/(user)/places/+page.ts +++ b/web/src/routes/(user)/places/+page.ts @@ -1,15 +1,18 @@ import { authenticate } from '$lib/utils/auth'; 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); return { items, meta: { - title: 'Places', + title: $t('places'), }, }; }) satisfies PageLoad; 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 c0384cf38d..c282577c8d 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,14 +1,18 @@ import { authenticate } from '$lib/utils/auth'; 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); + return { asset, meta: { - title: 'Search', + title: $t('search'), }, }; }) satisfies PageLoad; 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 94969a088e..06e9b2905e 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 @@ -2,12 +2,15 @@ import { getAssetThumbnailUrl, setSharedLink } from '$lib/utils'; import { authenticate } from '$lib/utils/auth'; 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 }); @@ -20,8 +23,8 @@ export const load = (async ({ params }) => { asset, key, meta: { - title: sharedLink.album ? sharedLink.album.albumName : 'Public Share', - description: sharedLink.description || `${assetCount} shared photos & videos.`, + title: sharedLink.album ? sharedLink.album.albumName : $t('public_share'), + description: sharedLink.description || $t('shared_photos_and_videos_count', { values: { assetCount } }), imageUrl: assetId ? getAssetThumbnailUrl(assetId) : '/feature-panel.png', }, }; @@ -31,7 +34,7 @@ export const load = (async ({ params }) => { passwordRequired: true, sharedLinkKey: key, meta: { - title: 'Password Required', + title: $t('password_required'), }, }; } diff --git a/web/src/routes/(user)/sharing/+page.ts b/web/src/routes/(user)/sharing/+page.ts index 2fa8415e7c..fc2d90d95e 100644 --- a/web/src/routes/(user)/sharing/+page.ts +++ b/web/src/routes/(user)/sharing/+page.ts @@ -1,17 +1,20 @@ import { authenticate } from '$lib/utils/auth'; 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); return { sharedAlbums, partners, meta: { - title: 'Sharing', + title: $t('sharing'), }, }; }) satisfies PageLoad; diff --git a/web/src/routes/(user)/sharing/sharedlinks/+page.ts b/web/src/routes/(user)/sharing/sharedlinks/+page.ts index dd07ff42f9..027276d538 100644 --- a/web/src/routes/(user)/sharing/sharedlinks/+page.ts +++ b/web/src/routes/(user)/sharing/sharedlinks/+page.ts @@ -1,11 +1,15 @@ import { authenticate } from '$lib/utils/auth'; +import { t } from 'svelte-i18n'; +import { get } from 'svelte/store'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate(); + const $t = get(t); + return { meta: { - title: 'Shared Links', + title: $t('shared_links'), }, }; }) satisfies PageLoad; 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 3fb1757cc1..fe363d2240 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,14 +1,18 @@ import { authenticate } from '$lib/utils/auth'; 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); + return { asset, meta: { - title: 'Trash', + title: $t('trash'), }, }; }) satisfies PageLoad; diff --git a/web/src/routes/(user)/utilities/+page.ts b/web/src/routes/(user)/utilities/+page.ts index 1a62d6ec3f..23e3fc450d 100644 --- a/web/src/routes/(user)/utilities/+page.ts +++ b/web/src/routes/(user)/utilities/+page.ts @@ -1,15 +1,18 @@ import { authenticate } from '$lib/utils/auth'; 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); return { asset, meta: { - title: 'Utilities', + title: $t('utilities'), }, }; }) satisfies PageLoad; 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 67c33b85fd..9968b73d90 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,18 +1,21 @@ import { authenticate } from '$lib/utils/auth'; 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); return { asset, duplicates, meta: { - title: 'Duplicates', + title: $t('duplicates'), }, }; }) satisfies PageLoad; diff --git a/web/src/routes/+page.ts b/web/src/routes/+page.ts index 3f66cc9f41..ed10f6020b 100644 --- a/web/src/routes/+page.ts +++ b/web/src/routes/+page.ts @@ -1,6 +1,8 @@ import { AppRoute } from '$lib/constants'; 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'; @@ -19,10 +21,12 @@ export const load = (async () => { redirect(302, AppRoute.AUTH_LOGIN); } + const $t = get(t); + return { meta: { - title: 'Welcome 🎉', - description: 'Immich Web Interface', + title: $t('welcome') + ' 🎉', + description: $t('immich_web_interface'), }, }; }) satisfies PageLoad;