public static void updateLanguage(HttpServletRequest request, HttpServletResponse response) {

    String languageId =
        ParamUtil.getString(request, "companyLocale", PropsValues.COMPANY_DEFAULT_LOCALE);

    Locale locale = LocaleUtil.fromLanguageId(languageId);

    List<Locale> availableLocales = ListUtil.fromArray(LanguageUtil.getAvailableLocales());

    if (!availableLocales.contains(locale)) {
      return;
    }

    HttpSession session = request.getSession();

    session.setAttribute(Globals.LOCALE_KEY, locale);
    session.setAttribute(WebKeys.SETUP_WIZARD_DEFAULT_LOCALE, languageId);

    LanguageUtil.updateCookie(request, response, locale);

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    themeDisplay.setLanguageId(languageId);
    themeDisplay.setLocale(locale);
  }
  protected ThemeDisplay getThemeDisplay(SecurityToken securityToken) throws Exception {

    long userIdLong = GetterUtil.getLong(securityToken.getViewerId());

    User user = UserLocalServiceUtil.getUserById(userIdLong);

    Company company = CompanyLocalServiceUtil.getCompanyById(user.getCompanyId());

    ThemeDisplay themeDisplay = new ThemeDisplay();

    themeDisplay.setCompany(company);
    themeDisplay.setLocale(user.getLocale());
    themeDisplay.setUser(user);

    return themeDisplay;
  }