// dang.tung - set portal language by user preference -> browser ->
// default
// ------------------------------------------------------------------------------
String portalLanguage = null;
LocaleConfigService localeConfigService = getApplicationComponent(LocaleConfigService.class);
OrganizationService orgService = getApplicationComponent(OrganizationService.class);
LocaleConfig localeConfig = localeConfigService.getLocaleConfig(userPortalConfig_.getPortalConfig().getLocale());
String user = context.getRemoteUser();
if (user != null)
{
UserProfile userProfile = orgService.getUserProfileHandler().findUserProfileByName(user);
if (userProfile != null)
{
portalLanguage = userProfile.getUserInfoMap().get("user.language");
}
else
{
if (log.isWarnEnabled())
log.warn("Could not load user profile for " + user + ". Using default portal locale.");
}
}
localeConfig = localeConfigService.getLocaleConfig(portalLanguage);
if (portalLanguage == null || !portalLanguage.equals(localeConfig.getLanguage()))
{
// if user language no support by portal -> get browser language if no
// ->
// get portal
portalLanguage = context.getRequest().getLocale().getLanguage();
localeConfig = localeConfigService.getLocaleConfig(portalLanguage);
if (!portalLanguage.equals(localeConfig.getLanguage()))
{
localeConfig = localeConfigService.getLocaleConfig(userPortalConfig_.getPortalConfig().getLocale());
}
}
setLocale(localeConfig.getLocale());
setOrientation(localeConfig.getOrientation());
// -------------------------------------------------------------------------------