"use client"; import { createContext, ReactNode, useContext } from "react"; import type { Dictionary } from "./types"; import type { Locale } from "./config"; type I18nContextValue = { locale: Locale; dictionary: Dictionary; }; const I18nContext = createContext(undefined); export function I18nProvider({ value, children }: { value: I18nContextValue; children: ReactNode }) { return {children}; } export function useI18n() { const context = useContext(I18nContext); if (!context) { throw new Error("useI18n must be used within an I18nProvider"); } return context; } export function useDictionary() { const { dictionary } = useI18n(); return dictionary; } export function useLocale() { const { locale } = useI18n(); return locale; }