Locale getLanguage - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Locale getLanguage method.

This code example shows how to use the following methods:getCountry, getLanguage, getVariant
	 *  
	 * @param locale the locale for which a resource bundle is desired 
	 * @return a <code>List</code> of candidate <code>Locale</code>s for the given <code>locale</code> 
	 * @exception NullPointerException if <code>locale</code> is <code>null</code> */ 
	private static List<Locale> getCandidateLocales (Locale locale) {
		String language = locale.getLanguage();
		String country = locale.getCountry();
		String variant = locale.getVariant();
 
		List<Locale> locales = new ArrayList<Locale>(4);
		if (variant.length() > 0) {
			locales.add(locale);
		} 
		if (country.length() > 0) {
			locales.add((locales.size() == 0) ? locale : new Locale(language, country));
		} 
		if (language.length() > 0) {
			locales.add((locales.size() == 0) ? locale : new Locale(language));
		} 
		locales.add(Locale.ROOT);

7
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage, getVariant
		Assert.notNull(extension, "Extension must not be null");
 
		Resource resource = null;
 
		if (locale != null) {
			String lang = locale.getLanguage();
			String country = locale.getCountry();
			String variant = locale.getVariant();
 
			// Check for file with language, country and variant localization. 
			if (variant.length() > 0) {
				String location =
						name + this.separator + lang + this.separator + country + this.separator + variant + extension;
				resource = this.resourceLoader.getResource(location);
			} 
 
			// Check for file with language and country localization. 
			if ((resource == null || !resource.exists()) && country.length() > 0) {
				String location = name + this.separator + lang + this.separator + country + extension;
				resource = this.resourceLoader.getResource(location);
7
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage, getVariant
		} 
 
		try { 
			Locale locale = (Locale)object;
 
			localeJSONObject.put("country", locale.getCountry());
			localeJSONObject.put("language", locale.getLanguage());
			localeJSONObject.put("variant", locale.getVariant());
		} 
		catch (Exception e) {
			throw new MarshallException( 
				"Unable to put country, language, and variant", e);
		} 
		finally { 
			serializerState.pop();
		} 
 
		return jsonObject;
	} 
 
7
CodeRank
This code example shows how to use the following methods:getLanguage
    if (locale == null) {
      return DEFAULT_LANGUAGE;
    } 
    String language = locale.getLanguage();
    // Special case Chinese 
    if (Locale.SIMPLIFIED_CHINESE.getLanguage().equals(language)) {
      return language + "-r" + getSystemCountry();
    } 
    return language;
  } 
 
  public static String getTranslatedAssetLanguage() {
    String language = getSystemLanguage();
    return TRANSLATED_HELP_ASSET_LANGUAGES.contains(language) ? language : DEFAULT_LANGUAGE;
  } 
 
  private static String doGetTLD(Map<String,String> map, Context context) {
    String tld = map.get(getCountry(context));
    return tld == null ? DEFAULT_TLD : tld;
  } 
7
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage
 
  @Test(dependsOnMethods = { "testDbOpenWithBackSlash" }) 
  public void testChangeLocale() throws IOException { 
    database = new OObjectDatabaseTx(url);
    database.open("admin", "admin");
    database.getStorage().getConfiguration().setLocaleLanguage(Locale.ENGLISH.getLanguage());
    database.getStorage().getConfiguration().setLocaleCountry(Locale.ENGLISH.getCountry());
    database.getStorage().getConfiguration().update();
    database.close();
  } 
 
  @Test(dependsOnMethods = { "testChangeLocale" }) 
  public void testRoles() throws IOException { 
    database = new OObjectDatabaseTx(url);
    database.open("admin", "admin");
    database.query(new OSQLSynchQuery<ORole>("select from ORole where name = 'admin'"));
    database.close();
  } 
 
  @Test(dependsOnMethods = { "testChangeLocale" }) 
7
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage, getVariant
	} 
 
	@AfterClass 
	public static void tearDownClass() { 
		LocaleUtil.setDefault( 
			_defaultLocale.getLanguage(), _defaultLocale.getCountry(),
			_defaultLocale.getVariant());
	} 
 
	@Test
	public void testCustomPortalLocaleAlternateURL() throws Exception {
		testAlternateURL("localhost", null, null, LocaleUtil.SPAIN, "/es"); 
	} 
 
	@Test
	public void testDefaultPortalLocaleAlternateURL() throws Exception {
		testAlternateURL( 
			"localhost", null, null, LocaleUtil.US, StringPool.BLANK); 
	} 
 
7
CodeRank
This code example shows how to use the following methods:getCountry, getDisplayLanguage, getLanguage
	} 
 
	private String _getShortDisplayName(
		Locale locale, Set<String> duplicateLanguages) {
 
		String language = locale.getDisplayLanguage(locale);
 
		if (language.length() > 3) {
			language = locale.getLanguage();
			language = StringUtil.toUpperCase(language);
		} 
 
		String country = locale.getCountry();
 
		return _getDisplayName( 
			language, StringUtil.toUpperCase(country), locale,
			duplicateLanguages);
	} 
 
	private Locale _getSiteDefault() {
6
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage, toString
     * @param locale The locale for which to calculate a character set 
     */ 
    public String getCharset(Locale locale) {
        // Match full language_country_variant first, then language_country,  
        // then language only 
        String charset = map.getProperty(locale.toString());
        if (charset == null) {
            charset = map.getProperty(locale.getLanguage() + "_" 
                    + locale.getCountry());
            if (charset == null) {
                charset = map.getProperty(locale.getLanguage());
            } 
        } 
        return (charset);
    } 
 
     
    /** 
     * The deployment descriptor can have a 
     * locale-encoding-mapping-list element which describes the 
7
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage, getVariant
     * @param locale the message locale to use 
     * @param <T> the bundle type 
     * @return the bundle 
     */ 
    public static <T> T getBundle(Class<T> type, Locale locale) {
        String language = locale.getLanguage();
        String country = locale.getCountry();
        String variant = locale.getVariant();
 
        Class<? extends T> bundleClass = null;
        if (variant != null && variant.length() > 0)
            try { 
                bundleClass = Class.forName(join(type.getName(), "$bundle", language, country, variant), true,
                        type.getClassLoader()).asSubclass(type);
            } catch (ClassNotFoundException e) {
                // ignore 
            } 
        if (bundleClass == null && country != null && country.length() > 0)
            try { 
                bundleClass = Class.forName(join(type.getName(), "$bundle", language, country, null), true,
7
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage, getVariant
	} 
 
	@AfterClass 
	public static void tearDownClass() { 
		LocaleUtil.setDefault( 
			_defaultLocale.getLanguage(), _defaultLocale.getCountry(),
			_defaultLocale.getVariant());
	} 
 
	@Before 
	public void setUp() throws Exception {
		StringBundler sb = new StringBundler();
 
		sb.append("<?xml version='1.0' encoding='UTF-8'?>");
 
		sb.append("<root available-locales=\"en_US,es_ES\" ");
		sb.append("default-locale=\"en_US\">");
		sb.append("<static-content language-id=\"es_ES\">");
		sb.append("foo&amp;bar");
		sb.append("</static-content>");
7
CodeRank

Related Locale getLanguage Questions & Answers:

getLanguage Method Overview
Returns the language code of this Locale.
See Code Examples for other Java 8 Locale Methods: