oriyo_next/src/shared/language/hooks/use-text-controller.ts

21 lines
477 B
TypeScript

'use client';
import { useContext } from 'react';
import { TextControlContext } from '../context/text-control-provider';
export function useTextController() {
const context = useContext(TextControlContext);
if (context === undefined) {
throw new Error(
'useTextController must be used within a TextControlProvider',
);
}
if (typeof context.t !== 'function') {
throw new Error('Translation function (t) is not available');
}
return context;
}