本文整理汇总了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;
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
}
示例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();
}
示例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) : "")
+ ")";
}
示例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);
}
示例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);
}
}
示例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();
}
示例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();
}
}
示例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);
}
}
}