List of usage examples for java.util Locale Locale
public Locale(String language)
From source file:nz.co.senanque.sandbox.LocaleTest.java
@Test public void testValidate() { Locale locale = new Locale("fr"); Locale.setDefault(locale);/*www .j a v a2 s . co m*/ String t = MessageFormat.format( "chec de l''envoi: label = {0} n''est pas une adresse email valide, a tent = {1}", new Object[] { "aa", "bb" }); assertEquals("chec de l'envoi: label = aa n'est pas une adresse email valide, a tent = bb", t); }
From source file:modelinspector.collectors.WordlistMatchCollector.java
public WordlistMatchCollector(String aName, String aLanguage, boolean aCaseSensitive, int aCutoff, String aFile, String aEncoding) {/*from w ww . j av a2 s . c om*/ name = aName; baseVocabulary = new HashSet<>(); caseSensitive = aCaseSensitive; language = new Locale(aLanguage); cutoff = aCutoff; try (InputStream is = new FileInputStream(aFile)) { LineIterator i = IOUtils.lineIterator(is, aEncoding); while (i.hasNext()) { String[] fields = i.nextLine().split("\t"); if (fields.length > 1 && aCutoff > 0) { if (Integer.valueOf(fields[1]) < aCutoff) { continue; } } String word = aCaseSensitive ? fields[0] : fields[0].toLowerCase(language); baseVocabulary.add(word); } } catch (IOException e) { throw new RuntimeException(e); } originalBaseVocabularySize = baseVocabulary.size(); }
From source file:es.indra.hlf.vaadin.isfar.Application.java
@Bean public LocaleResolver localeResolver() { SessionLocaleResolver slr = new SessionLocaleResolver(); slr.setDefaultLocale(new Locale("es")); return slr;// www . ja va 2s . c om }
From source file:org.echocat.jomon.spring.i18n.LocaleProvider.java
@Override public void afterPropertiesSet() throws Exception { _locales.clear(); _locales.add(new Locale("")); }
From source file:ca.sqlpower.dao.session.LocaleConverter.java
@Override public Locale convertToComplexType(String convertFrom) throws ConversionException { String[] split = convertFrom.split(SEPARATOR); if (split.length == 0 || split[0].length() == 0) throw new ConversionException("All locales must have a language"); if (split.length == 1 || split[1].length() == 0) return new Locale(split[0]); if (split.length == 2 || split[2].length() == 0) return new Locale(split[0], split[1]); return new Locale(split[0], split[1], split[2]); }
From source file:com.gisgraphy.util.DateUtilTest.java
@Test public void testGetInternationalDatePattern() { LocaleContextHolder.setLocale(new Locale("nl")); assertEquals("dd-MMM-yyyy", DateUtil.getDatePattern()); LocaleContextHolder.setLocale(Locale.FRANCE); assertEquals("dd/MM/yyyy", DateUtil.getDatePattern()); LocaleContextHolder.setLocale(Locale.GERMANY); assertEquals("dd.MM.yyyy", DateUtil.getDatePattern()); // non-existant bundle should default to default locale LocaleContextHolder.setLocale(new Locale("fi")); String fiPattern = DateUtil.getDatePattern(); LocaleContextHolder.setLocale(Locale.getDefault()); String defaultPattern = DateUtil.getDatePattern(); assertEquals(defaultPattern, fiPattern); }
From source file:fi.helsinki.opintoni.service.NewsServiceCacheTest.java
@Test public void thatTeacherNewsAreCached() { flammaServer.expectTeacherNews();/* w w w. j a va2 s . c o m*/ List<NewsDto> news = newsService.getTeacherNews(new Locale("fi")); List<NewsDto> cachedNews = newsService.getTeacherNews(new Locale("fi")); assertThat(cachedNews).isSameAs(news); }
From source file:com.hichinaschool.flashcards.anki.ReadText.java
public static void speak(String text, String loc) { int result = mTts.setLanguage(new Locale(loc)); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e(AnkiDroidApp.TAG, "Error loading locale " + loc.toString()); } else {/*from w ww . j a v a2s . c o m*/ if (mTts.isSpeaking()) { sTextQueue.add(new String[] { text, loc }); } else { mTts.speak(mTextToSpeak, TextToSpeech.QUEUE_FLUSH, mTtsParams); } } }
From source file:com.inkubator.hrm.web.converter.PaySalaryComponentConverter.java
@Override public String getAsString(FacesContext context, UIComponent component, Object value) { ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages", new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString())); String messages = StringUtils.EMPTY; Integer data = (Integer) value; if (Objects.equals(data, HRMConstant.PAY_SALARY_COMPONENT_TUNJANGAN)) { messages = resourceBundle.getString("paySalaryComponent.paySalaryComponent_tunjangan"); } else if (Objects.equals(data, HRMConstant.PAY_SALARY_COMPONENT_POTONGAN)) { messages = resourceBundle.getString("paySalaryComponent.paySalaryComponent_potongan"); } else if (Objects.equals(data, HRMConstant.PAY_SALARY_COMPONENT_SUBSIDI)) { messages = resourceBundle.getString("paySalaryComponent.paySalaryComponent_subsidi"); }//from w w w . jav a 2s. c o m return messages; }
From source file:io.selendroid.android.impl.DefaultAndroidEmulatorTests.java
@Test public void testShouldBeAbleToStartEmulator() throws Exception { AndroidEmulator emulator = new DefaultAndroidEmulator("l10n", "X86", "320x480", "16", new File( FileUtils.getUserDirectory(), ".android" + File.separator + "avd" + File.separator + "l10n.avd")); Assert.assertTrue("expecting emulators exists: ", emulator.isEmulatorAlreadyExistent()); Assert.assertFalse("expecting emulator is not yet started: ", emulator.isEmulatorStarted()); emulator.start(new Locale("en_GB"), 5554, null); Assert.assertTrue(emulator.isEmulatorStarted()); emulator.stop();/*from w ww . ja v a 2 s .com*/ Assert.assertFalse(emulator.isEmulatorStarted()); }