import { usePage } from '@inertiajs/react';

interface PageProps {
    locale: string;
    translations: Record<string, string>;
    [key: string]: any;
}

export function useTranslation() {
    const { locale, translations } = usePage<PageProps>().props;

    const t = (key: string, fallback?: string): string => {
        return translations?.[key] || fallback || key;
    };

    return { t, locale };
}
