List of usage examples for java.util Locale Locale
public Locale(String language)
From source file:ar.com.zauber.commons.xmpp.message.XMPPMessageTest.java
/** multiples lenguajes */ @Test/*from w w w . j a v a 2 s .c o m*/ public final void testMultiLang() throws Exception { final XMPPMessage c = new XMPPMessage("body", "title"); final Map<Locale, Resource> msgs = new HashMap<Locale, Resource>(); msgs.put(new Locale("es"), new StringResource("hola!")); msgs.put(Locale.ITALIAN, new StringResource("pronto!")); c.setLangBodies(msgs); org.jivesoftware.smack.packet.Message m = c.getXMPPMessage("juan"); m.setPacketID("0"); Assert.assertEquals(getResult("multilang.xml"), m.toXML()); }
From source file:com.logicaalternativa.ejemplomock.rest.sender.SendMailCodePromotionImpTest.java
@Before public void setUp() throws Exception { email = "test@test.dum"; nameUser = "User Name"; locale = new Locale("es"); promotionCode = new PromotionCode(); promotionCode.setEmail(email);/* w w w . jav a2s . c o m*/ promotionCode.setNameUser(nameUser); promotionCode.setCode("aaa"); promotionCodeRepositoryMock = new PromotionCodeRepositoryMock(); promotionCodeRepositoryMock.setPromotionCode(promotionCode); javaMailServerMock = new JavaMailServerMock(); messageSourceMock = new MessageSourceMock(); sendMailCodePromotionImp = new SendMailCodePromotionImp(); sendMailCodePromotionImp.setFrom("EjemoploMock <noreply@ejemplomock.dummys>"); sendMailCodePromotionImp.setJavaMailSender(javaMailServerMock); sendMailCodePromotionImp.setPromotionCodeRepository(promotionCodeRepositoryMock); sendMailCodePromotionImp.setMessageSource(messageSourceMock); }
From source file:rashjz.info.com.az.config.SpringWebConfig.java
@Bean public LocaleResolver localeResolver() { CookieLocaleResolver resolver = new CookieLocaleResolver(); resolver.setDefaultLocale(new Locale("en")); resolver.setCookieName("myLocaleCookie"); resolver.setCookieMaxAge(4800);//from w w w . j a va 2 s . c o m return resolver; }
From source file:com.bluexml.side.framework.alfresco.shareLanguagePicker.MyLocalResolver.java
public Locale resolveLocale(HttpServletRequest request) { HttpSession session = request.getSession(); logger.debug("[resolveLocale] ..."); logger.debug("[resolveLocale] session Id :" + session.getId()); Locale l = null;// w w w . j a v a2s. c om RequestContext initRequestContext; try { initRequestContext = RequestContextUtil.initRequestContext(applicationContext, request); String languageFromLayoutParam = LanguageSetter.getLanguageFromLayoutParam(request, initRequestContext); l = new Locale(languageFromLayoutParam); } catch (Exception e) { logger.error("oups " + e.getMessage(), e); e.printStackTrace(); } logger.debug("[resolveLocale] resolveLocale = " + l); if (l == null) { l = Locale.getDefault(); logger.warn("[resolveLocale] back to default (local is null)= " + l); } setLocale(request, null, l); return l; }
From source file:com.isalnikov.config.MessageTest.java
@Test public void testHelloConfigurer() { System.out.println(messageHelper.getMessage("hello")); System.out.println(messageHelper.getMessage(Locale.CANADA, "hello")); System.out.println(messageHelper.getMessage(Locale.ENGLISH, "hello")); System.out.println(messageHelper.getMessage(new Locale("ru"), "hello")); System.out.println(messageHelper.getMessage(new Locale("ru_RU"), "hello")); }
From source file:org.vaadin.webinars.springandvaadin.i18n.ui.I18nUI.java
@Override protected void init(VaadinRequest request) { setLocale(request.getLocale());//w w w . ja va 2 s . c o m getPage().setTitle(messageSource.getMessage("page.title", null, getLocale())); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); setContent(layout); final TextField textField = new TextField(messageSource.getMessage("textField.caption", null, getLocale())); layout.addComponent(textField); final Button button = new Button(messageSource.getMessage("button.caption", null, getLocale())); button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Notification.show(messageSource.getMessage("greeting.caption", new Object[] { textField.getValue() }, getLocale())); } }); layout.addComponent(button); final Button swe = new Button("P svenska", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { LocaleContextHolder.setLocale(new Locale("sv")); getPage().reload(); } }); layout.addComponent(swe); final Button eng = new Button("In English", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { LocaleContextHolder.setLocale(new Locale("en")); getPage().reload(); } }); layout.addComponent(eng); }
From source file:org.accelerators.activiti.admin.AdminApp.java
@Override public void init() { // Set theme// w w w. j a v a2 s . c o m setTheme(Consts.THEME); // Set default locale setLocale(new Locale("en")); // Init resource bundle final ResourceBundle i18n = ResourceBundle.getBundle(Messages.class.getName(), getLocale()); // Add title mainWindow = new Window(i18n.getString(Messages.AppTitle)); // Set window to full size mainWindow.setSizeFull(); // Set as main window setMainWindow(mainWindow); // Add window to view manager viewManager = new ViewManager(mainWindow); // Create the login screen viewManager.switchScreen(LoginView.class.getName(), new LoginView(this)); }
From source file:bean.Message.java
public String getRelativeTime() { String temp = date;//from w ww.j a v a 2s.c om PrettyTime p = new PrettyTime(new Locale("en")); try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date; date = sdf.parse(temp); temp = p.format(date); //System.out.println(date); //System.out.println(p.format(date)); } catch (ParseException ex) { Logger.getLogger(Message.class.getName()).log(Level.SEVERE, null, ex); return temp; } return temp; }
From source file:at.alladin.rmbt.controlServer.QoSResultResource.java
@Post("json") public String request(final String entity) { addAllowOrigin();//from w w w . j a v a2s .com JSONObject request = null; final ErrorList errorList = new ErrorList(); final JSONObject answer = new JSONObject(); String answerString; System.out.println(MessageFormat.format(labels.getString("NEW_QOS_TESTRESULT_DETAIL"), getIP())); if (entity != null && !entity.isEmpty()) // try parse the string to a JSON object try { request = new JSONObject(entity); String lang = request.optString("language"); // Load Language Files for Client final List<String> langs = Arrays .asList(settings.getString("RMBT_SUPPORTED_LANGUAGES").split(",\\s*")); if (langs.contains(lang)) { errorList.setLanguage(lang); labels = (PropertyResourceBundle) ResourceBundle.getBundle("at.alladin.rmbt.res.SystemMessages", new Locale(lang)); } else lang = settings.getString("RMBT_DEFAULT_LANGUAGE"); if (conn != null) { final String testUuid = request.optString("test_uuid"); long ts = System.nanoTime(); QoSUtil.evaluate(settings, conn, new TestUuid(testUuid, UuidType.TEST_UUID), answer, lang, errorList); long endTs = System.nanoTime() - ts; answer.put("evaluation", "Time needed to evaluate test result: " + ((float) endTs / 1000000f) + " ms"); } else { errorList.addError("ERROR_DB_CONNECTION"); } } catch (final JSONException e) { errorList.addError("ERROR_REQUEST_JSON"); e.printStackTrace(); } catch (SQLException e) { errorList.addError("ERROR_DB_CONNECTION"); e.printStackTrace(); } catch (HstoreParseException e) { errorList.addErrorString(e.getMessage()); e.printStackTrace(); } catch (IllegalArgumentException e) { errorList.addError("ERROR_REQUEST_JSON"); e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedOperationException e) { e.printStackTrace(); errorList.addError("ERROR_REQUEST_QOS_RESULT_DETAIL_NO_UUID"); } else errorList.addErrorString("Expected request is missing."); try { answer.putOpt("error", errorList.getList()); } catch (final JSONException e) { System.out.println("Error saving ErrorList: " + e.toString()); } answerString = answer.toString(); //System.out.println(answerString); return answerString; }
From source file:marytts.features.FeatureRegistry.java
/** * Get the feature processor manager associated with the given locale, if any. * @param locale//from w w w . jav a2s . co m * @return the feature processor manager, or null if there is no locale-specific * feature processor manager. */ public static FeatureProcessorManager getFeatureProcessorManager(Locale locale) { FeatureProcessorManager m = managersByLocale.get(locale); if (m != null) return m; // Maybe locale is language_COUNTRY, so look up by language also: Locale lang = new Locale(locale.getLanguage()); return managersByLocale.get(lang); }