javascript - reactJS i18n reloading page -
i'm using react-i18next in reactjs app.
problem when change language app reloads , starts main route.
is there way redirect on same page or change language without reload page?
thanks
update
i18n.js
import i18n 'i18next'; import languagedetector 'i18next-browser-languagedetector'; import {de} "../../locales/de"; import {en} "../../locales/en"; i18n .use(languagedetector) .init({ resources: { en: en, de: de }, fallbacklng: 'de', // have common namespace used around full app ns: ['translations'], defaultns: 'translations', keyseparator: '.', interpolation: { escapevalue: false, // not needed react!! formatseparator: ',' }, react: { wait: true } }); export default i18n;
change language:
const { t, i18n } = this.props; const changelanguage = (lng) => { i18n.changelanguage(lng); };
how change language? using querystring?
if call i18next.changelanguage(lng);
there won't change, rerender in new language...
as sample see: https://github.com/i18next/react-i18next/blob/master/example/webpack2/app/components/view.js#l50
Comments
Post a Comment