on 07-27-2016 4:50 PM
I would like to override the selected language behavior for the product cockpit labels based on the following use case:
If the selected language on login screen is assigned to any of the user's readable catalogs. Use the selected language.
if a session language is assigned to user's profile use the user's session language.
otherwise use ENGLISH (en)
I have overridden the DefaultCockpitUserDetailsService.loadUserByUsername as:
private String getLoginLanguage(String loginLanguage, final String userUid)
{
boolean languageAvailableInCatalog = false;
final Collection<CatalogVersionModel> catalogVersions = catalogVersionService.getAllCatalogVersions();
for (final CatalogVersionModel catalogVersion : catalogVersions)
{
if (catalogVersion.getCatalog().getId().equals("Default"))
{
continue;
}
for (final LanguageModel language : catalogVersion.getLanguages())
{
if (StringUtils.equalsIgnoreCase(language.getIsocode(), loginLanguage))
{
languageAvailableInCatalog = true;
break;
}
}
}
if (!languageAvailableInCatalog)
{
final LanguageModel sessionLanguage = userService.getUserForUID(userUid).getSessionLanguage();
if (null != sessionLanguage)
{
loginLanguage = sessionLanguage.getIsocode();
}
else
{
loginLanguage = Locale.ENGLISH.getLanguage();
}
}
return loginLanguage;
}
@Override
public CoreUserDetails loadUserByUsername(final String username)
{
final CoreUserDetails coreUserDetails = super.loadUserByUsername(username);
commonI18NService.setCurrentLanguage(commonI18NService.getLanguage(getLoginLanguage(commonI18NService.getCurrentLanguage().getIsocode(), username)));
return coreUserDetails;
}
It reflects in the data values but doesn't reflect in the cockpit labels.
Could any expert help here?
You want:
i18NService.setCurrentLocale(/* ... */)
Not:
commonI18NService.setCurrentLanguage(/* ... */)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Haitao,
Probably, you didn't understand the question. As I mentioned, if the login language is not available in the user's accessible catalog then I need to use other language based on the mentioned use case.
In that case, I need to render the cockpit labels in the language other than the login language.
Regards, Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Amit,
There is one way to set labels in the language selected in the cockpit login page.
Add context to the areas where you want to use. For example, editorArea_myvalue.xml
Create the i3-label.properties and i3-label_de.properties etc for the language you want to display.
Rebuild your codebase
For more details, please refer to:
Regards
Haitao
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.