import { derived, type Readable } from 'svelte/store'; import { json } from 'svelte-i18n'; import type { Locale } from '$lib/Locale/layout'; // type FormatXMLElementFn = (parts: Array) => R; // interface Options { // id?: string; // locale?: string; // format?: string; // default?: string; // values?: // | Record< // string, // string | number | boolean | Date | FormatXMLElementFn | null | undefined // > // | undefined; // } const createLocale = () => { return derived(json, ($json) => { return (locale = undefined) => new Proxy( {}, { get(_target, key) { const localisation = $json(key.toString(), locale); if (localisation === key.toString()) return undefined; return localisation; } } ); }) as Readable<(locale?: string) => Locale>; }; const locale = createLocale(); export default locale;