import i18next from "i18next";
import { initReactI18next } from "react-i18next";
import fr from "../locales/fr/translation.json";

/**
 * i18next instance for the whole app, imported once for its side effect
 * (`main.tsx`) before anything renders. Only French exists today —
 * `packages/shared`'s `ErrorCode` enum members double as translation keys
 * under the `errors` namespace (see `services/error-message.service.ts`).
 *
 * Adding a language later is "add a `resources.<lng>` entry pointing at a
 * new locale file", not touching a single component.
 */
void i18next.use(initReactI18next).init({
  resources: {
    fr: { translation: fr },
  },
  lng: "fr",
  fallbackLng: "fr",
  // React already escapes interpolated values when rendering JSX — letting
  // i18next also HTML-escape them would double-escape (e.g. turn "é" text
  // into visible "&eacute;" in some setups).
  interpolation: { escapeValue: false },
});

export default i18next;
