当前位置: 首页>>代码示例>>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;未经允许,请勿转载。