Page 1 of 1

Menu acts like static about its labels

Posted: 12 Nov 2017, 17:32
by numankayali
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}/>

Re: Menu acts like static about its labels

Posted: 13 Nov 2017, 13:04
by kaho29
Could this be related to what I described here?

viewtopic.php?f=57&t=53045&sid=c735f428 ... caf34067a3

Re: Menu acts like static about its labels

Posted: 16 Nov 2017, 13:22
by aragorn
Could you please provide a plunker for us to replicate?
https://plnkr.co/edit/uHHN7wKskRgpHszbPZtj?p=info

Re: Menu acts like static about its labels

Posted: 17 Nov 2017, 15:32
by kaho29
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.

Re: Menu acts like static about its labels

Posted: 19 Nov 2017, 11:26
by numankayali
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

Re: Menu acts like static about its labels

Posted: 23 Nov 2017, 15:03
by merve7
Thanks for plunker. We fixed for next version(PrimeReact 1.2.1)