List of usage examples for java.util Locale getCountry
public String getCountry()
From source file:it.av.eatt.web.page.RistoranteEditDataPage.java
private Language getInitialLanguage() throws JackWicketException { Locale locale = Locales.getSupportedLocale(getLocale()); // TODO create a getByLanguage or Country List<Language> langs = languageService.getAll(); Language lang = null;//from w w w. java 2 s. com for (Language language : langs) { if (language.getCountry().equals(locale.getCountry())) { lang = language; } } Assert.notNull(lang); return lang; }
From source file:org.springframework.roo.addon.creator.CreatorOperationsImpl.java
private void installFlagGraphic(final Locale locale, final String packagePath) { boolean success = false; final String countryCode = locale.getCountry().toLowerCase(); // Retrieve the icon file: BufferedInputStream bis = null; ZipInputStream zis = null;/*from w ww . ja va 2 s.c om*/ try { bis = new BufferedInputStream(httpService.openConnection(new URL(iconSetUrl))); zis = new ZipInputStream(bis); ZipEntry entry; final String expectedEntryName = "png/" + countryCode + ".png"; while ((entry = zis.getNextEntry()) != null) { if (entry.getName().equals(expectedEntryName)) { final MutableFile target = fileManager.createFile(pathResolver.getFocusedIdentifier( Path.SRC_MAIN_RESOURCES, packagePath + "/" + countryCode + ".png")); OutputStream outputStream = null; try { outputStream = target.getOutputStream(); IOUtils.copy(zis, outputStream); success = true; } finally { IOUtils.closeQuietly(outputStream); } } } } catch (final IOException e) { throw new IllegalStateException(getErrorMsg(locale.getCountry()), e); } finally { IOUtils.closeQuietly(bis); IOUtils.closeQuietly(zis); } if (!success) { throw new IllegalStateException(getErrorMsg(locale.toString())); } }
From source file:com.haulmont.cuba.core.global.MessageTools.java
/** * @return whether to use a full locale representation, or language only. Returns true if all locales listed * in {@code cuba.availableLocales} app property are language only. *//*from ww w . j a v a2s .com*/ public boolean useLocaleLanguageOnly() { if (useLocaleLanguageOnly == null) { boolean found = false; for (Locale locale : globalConfig.getAvailableLocales().values()) { if (!StringUtils.isEmpty(locale.getCountry()) || !StringUtils.isEmpty(locale.getVariant())) { useLocaleLanguageOnly = false; found = true; break; } } if (!found) useLocaleLanguageOnly = true; } return useLocaleLanguageOnly; }
From source file:com.processpuzzle.internalization.domain.ProcessPuzzleLocale.java
public int compareTo(Object other) { Locale javaLocale = getJavaLocale(); int result = 0; if (other instanceof ProcessPuzzleLocale) { ProcessPuzzleLocale o = (ProcessPuzzleLocale) other; result = new CompareToBuilder().append(javaLocale.getLanguage(), o.getLanguage()) .append(javaLocale.getCountry(), o.getCountry()).append(javaLocale.getVariant(), o.getVariant()) .toComparison();/* ww w . j av a2 s . c o m*/ } return result; }
From source file:com.puppycrawl.tools.checkstyle.CheckerTest.java
@Test public void testCacheFile() throws Exception { final DefaultConfiguration checkConfig = createCheckConfig(HiddenFieldCheck.class); final DefaultConfiguration treeWalkerConfig = createCheckConfig(TreeWalker.class); treeWalkerConfig.addChild(checkConfig); final DefaultConfiguration checkerConfig = new DefaultConfiguration("checkstyleConfig"); checkerConfig.addAttribute("charset", "UTF-8"); checkerConfig.addChild(treeWalkerConfig); checkerConfig.addAttribute("cacheFile", temporaryFolder.newFile().getPath()); final Checker checker = new Checker(); final Locale locale = Locale.ROOT; checker.setLocaleCountry(locale.getCountry()); checker.setLocaleLanguage(locale.getLanguage()); checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader()); checker.configure(checkerConfig);/* www . ja va 2 s. c o m*/ checker.addListener(new BriefUtLogger(stream)); final String pathToEmptyFile = temporaryFolder.newFile("file.java").getPath(); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; verify(checker, pathToEmptyFile, pathToEmptyFile, expected); // one more time to reuse cache verify(checker, pathToEmptyFile, pathToEmptyFile, expected); }
From source file:com.puppycrawl.tools.checkstyle.CheckerTest.java
@Test public void testClearNonexistentCache() throws Exception { final DefaultConfiguration checkConfig = createCheckConfig(HiddenFieldCheck.class); final DefaultConfiguration treeWalkerConfig = createCheckConfig(TreeWalker.class); treeWalkerConfig.addChild(checkConfig); final DefaultConfiguration checkerConfig = new DefaultConfiguration("simpleConfig"); checkerConfig.addAttribute("charset", "UTF-8"); checkerConfig.addChild(treeWalkerConfig); final Checker checker = new Checker(); final Locale locale = Locale.ROOT; checker.setLocaleCountry(locale.getCountry()); checker.setLocaleLanguage(locale.getLanguage()); checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader()); checker.configure(checkerConfig);//w w w . j a v a 2s . co m checker.addListener(new BriefUtLogger(stream)); final String pathToEmptyFile = temporaryFolder.newFile("file.java").getPath(); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; verify(checker, pathToEmptyFile, pathToEmptyFile, expected); checker.clearCache(); // one more time, but cache does not exist verify(checker, pathToEmptyFile, pathToEmptyFile, expected); }
From source file:com.puppycrawl.tools.checkstyle.CheckerTest.java
@Test public void testClearExistingCache() throws Exception { final DefaultConfiguration checkConfig = createCheckConfig(HiddenFieldCheck.class); final DefaultConfiguration treeWalkerConfig = createCheckConfig(TreeWalker.class); treeWalkerConfig.addChild(checkConfig); final DefaultConfiguration checkerConfig = new DefaultConfiguration("myConfig"); checkerConfig.addAttribute("charset", "UTF-8"); checkerConfig.addChild(treeWalkerConfig); checkerConfig.addAttribute("cacheFile", temporaryFolder.newFile().getPath()); final Checker checker = new Checker(); final Locale locale = Locale.ROOT; checker.setLocaleCountry(locale.getCountry()); checker.setLocaleLanguage(locale.getLanguage()); checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader()); checker.configure(checkerConfig);/*from ww w .j a va2 s .c om*/ checker.addListener(new BriefUtLogger(stream)); final String pathToEmptyFile = temporaryFolder.newFile("file.java").getPath(); final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY; verify(checker, pathToEmptyFile, pathToEmptyFile, expected); checker.clearCache(); // one more time, but file that should be audited is not in cache verify(checker, pathToEmptyFile, pathToEmptyFile, expected); }
From source file:com.smartitengineering.util.opensearch.io.impl.dom.OpenSearchDescriptorWriter.java
protected String getLocaleString(Locale language) { if (language == null) { return null; } else {/*from w w w. jav a 2 s. co m*/ StringBuilder localeString = new StringBuilder(""); if (StringUtils.isNotBlank(language.getLanguage())) { localeString.append(language.getLanguage()); if (StringUtils.isNotBlank(language.getCountry())) { localeString.append('-').append(language.getCountry().toLowerCase()); } } return localeString.toString(); } }
From source file:it.av.youeat.web.page.RistoranteEditDataPage.java
private Language getInitialLanguage() throws YoueatException { Locale locale = Locales.getSupportedLocale(getLocale()); // TODO create a getByLanguage or Country List<Language> langs = languageService.getAll(); Language lang = null;// w ww. j a v a 2 s .c om for (Language language : langs) { if (language.getCountry().equals(locale.getCountry())) { lang = language; } } Assert.notNull(lang); return lang; }
From source file:com.haulmont.cuba.core.sys.AbstractMessages.java
private Locale truncateLocale(Locale locale) { if (locale == null || StringUtils.isEmpty(locale.getCountry())) return null; return Locale.forLanguageTag(locale.getLanguage()); }