Canonicalize and persist a website language.
Usage:
import { setLanguagePreference } from "mazey";const stored = setLanguagePreference( "MY_WEBSITE_LANGUAGE", "ZH_cn");console.log(stored); Copy
import { setLanguagePreference } from "mazey";const stored = setLanguagePreference( "MY_WEBSITE_LANGUAGE", "ZH_cn");console.log(stored);
Output when browser storage is available:
true Copy
true
The stored value is canonicalized to:
zh-CN Copy
zh-CN
Project-specific local-storage key.
Language tag to canonicalize and persist.
true when storage succeeds, or false when storage is unavailable or rejects the write.
false
If storageKey is empty or language is empty or malformed.
storageKey
language
Safe during SSR. This function writes only the canonical language and never mutates the DOM, applies translations, redirects, or adds listeners.
Canonicalize and persist a website language.
Usage:
Output when browser storage is available:
The stored value is canonicalized to: