Closed mahsashadi closed 3 years ago
Use await core.make('osjs/locale').setLocale('en_EN')
Yes, thanks. It is solved.
And It seems I should check both 'en_US' & 'en_EN'
, since at first it is set by 'en_US'
//toggle language between english and persian
osjs.on('osjs/core:started', () =>
osjs.make('osjs/tray', {
title: 'Language',
icon: osjs.make('osjs/theme').icon('preferences-desktop-locale'),
onclick: async (ev) => {
const lang = await osjs.make('osjs/locale').getLocale();
if (lang === 'fa_FA') {
await osjs.make('osjs/locale').setLocale('en_EN');
document.location.reload();
} else if (lang === 'en_US' || lang === 'en_EN') {
await osjs.make('osjs/locale').setLocale('fa_FA');
document.location.reload();
}
},
})
);
Just use lang.match(/^en/)
:)
I need to add an icon fro toggleling between english and persian language in desktop. I add the following code to
src/client/index.js
fileIt won't work, till at least one-time I change the language by setting app, after that it will toggle properly. But if I don't change language by settings, the code will console.log
undefined
. The propertydata-locale
of element with classosjs-root
is alsoundefined
.