List of usage examples for org.springframework.util StringUtils parseLocaleString
@Nullable public static Locale parseLocaleString(String localeString)
From source file:com.nominanuda.springmvc.QueryParamLocaleResolver.java
public Locale resolveLocale(HttpServletRequest request) { String lang = request.getParameter(paramName); if (lang != null) { Locale locale = StringUtils.parseLocaleString(lang); return locale; }/*from ww w .j a v a 2 s. c o m*/ return getDefaultLocale(); }
From source file:info.jtrac.wicket.LogoutPage.java
public LogoutPage(PageParameters params) { String locale = params.getString("locale"); if (locale != null) { getRequestCycle().getSession().setLocale(StringUtils.parseLocaleString(locale)); }//from w w w .j a va 2 s .c o m setVersioned(false); add(new Label("title", getLocalizer().getString("logout.title", null))); String jtracVersion = ComponentUtils.getJtrac(this).getReleaseVersion(); add(new Label("version", jtracVersion)); }
From source file:org.paxml.bean.SetLocaleTag.java
/** * {@inheritDoc}/*from w w w .ja va2 s .com*/ */ @Override protected Object doInvoke(Context context) throws Exception { Object value = getValue(); if (value != null) { Locale locale = StringUtils.parseLocaleString(value.toString()); context.setLocale(locale); } else { throw new PaxmlRuntimeException("No locale given!"); } return context.getLocale(); }
From source file:de.berlios.jhelpdesk.web.tools.LocaleCustomResolver.java
public Locale resolveLocale(HttpServletRequest request) { Locale raLocale = (Locale) request.getAttribute("jhd_locale"); if (raLocale != null) { return raLocale; }// w w w . j av a 2 s . co m HttpSession session = request.getSession(); User currentUser = (User) session.getAttribute("user"); if (currentUser != null && currentUser.getUserId() != null) { request.setAttribute("jhd_locale", currentUser.getPreferredLocale()); return currentUser.getPreferredLocale(); } Cookie localeCookie = WebUtils.getCookie(request, "jhd_locale"); if (localeCookie != null) { Locale locale = StringUtils.parseLocaleString(localeCookie.getValue()); if (locale != null) { request.setAttribute("jhd_locale", locale); return locale; } } request.setAttribute("jhd_locale", request.getLocale()); return request.getLocale(); }
From source file:info.jtrac.wicket.JtracSession.java
public void setUser(User user) { this.user = user; if (user.getLocale() == null) { // for downward compatibility, may be null in old JTrac versions user.setLocale(((JtracApplication) getApplication()).getJtrac().getDefaultLocale()); }//from w ww . j av a2s . c om // flip locale only if different from existing if (!getLocale().getDisplayName().equals(user.getLocale())) { setLocale(StringUtils.parseLocaleString(user.getLocale())); } }
From source file:org.jnap.core.mvc.i18n.CompositeLocaleResolver.java
@Override public Locale resolveLocale(HttpServletRequest request) { Locale locale = null;/* w w w . j a v a 2s . c om*/ for (LocaleResolver localeResolver : this.resolvers) { locale = localeResolver.resolveLocale(request); if (locale != null) { break; } } if (locale == null) { locale = defaultLocale != null ? StringUtils.parseLocaleString(defaultLocale) : Locale.getDefault(); } CurrentLocaleHolder.set(locale); return locale; }
From source file:info.jtrac.mail.MailSender.java
public MailSender(Map<String, String> config, MessageSource messageSource, String defaultLocale) { // initialize email sender this.messageSource = messageSource; this.defaultLocale = StringUtils.parseLocaleString(defaultLocale); String mailSessionJndiName = config.get("mail.session.jndiname"); if (StringUtils.hasText(mailSessionJndiName)) { initMailSenderFromJndi(mailSessionJndiName); }/* ww w . j a v a2s . c om*/ if (sender == null) { initMailSenderFromConfig(config); } // if sender is still null the send* methods will not // do anything when called and will just return immediately }
From source file:org.ng200.openolympus.controller.LanguageSwitchController.java
@RequestMapping(value = "/locale", method = RequestMethod.GET) public String switchLanguage(final HttpServletRequest request, final HttpServletResponse response, @RequestParam("name") final String name) { Assertions.resourceExists(name);/*from w w w . j a v a2 s. c om*/ final LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request); localeResolver.setLocale(request, response, StringUtils.parseLocaleString(name)); return "redirect:/"; }
From source file:com.citrix.g2w.webdriver.tests.attendee.registration.RegistrationConfirmationPageWebDriverTests.java
@BeforeMethod public void testSetup() { this.locale = StringUtils.parseLocaleString(this.propertyUtil.getProperty("environment.locale")); }
From source file:MailSender.java
public MailSender(Map<String, String> config, MessageSource messageSource, String defaultLocale) { // initialize email sender this.messageSource = messageSource; this.defaultLocale = StringUtils.parseLocaleString(defaultLocale); String mailSessionJndiName = config.get("mail.session.jndiname"); // major: the initialization of the sender should be done // using a factory, and should be passed as an argument // to the constructor, the mail sender should not be aware // of the logic of the creation of the sender. if (StringUtils.hasText(mailSessionJndiName)) { initMailSenderFromJndi(mailSessionJndiName); }/*from w ww.j a v a 2 s .c o m*/ if (sender == null) { initMailSenderFromConfig(config); } // if sender is still null the send* methods will not // do anything when called and will just return immediately String tempUrl = config.get("jtrac.url.base"); if (tempUrl == null) { tempUrl = "http://localhost/jtrac/"; } if (!tempUrl.endsWith("/")) { tempUrl = tempUrl + "/"; } this.url = tempUrl; logger.info("email hyperlink base url set to '" + this.url + "'"); }