mazey
    Preparing search index...

    Function setLanguagePreference

    • Canonicalize and persist a website language.

      Usage:

      import { setLanguagePreference } from "mazey";

      const stored = setLanguagePreference(
      "MY_WEBSITE_LANGUAGE",
      "ZH_cn"
      );

      console.log(stored);

      Output when browser storage is available:

      true
      

      The stored value is canonicalized to:

      zh-CN
      

      Parameters

      • storageKey: string

        Project-specific local-storage key.

      • language: string

        Language tag to canonicalize and persist.

      Returns boolean

      true when storage succeeds, or false when storage is unavailable or rejects the write.

      If storageKey is empty or language is empty or malformed.

      Safe during SSR. This function writes only the canonical language and never mutates the DOM, applies translations, redirects, or adds listeners.