當前位置: 首頁>>代碼示例>>Java>>正文


Java Locale.getDisplayCountry方法代碼示例

本文整理匯總了Java中java.util.Locale.getDisplayCountry方法的典型用法代碼示例。如果您正苦於以下問題:Java Locale.getDisplayCountry方法的具體用法?Java Locale.getDisplayCountry怎麽用?Java Locale.getDisplayCountry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Locale的用法示例。


在下文中一共展示了Locale.getDisplayCountry方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: summarizeLocale

import java.util.Locale; //導入方法依賴的package包/類
private String summarizeLocale(final Locale locale, final String localeAndroidCode) {
    String country = locale.getDisplayCountry(locale);
    String language = locale.getDisplayLanguage(locale);
    String ret = locale.getDisplayLanguage(Locale.ENGLISH)
            + " (" + language.substring(0, 1).toUpperCase(Locale.getDefault()) + language.substring(1)
            + ((!country.isEmpty() && !country.toLowerCase(Locale.getDefault()).equals(language.toLowerCase(Locale.getDefault()))) ? (", " + country) : "")
            + ")";

    if (localeAndroidCode.equals("zh-rCN")) {
        ret = ret.substring(0, ret.indexOf(" ") + 1) + "Simplified" + ret.substring(ret.indexOf(" "));
    } else if (localeAndroidCode.equals("zh-rTW")) {
        ret = ret.substring(0, ret.indexOf(" ") + 1) + "Traditional" + ret.substring(ret.indexOf(" "));
    }

    return ret;
}
 
開發者ID:gsantner,項目名稱:markor,代碼行數:17,代碼來源:LanguagePreferenceCompat.java

示例2: initIso3Locales

import java.util.Locale; //導入方法依賴的package包/類
private static void initIso3Locales() {
    filteredIso3Locales = new HashMap<>();
    for (Locale locale : LOCALES) {
        final String country = locale.getDisplayCountry();
        if (country.length() == 0)
            continue;
        final String iso3Locale;
        try {
            iso3Locale = locale.getISO3Country();
        } catch (MissingResourceException mre) {
            continue;
        }
        filteredIso3Locales.put(iso3Locale, country);
    }
    filteredIso3Locales = sortHashMapByValues(filteredIso3Locales);
}
 
開發者ID:GrenderG,項目名稱:Protestr,代碼行數:17,代碼來源:LocaleUtils.java

示例3: CountryList

import java.util.Locale; //導入方法依賴的package包/類
public CountryList() {
    // A collection to store our country object
    this.countries = new ArrayList<String>();

    // Get ISO countries, create Country object and
    // store in the collection.
    String[] isoCountries = Locale.getISOCountries();
    for (String country : isoCountries) {
        Locale locale = new Locale("en", country);
        String name = locale.getDisplayCountry();

        if (!"".equals(name)) {
            this.countries.add(name);
        }
    }
    this.countryListSize = countries.size();
    this.random = new Random();
}
 
開發者ID:couchbaselabs,項目名稱:GitTalent,代碼行數:19,代碼來源:CountryList.java

示例4: initializeCountryPicker

import java.util.Locale; //導入方法依賴的package包/類
/**
 * Initializes the country picker with a list of all valid world countries, as obtained by the
 * Java locale class.
 */
private void initializeCountryPicker() {
    countries = FXCollections.observableArrayList();
    Locale[] locales = Locale.getAvailableLocales();
    for (Locale locale : locales) {
        String name = locale.getDisplayCountry();
        if (!countries.contains(name)) {
            countries.add(name);
        }
    }
    FXCollections.sort(countries);
    countryPicker.setItems(countries);
}
 
開發者ID:maillouxc,項目名稱:git-rekt,代碼行數:17,代碼來源:PlaceBookingScreenController.java

示例5: Country

import java.util.Locale; //導入方法依賴的package包/類
public Country(String code, String name, String dialCode, int flag) {
    this.code = code;
    Locale locale = new Locale("", code);
    this.name = (locale.getDisplayCountry() == null || name == " World Wide") ? " World Wide" : locale.getDisplayCountry(); //name;
    this.dialCode = dialCode;
    this.flag = flag;
}
 
開發者ID:AppHero2,項目名稱:Raffler-Android,代碼行數:8,代碼來源:Country.java

示例6: checkCountryCurrency

import java.util.Locale; //導入方法依賴的package包/類
static void checkCountryCurrency(String countryCode, String expected) {
    Locale locale = new Locale("", countryCode);
    Currency currency = Currency.getInstance(locale);
    String code = (currency != null) ? currency.getCurrencyCode() : null;
    if (!(expected == null ? code == null : expected.equals(code))) {
        throw new RuntimeException("Wrong currency for " +
                locale.getDisplayCountry() +
                ": expected " + expected + ", got " + code);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:CurrencyTest.java

示例7: buildName

import java.util.Locale; //導入方法依賴的package包/類
private String buildName(Locale locale) {
	StringBuilder sName = new StringBuilder();

	String sName1 = locale.getDisplayLanguage(locale);
	String sName2 = locale.getDisplayLanguage();
	sName.append(sName1);

	if (!sName1.equals(sName2)) {
		sName.append("/").append(sName2);
	}

	sName1 = locale.getDisplayCountry(locale);
	sName2 = locale.getDisplayCountry();
	if (sName1.length() > 0 || sName2.length() > 0) {
		sName.append(" (");
		if (sName1.length() > 0)
			sName.append(sName1);

		if (sName2.length() > 0 && !sName1.equals(sName2)) {
			sName.append("/").append(sName2);
		}

		sName1 = locale.getDisplayVariant(locale);
		sName2 = locale.getDisplayVariant();
		if (sName1.length() > 0 || sName2.length() > 0) {
			sName.append(", ");
			if (sName1.length() > 0)
				sName.append(sName1);

			if (sName2.length() > 0 && !sName1.equals(sName2)) {
				sName.append("/").append(sName2);
			}
		}

		sName.append(")");
	}

	return sName.toString();
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:40,代碼來源:LanguagePanel.java

示例8: summarizeLocale

import java.util.Locale; //導入方法依賴的package包/類
private String summarizeLocale(Locale locale) {
    String country = locale.getDisplayCountry(locale);
    String language = locale.getDisplayLanguage(locale);
    return locale.getDisplayLanguage(Locale.ENGLISH)
            + " (" + language.substring(0, 1).toUpperCase(Locale.getDefault()) + language.substring(1)
            + ((!country.isEmpty() && !country.toLowerCase(Locale.getDefault()).equals(language.toLowerCase(Locale.getDefault()))) ? (", " + country) : "")
            + ")";
}
 
開發者ID:gsantner,項目名稱:memetastic,代碼行數:9,代碼來源:LanguagePreferenceCompat.java

示例9: CountryPath

import java.util.Locale; //導入方法依賴的package包/類
public CountryPath(final String NAME, final String CONTENT) {
    super();
    name    = NAME;
    locale  = new Locale("", NAME);
    tooltip = new Tooltip(locale.getDisplayCountry());
    Tooltip.install(CountryPath.this, tooltip);
    if (null == CONTENT) return;
    setContent(CONTENT);
}
 
開發者ID:HanSolo,項目名稱:charts,代碼行數:10,代碼來源:CountryPath.java

示例10: doTestDisplayNames

import java.util.Locale; //導入方法依賴的package包/類
private void doTestDisplayNames(Locale inLocale, int compareIndex, boolean defaultIsFrench) {
    if (defaultIsFrench && !Locale.getDefault().getLanguage().equals("fr"))
        errln("Default locale should be French, but it's really " + Locale.getDefault().getLanguage());
    else if (!defaultIsFrench && !Locale.getDefault().getLanguage().equals("en"))
        errln("Default locale should be English, but it's really " + Locale.getDefault().getLanguage());

    for (int i = 0; i <= MAX_LOCALES; i++) {
        Locale testLocale = new Locale(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
        logln("  Testing " + testLocale + "...");

        String  testLang;
        String  testCtry;
        String  testVar;
        String  testName;

        if (inLocale == null) {
            testLang = testLocale.getDisplayLanguage();
            testCtry = testLocale.getDisplayCountry();
            testVar = testLocale.getDisplayVariant();
            testName = testLocale.getDisplayName();
        }
        else {
            testLang = testLocale.getDisplayLanguage(inLocale);
            testCtry = testLocale.getDisplayCountry(inLocale);
            testVar = testLocale.getDisplayVariant(inLocale);
            testName = testLocale.getDisplayName(inLocale);
        }

        String  expectedLang;
        String  expectedCtry;
        String  expectedVar;
        String  expectedName;

        expectedLang = dataTable[compareIndex][i];
        if (expectedLang.equals("") && defaultIsFrench)
            expectedLang = dataTable[DLANG_EN][i];
        if (expectedLang.equals(""))
            expectedLang = dataTable[DLANG_ROOT][i];

        expectedCtry = dataTable[compareIndex + 1][i];
        if (expectedCtry.equals("") && defaultIsFrench)
            expectedCtry = dataTable[DCTRY_EN][i];
        if (expectedCtry.equals(""))
            expectedCtry = dataTable[DCTRY_ROOT][i];

        expectedVar = dataTable[compareIndex + 2][i];
        if (expectedVar.equals("") && defaultIsFrench)
            expectedVar = dataTable[DVAR_EN][i];
        if (expectedVar.equals(""))
            expectedVar = dataTable[DVAR_ROOT][i];

        expectedName = dataTable[compareIndex + 3][i];
        if (expectedName.equals("") && defaultIsFrench)
            expectedName = dataTable[DNAME_EN][i];
        if (expectedName.equals(""))
            expectedName = dataTable[DNAME_ROOT][i];

        if (!testLang.equals(expectedLang))
            errln("Display language mismatch: " + testLang + " versus " + expectedLang);
        if (!testCtry.equals(expectedCtry))
            errln("Display country mismatch: " + testCtry + " versus " + expectedCtry);
        if (!testVar.equals(expectedVar))
            errln("Display variant mismatch: " + testVar + " versus " + expectedVar);
        if (!testName.equals(expectedName))
            errln("Display name mismatch: " + testName + " versus " + expectedName);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:68,代碼來源:LocaleTest.java

示例11: testTZ

import java.util.Locale; //導入方法依賴的package包/類
/**
* Compares the english timezone name and timezone name in specified locale
* @param timeZoneName - name of the timezone to compare
* @param locale - locale to test against english
* @return empty string when passed, descriptive error message in other cases
*/
private static String testTZ(String timeZoneName, Locale locale) {
    StringBuffer timeZoneResult = new StringBuffer("");
    TimeZone tz = TimeZone.getTimeZone(timeZoneName);
    sdfEn.setTimeZone(tz);
    sdfEnShort.setTimeZone(tz);
    sdfLoc.setTimeZone(tz);
    sdfLocShort.setTimeZone(tz);

    String en, enShort, loc, locShort;
    en = sdfEn.format(date);
    enShort = sdfEnShort.format(date);
    loc = sdfLoc.format(date);
    locShort = sdfLocShort.format(date);

    String displayLanguage = locale.getDisplayLanguage();
    String displayCountry = locale.getDisplayCountry();

    if (loc.equals(en)) {
        timeZoneResult.append("[");
        timeZoneResult.append(displayLanguage);
        if (!"".equals(displayCountry)) {
            timeZoneResult.append(" ");
            timeZoneResult.append(displayCountry);
        }
        timeZoneResult.append("] timezone \"");
        timeZoneResult.append(timeZoneName);
        timeZoneResult.append("\" long name \"" + en);
        timeZoneResult.append("\" not localized!\n");
    }

    if (!locShort.equals(enShort)) {
        timeZoneResult.append("[");
        timeZoneResult.append(displayLanguage);
        if (!"".equals(displayCountry)) {
            timeZoneResult.append(" ");
            timeZoneResult.append(displayCountry);
        }
        timeZoneResult.append("] timezone \"");
        timeZoneResult.append(timeZoneName);
        timeZoneResult.append("\" short name \"" + enShort);
        timeZoneResult.append("\" is localized \"");
        timeZoneResult.append(locShort);
        timeZoneResult.append("\"!\n");
    }
    return timeZoneResult.toString();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:53,代碼來源:Bug4640234.java

示例12: checkCountry

import java.util.Locale; //導入方法依賴的package包/類
private static void checkCountry(Locale country, String expected) {
    String actual = country.getDisplayCountry();
    if (!expected.equals(actual)) {
        throw new RuntimeException();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:HongKong.java

示例13: doTestDisplayNames

import java.util.Locale; //導入方法依賴的package包/類
private void doTestDisplayNames(Locale inLocale, int compareIndex, boolean defaultIsFrench) {
    String language = Locale.getDefault().getLanguage();

    if (defaultIsFrench && !language.equals("fr")) {
        errln("Default locale should be French, but it's really " + language);
    } else if (!defaultIsFrench && !language.equals("en")) {
        errln("Default locale should be English, but it's really " + language);
    }

    for (int i = 0; i <= MAX_LOCALES; i++) {
        Locale testLocale = new Locale(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
        logln("  Testing " + testLocale + "...");

        String testLang;
        String testCtry;
        String testVar;
        String testName;

        if (inLocale == null) {
            testLang = testLocale.getDisplayLanguage();
            testCtry = testLocale.getDisplayCountry();
            testVar = testLocale.getDisplayVariant();
            testName = testLocale.getDisplayName();
        } else {
            testLang = testLocale.getDisplayLanguage(inLocale);
            testCtry = testLocale.getDisplayCountry(inLocale);
            testVar = testLocale.getDisplayVariant(inLocale);
            testName = testLocale.getDisplayName(inLocale);
        }

        String expectedLang;
        String expectedCtry;
        String expectedVar;
        String expectedName;

        expectedLang = dataTable[compareIndex][i];
        if (expectedLang.equals("") && defaultIsFrench) {
            expectedLang = dataTable[DLANG_EN][i];
        }
        if (expectedLang.equals("")) {
            expectedLang = dataTable[DLANG_ROOT][i];
        }

        expectedCtry = dataTable[compareIndex + 1][i];
        if (expectedCtry.equals("") && defaultIsFrench) {
            expectedCtry = dataTable[DCTRY_EN][i];
        }
        if (expectedCtry.equals("")) {
            expectedCtry = dataTable[DCTRY_ROOT][i];
        }

        expectedVar = dataTable[compareIndex + 2][i];
        if (expectedVar.equals("") && defaultIsFrench) {
            expectedVar = dataTable[DVAR_EN][i];
        }
        if (expectedVar.equals("")) {
            expectedVar = dataTable[DVAR_ROOT][i];
        }

        expectedName = dataTable[compareIndex + 3][i];
        if (expectedName.equals("") && defaultIsFrench) {
            expectedName = dataTable[DNAME_EN][i];
        }
        if (expectedName.equals("")) {
            expectedName = dataTable[DNAME_ROOT][i];
        }

        if (!testLang.equals(expectedLang)) {
            errln("Display language mismatch: " + testLang + " versus " + expectedLang);
        }
        if (!testCtry.equals(expectedCtry)) {
            errln("Display country mismatch: " + testCtry + " versus " + expectedCtry);
        }
        if (!testVar.equals(expectedVar)) {
            errln("Display variant mismatch: " + testVar + " versus " + expectedVar);
        }
        if (!testName.equals(expectedName)) {
            errln("Display name mismatch: " + testName + " versus " + expectedName);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:82,代碼來源:LocaleTest.java


注:本文中的java.util.Locale.getDisplayCountry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。