asi-calculator/features/prices/hooks/use-locale.ts

17 lines
322 B
TypeScript
Raw Normal View History

'use client'
import { useEffect, useState } from 'react'
export function useLocale() {
const [locale, setLocale] = useState('en-US')
useEffect(() => {
const userLocale = navigator?.languages?.length
? navigator.languages[0]
: navigator.language
setLocale(userLocale)
}, [])
return locale
}