"use client"; import { createContext, type ReactNode, useContext, useMemo } from "react"; import { defaultLocale, type Locale } from "@/translations/config"; import { type Dictionary, getDictionary } from "@/translations/dictionaries"; type I18nContextValue = { locale: Locale; dictionary: Dictionary; }; const I18nContext = createContext({ locale: defaultLocale, dictionary: getDictionary(defaultLocale), }); type I18nProviderProps = { children: ReactNode; locale: Locale; }; export function I18nProvider({ children, locale }: I18nProviderProps) { const value = useMemo( () => ({ locale, dictionary: getDictionary(locale), }), [locale], ); return {children}; } export function useI18n() { return useContext(I18nContext); }