18 lines
451 B
TypeScript
18 lines
451 B
TypeScript
"use client"
|
|
import { useParams } from "next/navigation"
|
|
|
|
import { Lang } from "@scandic-hotels/common/constants/language"
|
|
import { languageSchema } from "@scandic-hotels/common/utils/languages"
|
|
|
|
/**
|
|
* A hook to get the current lang from the URL
|
|
*/
|
|
export default function useLang() {
|
|
const { lang } = useParams<{
|
|
lang: Lang
|
|
}>()
|
|
|
|
const parsedLang = languageSchema.safeParse(lang)
|
|
return parsedLang.success ? parsedLang.data : Lang.en
|
|
}
|