index.ts
1 /* istanbul ignore file */ 2 3 //TODO rdar://93379311 (Solution for sharing context between app + shared components) 4 import { getContext, setContext } from 'svelte'; 5 import type { Locale } from '@amp/web-app-components/src/types'; 6 7 const CONTEXT_NAME = 'shared:locale'; 8 9 // WARNING these signatures can change after rdar://93379311 10 export function setLocale(context: Map<string, unknown>, locale: Locale) { 11 context.set(CONTEXT_NAME, locale); 12 } 13 14 // WARNING these signatures can change after rdar://93379311 15 export function getLocale(): Locale { 16 return getContext(CONTEXT_NAME) as Locale | undefined; 17 }