I need to add language to url i.e. this is how the URL looks now http://localhost:3000/, http://localhost:3000/news, but it needs to be like this http://localhost:3000/en, http://localhost:3000/en/news.
At the same time, when someone sends a link to this site, the language must be taken from the link. Here is my code. Languages work, change on click.
import i18n from 'i18next'
import HttpApi from 'i18next-http-backend'
import LanguageDetector from 'i18next-browser-languagedetector'
import { initReactI18next } from 'react-i18next'
i18n
.use(LanguageDetector)
.use(initReactI18next)
.use(HttpApi)
.init({
supportedLngs: ['ru', 'en', 'kk'],
fallbackLng: "en",
detection: {
order: ["cookie", "localStorage", "htmlTag", "path", "subdomain"],
caches: ["cookie"],
},
interpolation: {
escapeValue: false
}
});
export default i18n;
But how to add to URL automatically? Are there ready-made solutions for this?