Skip to content

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

NameTypeDescription
localeRef<string>Current website locale.
setLocale(locale)(locale: string) => voidUpdates 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;
};

Uses

All packages are released under the MIT License.