19 lines
439 B
TypeScript
19 lines
439 B
TypeScript
'use client';
|
|
|
|
import { useContext } from 'react';
|
|
|
|
import { LanguageContext } from '../context/language-provider';
|
|
|
|
export function useLanguage() {
|
|
const context = useContext(LanguageContext);
|
|
if (context === undefined) {
|
|
throw new Error('useLanguage must be used within a LanguageProvider');
|
|
}
|
|
|
|
if (typeof context.t !== 'function') {
|
|
throw new Error('Translation function (t) is not available');
|
|
}
|
|
|
|
return context;
|
|
}
|