summaryrefslogtreecommitdiff
path: root/shared/components/src/utils/internal/locale/index.ts
diff options
context:
space:
mode:
authorrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
committerrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
commitbce557cc2dc767628bed6aac87301a1be7c5431b (patch)
treeb51a051228d01fe3306cd7626d4a96768aadb944 /shared/components/src/utils/internal/locale/index.ts
init commit
Diffstat (limited to 'shared/components/src/utils/internal/locale/index.ts')
-rw-r--r--shared/components/src/utils/internal/locale/index.ts17
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;
+}