Search in sources :

Example 71 with LocaleData

use of libcore.icu.LocaleData in project j2objc by google.

the class LocaleDataTest method test_ru_RU.

public void test_ru_RU() throws Exception {
    // Russian locale strings updated in macOS 10.12 to match iOS.
    if (!EnvironmentUtil.onMacOSX() || EnvironmentUtil.onMinimumOSVersion("10.12")) {
        final Locale locale = new Locale("ru", "RU");
        LocaleData l = LocaleData.get(locale);
        assertEquals("воскресенье", l.longWeekdayNames[1]);
        // j2objc: iOS 12.2's CLDR returns initially capitalized names.
        assertEquals("вс", l.shortWeekdayNames[1].toLowerCase(locale));
        assertEquals("вс", l.tinyWeekdayNames[1].toLowerCase(locale));
        // Russian stand-alone weekday names have no initial capital since CLDR 28/ICU 56.
        assertEquals("воскресенье", l.longStandAloneWeekdayNames[1]);
        // ... but as of iOS 12.2, short standalone names have an initial capital again.
        assertEquals("вс", l.shortStandAloneWeekdayNames[1].toLowerCase(locale));
        assertEquals("В", l.tinyStandAloneWeekdayNames[1]);
    }
}
Also used : Locale(java.util.Locale) LocaleData(libcore.icu.LocaleData)

Example 72 with LocaleData

use of libcore.icu.LocaleData in project j2objc by google.

the class LocaleDataTest method testDecimalFormatSymbols_es.

// http://code.google.com/p/android/issues/detail?id=38844
public void testDecimalFormatSymbols_es() throws Exception {
    LocaleData es = LocaleData.get(new Locale("es"));
    assertEquals(',', es.decimalSeparator);
    assertEquals('.', es.groupingSeparator);
    LocaleData es_419 = LocaleData.get(new Locale("es", "419"));
    assertEquals('.', es_419.decimalSeparator);
    assertEquals(',', es_419.groupingSeparator);
    LocaleData es_US = LocaleData.get(new Locale("es", "US"));
    assertEquals('.', es_US.decimalSeparator);
    assertEquals(',', es_US.groupingSeparator);
    LocaleData es_MX = LocaleData.get(new Locale("es", "MX"));
    assertEquals('.', es_MX.decimalSeparator);
    assertEquals(',', es_MX.groupingSeparator);
    LocaleData es_AR = LocaleData.get(new Locale("es", "AR"));
    assertEquals(',', es_AR.decimalSeparator);
    assertEquals('.', es_AR.groupingSeparator);
}
Also used : Locale(java.util.Locale) LocaleData(libcore.icu.LocaleData)

Example 73 with LocaleData

use of libcore.icu.LocaleData in project robolectric by robolectric.

the class ShadowLocaleData method get.

@Implementation
public static LocaleData get(Locale locale) {
    LocaleData localeData = (LocaleData) Shadow.newInstanceOf(REAL_CLASS_NAME);
    if (locale == null) {
        locale = Locale.getDefault();
    }
    setEnUsLocaleData(localeData);
    return localeData;
}
Also used : LocaleData(libcore.icu.LocaleData) Implementation(org.robolectric.annotation.Implementation)

Example 74 with LocaleData

use of libcore.icu.LocaleData in project robolectric by robolectric.

the class ShadowLocaleDataTest method shouldSupportLocaleEn_US.

@Test
public void shouldSupportLocaleEn_US() throws NoSuchFieldException, IllegalAccessException {
    LocaleData localeData = LocaleData.get(Locale.US);
    assertThat(localeData.amPm).isEqualTo(new String[] { "AM", "PM" });
    assertThat(localeData.eras).isEqualTo(new String[] { "BC", "AD" });
    assertThat(localeData.firstDayOfWeek).isEqualTo(1);
    assertThat(localeData.minimalDaysInFirstWeek).isEqualTo(1);
    assertThat(localeData.longMonthNames).isEqualTo(new String[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" });
    assertThat(localeData.shortMonthNames).isEqualTo(new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" });
    assertThat(localeData.longStandAloneMonthNames).isEqualTo(localeData.longMonthNames);
    assertThat(localeData.shortStandAloneMonthNames).isEqualTo(localeData.shortMonthNames);
    assertThat(localeData.longWeekdayNames).isEqualTo(new String[] { "", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" });
    assertThat(localeData.shortWeekdayNames).isEqualTo(new String[] { "", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" });
    assertThat(localeData.longStandAloneWeekdayNames).isEqualTo(localeData.longWeekdayNames);
    assertThat(localeData.shortStandAloneWeekdayNames).isEqualTo(localeData.shortWeekdayNames);
    assertThat(localeData.fullTimeFormat).isEqualTo("h:mm:ss a zzzz");
    assertThat(localeData.longTimeFormat).isEqualTo("h:mm:ss a z");
    assertThat(localeData.mediumTimeFormat).isEqualTo("h:mm:ss a");
    assertThat(localeData.shortTimeFormat).isEqualTo("h:mm a");
    assertThat(localeData.fullDateFormat).isEqualTo("EEEE, MMMM d, y");
    assertThat(localeData.longDateFormat).isEqualTo("MMMM d, y");
    assertThat(localeData.mediumDateFormat).isEqualTo("MMM d, y");
    assertThat(localeData.shortDateFormat).isEqualTo("M/d/yy");
    assertThat(localeData.zeroDigit).isEqualTo('0');
    assertThat(localeData.decimalSeparator).isEqualTo('.');
    assertThat(localeData.groupingSeparator).isEqualTo(',');
    assertThat(localeData.patternSeparator).isEqualTo(';');
    assertThat(localeData.monetarySeparator).isEqualTo('.');
    assertThat(localeData.exponentSeparator).isEqualTo("E");
    assertThat(localeData.infinity).isEqualTo("∞");
    assertThat(localeData.NaN).isEqualTo("NaN");
    if (getApiLevel() <= R) {
        assertThat((String) ReflectionHelpers.getField(localeData, "currencySymbol")).isEqualTo("$");
        assertThat((String) ReflectionHelpers.getField(localeData, "internationalCurrencySymbol")).isEqualTo("USD");
    }
    assertThat(localeData.numberPattern).isEqualTo("#,##0.###");
    assertThat(localeData.integerPattern).isEqualTo("#,##0");
    assertThat(localeData.currencyPattern).isEqualTo("¤#,##0.00;(¤#,##0.00)");
    assertThat(localeData.percentPattern).isEqualTo("#,##0%");
}
Also used : LocaleData(libcore.icu.LocaleData) Test(org.junit.Test)

Example 75 with LocaleData

use of libcore.icu.LocaleData in project robolectric by robolectric.

the class ShadowLocaleDataTest method shouldSupportLocaleEn_US_since_lollipop.

@Test
@Config(minSdk = LOLLIPOP)
public void shouldSupportLocaleEn_US_since_lollipop() {
    LocaleData localeData = LocaleData.get(Locale.US);
    assertThat(localeData.minusSign).isEqualTo("-");
}
Also used : LocaleData(libcore.icu.LocaleData) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

LocaleData (libcore.icu.LocaleData)78 SpannableStringBuilder (android.text.SpannableStringBuilder)12 Locale (java.util.Locale)11 Test (org.junit.Test)8 Context (android.content.Context)6 Spanned (android.text.Spanned)6 SpannedString (android.text.SpannedString)6 CharacterStyle (android.text.style.CharacterStyle)6 RelativeSizeSpan (android.text.style.RelativeSizeSpan)6 SimpleDateFormat (java.text.SimpleDateFormat)6 Config (org.robolectric.annotation.Config)6 Date (java.util.Date)3 Resources (android.content.res.Resources)1 Implementation (org.robolectric.annotation.Implementation)1