diff options
Diffstat (limited to 'packages/web-util/src/hooks/useLang.ts')
-rw-r--r-- | packages/web-util/src/hooks/useLang.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/packages/web-util/src/hooks/useLang.ts b/packages/web-util/src/hooks/useLang.ts index d64cf6e1a..448cd8aba 100644 --- a/packages/web-util/src/hooks/useLang.ts +++ b/packages/web-util/src/hooks/useLang.ts @@ -14,7 +14,11 @@ GNU Anastasis; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { LocalStorageState, useLocalStorage } from "./useLocalStorage.js"; +import { + StorageState, + buildStorageKey, + useLocalStorage, +} from "./useLocalStorage.js"; function getBrowserLang(): string | undefined { if (typeof window === "undefined") return undefined; @@ -23,7 +27,9 @@ function getBrowserLang(): string | undefined { return undefined; } -export function useLang(initial?: string): Required<LocalStorageState> { +const langPreferenceKey = buildStorageKey("lang-preference"); + +export function useLang(initial?: string): Required<StorageState> { const defaultValue = (getBrowserLang() || initial || "en").substring(0, 2); - return useLocalStorage("lang-preference", { defaultValue: defaultValue }); + return useLocalStorage(langPreferenceKey, defaultValue); } |