'use client'
import { createContext, useContext } from 'react'
import { getDictionary, type Dictionary } from '@/lib/i18n'

const LangContext = createContext<Dictionary>(getDictionary('en'))

export function LangProvider({ lang, children }: { lang: string; children: React.ReactNode }) {
  return (
    <LangContext.Provider value={getDictionary(lang)}>
      {children}
    </LangContext.Provider>
  )
}

/** Use inside any client component to get the current language dictionary. */
export function useT(): Dictionary {
  return useContext(LangContext)
}
