import NextI18Next from 'next-i18next';

import { WithTranslation as OriginalWithTranslation } from 'react-i18next';

const options = {
  defaultLanguage: 'is-IS',
  otherLanguages: ['en'],
  localePath: typeof window === 'undefined' ? './public/locales' : '/locales',
  browserLanguageDetection: false,
  serverLanguageDetection: false,
  react: {
    useSuspense: false, // We should be able to set this to true when we've completely migrated from withTranslation to the hook
  },
};

const nexti18next = new NextI18Next(options);

export default nexti18next;

export type WithTranslation = OriginalWithTranslation;
export const { appWithTranslation, withTranslation, i18n, Link, Trans, config, useTranslation } =
  nexti18next;
