use of android.icu.text.LocaleDisplayNames in project j2objc by google.
the class ULocaleCollationTest method TestIllformedLocale.
@Test
public void TestIllformedLocale() {
ULocale french = ULocale.FRENCH;
Collator collator = Collator.getInstance(french);
LocaleDisplayNames names = LocaleDisplayNames.getInstance(french, DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU);
for (String malformed : Arrays.asList("en-a", "$", "ü--a", "en--US")) {
try {
Set<ULocale> supported = Collections.singleton(new ULocale(malformed));
names.getUiList(supported, false, collator);
assertNull("Failed to detect bogus locale «" + malformed + "»", supported);
} catch (IllformedLocaleException e) {
logln("Successfully detected ill-formed locale «" + malformed + "»:" + e.getMessage());
}
}
}
use of android.icu.text.LocaleDisplayNames in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RegionSearchPicker method createAdapterItem.
private List<RegionItem> createAdapterItem(Set<String> regionIds) {
final Collator collator = Collator.getInstance(getLocale());
final TreeSet<RegionItem> items = new TreeSet<>(new RegionInfoComparator(collator));
final LocaleDisplayNames localeDisplayNames = LocaleDisplayNames.getInstance(getLocale());
long i = 0;
for (String regionId : regionIds) {
String name = localeDisplayNames.regionDisplayName(regionId);
items.add(new RegionItem(i++, regionId, name));
}
return new ArrayList<>(items);
}
use of android.icu.text.LocaleDisplayNames in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RegionZonePicker method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final LocaleDisplayNames localeDisplayNames = LocaleDisplayNames.getInstance(getLocale());
final String regionId = getArguments() == null ? null : getArguments().getString(EXTRA_REGION_ID);
mRegionName = regionId == null ? null : localeDisplayNames.regionDisplayName(regionId);
}
use of android.icu.text.LocaleDisplayNames in project j2objc by google.
the class TestLocaleNamePackaging method testLocaleDisplayNameWithKeywords.
// test a 'root' locale, with keywords
@Test
public void testLocaleDisplayNameWithKeywords() {
String[] expectedWithLanguageData = { "root (collation=phonebook)", "Root (Phonebook Sort Order)", "ra\u00EDz (orden de list\u00EDn telef\u00F3nico)", "Root (Telefonbuch-Sortierung)", "Root (Phonebook Sort Order)" };
String[] expectedWithoutLanguageData = { "root (collation=phonebook)" };
String[] expected = LocaleDisplayNamesImpl.haveData(LANG) ? expectedWithLanguageData : expectedWithoutLanguageData;
ULocale kl = new ULocale("@collation=phonebook");
int n = 0;
for (ULocale displayLocale : locales) {
LocaleDisplayNames dn = LocaleDisplayNames.getInstance(displayLocale);
String result = dn.localeDisplayName(kl);
assertEquals(kl + " in " + displayLocale, expected[n++], result);
if (n == expected.length) {
n = 0;
}
}
}
use of android.icu.text.LocaleDisplayNames in project j2objc by google.
the class TestLocaleNamePackaging method testLocaleKeywords.
@Test
public void testLocaleKeywords() {
LocaleDisplayNames dn = LocaleDisplayNames.getInstance(ULocale.US, DialectHandling.DIALECT_NAMES);
String name = dn.localeDisplayName("de@collation=phonebook");
String target = LocaleDisplayNamesImpl.haveData(LANG) ? "German (Phonebook Sort Order)" : "de (collation=phonebook)";
assertEquals("collation", target, name);
}
Aggregations