Hello. I have a page works in 2 languages. I have a Menu element on this page. when i switch the language, all of my labels are re-rendered accordig to new language except menu. Although its model change it does not reflect the new language. My code:
import T from 'i18n-react';
//my menu model. when i change the locale i can see that content is changing too in debug.
let items = [
{ label: T.translate("component.home"), command: () => {this.props.history.push('/');} },
{ label: T.translate("component.about"), command: () => {this.props.history.push('/about');} }
];
//i am switching the language from here
<Dropdown value={sessionStorage.getItem('locale')} options={languages} onChange={this.handleLocaleChange()}
handleLocaleChange(e) {
if (e.value ==='tr') {
T.setTexts(require('./language/tr.json'));
sessionStorage.setItem('locale', 'tr');
} else if (e.value ==='en') {
T.setTexts(require('./language/en.json'));
sessionStorage.setItem('locale', 'en');
}
this.forceUpdate();
}
//My link object. It switches and shows the label correctly when language changes!
<Link to="/about" onClick={() => this.props.handlePageChange()}>
{T.translate("component.about")}
</Link>
//My menu and its button. Its only visible when width < 480
//It doesn change the labels. It acts like static.
<Button className="responsiveButton" icon="fa fa-list" onClick={(event) => this.menu.toggle(event)}/>
<Menu model={items} popup={true} ref={el => this.menu = el}/>
Menu acts like static about its labels
Could this be related to what I described here?
viewtopic.php?f=57&t=53045&sid=c735f428 ... caf34067a3
viewtopic.php?f=57&t=53045&sid=c735f428 ... caf34067a3
-
- Posts: 5281
- Joined: 29 Jun 2013, 12:38
Could you please provide a plunker for us to replicate?
https://plnkr.co/edit/uHHN7wKskRgpHszbPZtj?p=info
https://plnkr.co/edit/uHHN7wKskRgpHszbPZtj?p=info
Github Profile: https://github.com/mertsincan
I think you can reproduce this behaviour with my plunker I provided over here.
viewtopic.php?f=57&t=53045&sid=61ccb2a3 ... 4719e34c4a
Just replace one of the labels in the "switch"-function and you can see that not only the disabled state is not re-rendered correctly, but also a change in labels.
viewtopic.php?f=57&t=53045&sid=61ccb2a3 ... 4719e34c4a
Just replace one of the labels in the "switch"-function and you can see that not only the disabled state is not re-rendered correctly, but also a change in labels.
-
- Posts: 6
- Joined: 08 Dec 2016, 09:29
well, this is my first plunk so i hope i did it right.
my problem is that; when i update the state, button label changes but menu not!
thanks.
https://plnkr.co/edit/YmtooVj0tKLI1AQovvVE?p=info
my problem is that; when i update the state, button label changes but menu not!
thanks.
https://plnkr.co/edit/YmtooVj0tKLI1AQovvVE?p=info
-
- Information
-
Who is online
Users browsing this forum: No registered users and 12 guests