mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
chore(web): enforce valid translation keys using typescript (#12106)
This commit is contained in:
parent
bab5ad7ebd
commit
9f5a3f1e84
7 changed files with 48 additions and 49 deletions
28
web/src/app.d.ts
vendored
28
web/src/app.d.ts
vendored
|
|
@ -27,3 +27,31 @@ interface Element {
|
|||
// Make optional, because it's unavailable on iPhones.
|
||||
requestFullscreen?(options?: FullscreenOptions): Promise<void>;
|
||||
}
|
||||
|
||||
import type en from '$lib/i18n/en.json';
|
||||
import 'svelte-i18n';
|
||||
|
||||
type NestedKeys<T, K = keyof T> = K extends keyof T & string
|
||||
? `${K}` | (T[K] extends object ? `${K}.${NestedKeys<T[K]>}` : never)
|
||||
: never;
|
||||
|
||||
declare module 'svelte-i18n' {
|
||||
import type { InterpolationValues } from '$lib/components/i18n/format-message.svelte';
|
||||
import type { Readable } from 'svelte/store';
|
||||
|
||||
type Translations = NestedKeys<typeof en>;
|
||||
|
||||
interface MessageObject {
|
||||
id: Translations;
|
||||
locale?: string;
|
||||
format?: string;
|
||||
default?: string;
|
||||
values?: InterpolationValues;
|
||||
}
|
||||
|
||||
type MessageFormatter = (id: Translations | MessageObject, options?: Omit<MessageObject, 'id'>) => string;
|
||||
|
||||
const format: Readable<MessageFormatter>;
|
||||
const t: Readable<MessageFormatter>;
|
||||
const _: Readable<MessageFormatter>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue