mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
chore(web): migration svelte 5 syntax (#13883)
This commit is contained in:
parent
9203a61709
commit
0b3742cf13
310 changed files with 6435 additions and 4176 deletions
|
|
@ -3,12 +3,18 @@
|
|||
import FormatMessage from '../format-message.svelte';
|
||||
import type { ComponentProps } from 'svelte';
|
||||
|
||||
export let key: Translations;
|
||||
export let values: ComponentProps<FormatMessage>['values'];
|
||||
interface Props {
|
||||
key: Translations;
|
||||
values: ComponentProps<typeof FormatMessage>['values'];
|
||||
}
|
||||
|
||||
let { key, values }: Props = $props();
|
||||
</script>
|
||||
|
||||
<FormatMessage {key} {values} let:tag let:message>
|
||||
{#if tag === 'b'}
|
||||
<strong>{message}</strong>
|
||||
{/if}
|
||||
<FormatMessage {key} {values}>
|
||||
{#snippet children({ tag, message })}
|
||||
{#if tag === 'b'}
|
||||
<strong>{message}</strong>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</FormatMessage>
|
||||
|
|
|
|||
|
|
@ -3,12 +3,18 @@
|
|||
import type { InterpolationValues } from '$lib/components/i18n/format-message.svelte';
|
||||
import type { Translations } from 'svelte-i18n';
|
||||
|
||||
export let key: Translations;
|
||||
export let values: InterpolationValues = {};
|
||||
interface Props {
|
||||
key: Translations;
|
||||
values?: InterpolationValues;
|
||||
}
|
||||
|
||||
let { key, values = {} }: Props = $props();
|
||||
</script>
|
||||
|
||||
<FormatMessage {key} {values} let:message let:tag>
|
||||
{#if tag === 'b'}
|
||||
<b>{message}</b>
|
||||
{/if}
|
||||
<FormatMessage {key} {values}>
|
||||
{#snippet children({ message, tag })}
|
||||
{#if tag === 'b'}
|
||||
<b>{message}</b>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</FormatMessage>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<script lang="ts" context="module">
|
||||
<script lang="ts" module>
|
||||
import type { FormatXMLElementFn, PrimitiveType } from 'intl-messageformat';
|
||||
export type InterpolationValues = Record<string, PrimitiveType | FormatXMLElementFn<unknown>>;
|
||||
</script>
|
||||
|
|
@ -18,8 +18,13 @@
|
|||
tag?: string;
|
||||
};
|
||||
|
||||
export let key: Translations;
|
||||
export let values: InterpolationValues = {};
|
||||
interface Props {
|
||||
key: Translations;
|
||||
values?: InterpolationValues;
|
||||
children?: import('svelte').Snippet<[{ tag?: string; message?: string }]>;
|
||||
}
|
||||
|
||||
let { key, values = {}, children }: Props = $props();
|
||||
|
||||
const getLocale = (locale?: string | null) => {
|
||||
if (locale == null) {
|
||||
|
|
@ -96,9 +101,9 @@
|
|||
}
|
||||
};
|
||||
|
||||
$: message = ($json(key) as string) || key;
|
||||
$: locale = getLocale($i18nLocale);
|
||||
$: parts = getParts(message, locale);
|
||||
let message = $derived(($json(key) as string) || key);
|
||||
let locale = $derived(getLocale($i18nLocale));
|
||||
let parts = $derived(getParts(message, locale));
|
||||
</script>
|
||||
|
||||
<!--
|
||||
|
|
@ -130,7 +135,7 @@ Result: Visit <a href="">docs</a> <strong>now</strong>
|
|||
-->
|
||||
{#each parts as { tag, message }}
|
||||
{#if tag}
|
||||
<slot {tag} {message}>{message}</slot>
|
||||
{#if children}{@render children({ tag, message })}{:else}{message}{/if}
|
||||
{:else}
|
||||
{message}
|
||||
{/if}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue