// frontend/src/i18n/index.ts
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import { resources, defaultLanguage } from '../locales';

i18n
  .use(initReactI18next)
  .init({
    resources,
    lng: defaultLanguage,
    fallbackLng: defaultLanguage,

    interpolation: {
      escapeValue: false, // React already does escaping
    },

    // Enable debug in development
    debug: process.env.NODE_ENV === 'development',

    // Default namespace
    defaultNS: 'common',

    // Fallback namespace
    fallbackNS: 'common',

    // Key separator for nested keys
    keySeparator: '.',

    // Namespace separator
    nsSeparator: ':',

    // React options
    react: {
      useSuspense: false,
    },
  });

export default i18n;