Menu acts like static about its labels

UI Components for React
Post Reply
numankayali
Posts: 3
Joined: 08 Dec 2016, 09:29

12 Nov 2017, 17:32

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}/>

kaho29
Posts: 12
Joined: 18 Aug 2017, 10:57

13 Nov 2017, 13:04

Could this be related to what I described here?

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

User avatar
aragorn
Posts: 2638
Joined: 29 Jun 2013, 12:38

16 Nov 2017, 13:22

Could you please provide a plunker for us to replicate?
https://plnkr.co/edit/uHHN7wKskRgpHszbPZtj?p=info

kaho29
Posts: 12
Joined: 18 Aug 2017, 10:57

17 Nov 2017, 15:32

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.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest