I want to remove the /en or the /it from the url. I don't want it to be explicit putting that in the url. i18next does it by default and I don't know how to remove it. I just want to make it in background.
Do I have to add any option to remove that or there's nothing I can do about?
My code is the following:
import i18n from 'i18next'
import Backend from 'i18next-http-backend'
import LanguageDetector from 'i18next-browser-languagedetector'
import { initReactI18next } from 'react-i18next'
i18n
.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng: 'en',
debug: true,
interpolation: {
escapeValue: false,
},
react: {
useSuspense: false,
},
})
export default i18n
I import this in the page I want to translate
import { useTranslation } from 'react-i18next';
function MyComponent: ReactElement {
const [isEnglish, setIsEnglish] = useState(true);
const { t, i18n } = useTranslation();
const handleClick = () => {
setIsEnglish(!isEnglish);
i18n.changeLanguage(!isEnglish ? 'en' : 'it');
}
return <>My stuff</>
}
As I said it adds to my route /[language code]. Is there a way to remove it and just set it up in "background"?
Thank you very much!