import { computed, inject, toRef } from 'vue' import type { InjectionKey, Ref } from 'vue' import { createSharedComposable } from '@vueuse/core' import type { Locale, Messages } from '../types/locale' import { buildLocaleContext } from '../utils/locale' import en from '../locale/en' export const localeContextInjectionKey: InjectionKey | undefined>> = Symbol.for('nuxt-ui.locale-context') const _useLocale = (localeOverrides?: Ref | undefined>) => { const locale = localeOverrides || toRef(inject>(localeContextInjectionKey)) return buildLocaleContext(computed(() => locale.value || en)) } export const useLocale = createSharedComposable(_useLocale)