i18next / react-i18next

Internationalization for react done right. Using the i18next i18n ecosystem.

Home Page:https://react.i18next.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

i18n.changeLanguage dont work if we setup our app using SSR razzle example in react-i18next

Tarunmeena0901 opened this issue Β· comments

πŸ› Bug Report

A clear and concise description of what the bug is.
i18n.changeLanguage dont work if we setup our app using SSR razzle example in react-i18next

To Reproduce

setup the razzle app example in react-18next and add a langauge switcher in the home page

My code

renderContent() {
		const { t , i18n} = this.props;
		const lngs = {
			en: { nativeName: 'English' },
			es: { nativeName: 'Spanish' }
		};
		return (
			<Container>
				<Row>
					<Col lg={{offset: 2, span: 8}}>
						<h1 className="text-center">The Open Book Database</h1>
						<p className="lead text-justify">
							{t('home.home_about')}
						</p>
					</Col>
					<Col>
            			{Object.keys(lngs).map((lng) => (
            			    <button key={lng} style={{ fontWeight: i18n.resolvedLanguage === lng ? 'bold' : 'normal' }} type="submit" 
                                          onClick={() => i18n.changeLanguage(lng)}>
            			        {lngs[lng].nativeName}
            			    </button>
            			))}
        			</Col>
				</Row>

i am using the withTranslation() with the class component everything else done is same as the example provide in link
the t function works fine but the language changer is not working

please provide a minimal but complete example repository, not just code snippets...

Hi @adrai , i am sorry but i implemented this in an organization code so i can not make a new repo for it, everything is working fine except the language changer
in this repo you can find all the relevant files . Thanks

GITHUB LINK

Sorry, but I need something to reproduce this...
Can you adapt this example so this can be reproduced?
https://github.com/i18next/react-i18next/tree/master/example/razzle-ssr

I am so sorry to say this but i am not able to find any time to create a repository adapting a example but i found out something weird happening with my setup and this not the issue with react-i18next so i think we can close this issue

by the way it would we be a great help if anyone can give me any idea of what is wrong here .... as soon i import ../../i18n here
my frontend buttons stop working rest all is working fine . anything related to webpack ? I trying to setup i18n with SSR in react

Screenshot 2024-03-21 022903