Hello,
I am able to set the localization service to the message in english but when I change the dropdown value to spanish the message remains in english, do you have a workaround for this?
const DrawerContainer = (props: any) => {
constlocalizationService = useLocalization();
const locales: LocaleInterface[] = [
{
language: "en-US",
locale: "en",
name: "English",
},
{
language: "es-ES",
locale: "es",
name: "Spanish",
},
{
language: "sv",
locale: "sv",
name: "Swedish",
},
];
const [currentLocale, setCurrentLocale] = React.useState(
locales[0]
);
const [expanded, setExpanded] = React.useState(true);
const [drawerExpanded, setDrawerExpanded] = React.useState(true);
const [items, setItems] = React.useState([
{
text: localizationService.toLanguageString('custom.personalInfo', ''),
route: '/profile'
},
{
separator: true
},
{
text: 'Sites',
route: '/sites'
},
{
separator: true
},
{
text: 'My Compressed Air System',
route: '/mycasystem'
},
{
text: Array(25).fill('\xa0').join('') + 'Compressors',
route: '/mypage'
},
/* {
text: 'My Compressor',
route: '/mycomp'
}, {
text: 'Compare',
route: '/compare'
},
{
text: 'Dashboard',
route: '/dashboard'
},
{
text: 'Customers',
route: '/customers'
} */
]);
const selected = setSelectedItem(props.location.pathname);
return<div>
<LocalizationProvider language={currentLocale.language}>
<IntlProvider locale={currentLocale.locale}>
<DropDownList
value={currentLocale}
textField="name"
onChange={(e) => {
setCurrentLocale(e.target.value);
}}
data={locales}
/>
<div className="custom-toolbar">
<Button icon="menu" onClick={handleClick} />
<span className="title" id="burguer-menu">{localizationService.toLanguageString('custom.menu', '')}</span>
</div>
<Drawer expanded={expanded} position={'start'} mode={'push'} width={300} items={items.map(item => ({
...item,
selected: item.text === selected
}))} onSelect={onSelect}>
<DrawerContent>
{props.children}
</DrawerContent>
</Drawer>
</IntlProvider>
</LocalizationProvider>
</div >;
};
export default withRouter(DrawerContainer);