useWebsiteLocale
Creates persistent website-locale state backed by local storage. Whenever the locale changes, the composable updates the root document language through setWebsiteLocale.
Importing
ts
import { useWebsiteLocale } from '@almighty-shogun/vue-utils'Usage
ts
import { useWebsiteLocale } from '@almighty-shogun/vue-utils'
const { locale, setLocale } = useWebsiteLocale();
setLocale('nl');Returns
| Name | Type | Description |
|---|---|---|
locale | Ref<string> | Current website locale. |
setLocale(locale) | (locale: string) => void | Updates the locale ref and applies it to the document. |
Type signature
ts
declare function useWebsiteLocale(): UseWebsiteLocale;
type UseWebsiteLocale = {
readonly locale: Ref<string>;
setLocale(newLocale: string): void;
};