mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
13 lines
334 B
TypeScript
13 lines
334 B
TypeScript
import { useContext } from 'react'
|
|
import { I18nContext } from './i18n-context'
|
|
|
|
export type { Locale, I18nContextValue } from './i18n-context'
|
|
|
|
export function useTranslation() {
|
|
const context = useContext(I18nContext)
|
|
if (!context) {
|
|
throw new Error('useTranslation must be used within I18nProvider')
|
|
}
|
|
return context
|
|
}
|