diff options
Diffstat (limited to 'shared/components/src/utils/internal/locale')
| -rw-r--r-- | shared/components/src/utils/internal/locale/index.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/shared/components/src/utils/internal/locale/index.ts b/shared/components/src/utils/internal/locale/index.ts new file mode 100644 index 0000000..e4165a9 --- /dev/null +++ b/shared/components/src/utils/internal/locale/index.ts @@ -0,0 +1,17 @@ +/* istanbul ignore file */ + +//TODO rdar://93379311 (Solution for sharing context between app + shared components) +import { getContext, setContext } from 'svelte'; +import type { Locale } from '@amp/web-app-components/src/types'; + +const CONTEXT_NAME = 'shared:locale'; + +// WARNING these signatures can change after rdar://93379311 +export function setLocale(context: Map<string, unknown>, locale: Locale) { + context.set(CONTEXT_NAME, locale); +} + +// WARNING these signatures can change after rdar://93379311 +export function getLocale(): Locale { + return getContext(CONTEXT_NAME) as Locale | undefined; +} |
