diff --git a/icu4c/source/data/locales/pt.txt b/icu4c/source/data/locales/pt.txt index b3c8e5dce08d..bb63cb7c468d 100644 --- a/icu4c/source/data/locales/pt.txt +++ b/icu4c/source/data/locales/pt.txt @@ -2000,7 +2000,7 @@ pt{ } past{ one{"há {0} segunda-feira"} - other{"{{0} segundas-feiras atrás"} + other{"{0} segundas-feiras atrás"} } } } diff --git a/icu4c/source/i18n/reldatefmt.cpp b/icu4c/source/i18n/reldatefmt.cpp index 0af9b47a1914..1a4da0f0b95c 100644 --- a/icu4c/source/i18n/reldatefmt.cpp +++ b/icu4c/source/i18n/reldatefmt.cpp @@ -605,8 +605,14 @@ static void loadWeekdayNames(UnicodeString absoluteUnits[UDAT_STYLE_COUNT] [UDAT_ABSOLUTE_UNIT_COUNT][UDAT_DIRECTION_COUNT], const char* localeId, UErrorCode& status) { + if (U_FAILURE(status)) { + return; + } Locale locale(localeId); DateFormatSymbols dfSym(locale, status); + if (U_FAILURE(status)) { + return; + } for (int32_t style = 0; style < UDAT_STYLE_COUNT; ++style) { DateFormatSymbols::DtWidthType dtfmtWidth = styleToDateFormatSymbolWidth[style]; int32_t count; @@ -630,6 +636,9 @@ static UBool loadUnitData( RelDateTimeFmtDataSink sink(cacheData); ures_getAllItemsWithFallback(resource, "fields", sink, status); + if (U_FAILURE(status)) { + return false; + } // Get the weekday names from DateFormatSymbols. loadWeekdayNames(cacheData.absoluteUnits, localeId, status); diff --git a/icu4c/source/test/intltest/reldatefmttest.cpp b/icu4c/source/test/intltest/reldatefmttest.cpp index 65969e48e913..4481f420cb8c 100644 --- a/icu4c/source/test/intltest/reldatefmttest.cpp +++ b/icu4c/source/test/intltest/reldatefmttest.cpp @@ -10,8 +10,10 @@ * ******************************************************************************* */ +#include #include #include +#include #include "intltest.h" @@ -765,6 +767,7 @@ class RelativeDateTimeFormatterTest : public IntlTest { void TestBadDisplayContext(); void TestFormat(); void TestFormatNumeric(); + void TestLocales(); void RunTest( const Locale& locale, const WithQuantityExpected* expectedResults, @@ -854,6 +857,7 @@ void RelativeDateTimeFormatterTest::runIndexedTest( TESTCASE_AUTO(TestSidewaysDataLoading); TESTCASE_AUTO(TestFormat); TESTCASE_AUTO(TestFormatNumeric); + TESTCASE_AUTO(TestLocales); TESTCASE_AUTO_END; } @@ -1296,6 +1300,19 @@ void RelativeDateTimeFormatterTest::TestFormat() { RunTest("en", kEnglishFormat, UPRV_LENGTHOF(kEnglishFormat), false); } +void RelativeDateTimeFormatterTest::TestLocales() { + int32_t numLocales = 0; + const Locale *availableLocales = Locale::getAvailableLocales(numLocales); + std::vector> allFormatters; + for (int localeIdx=0; localeIdx rdtf(new RelativeDateTimeFormatter(loc, status)); + allFormatters.push_back(std::move(rdtf)); + assertSuccess(loc.getName(), status); + } +} + static const char *kLast2 = "Last_2"; static const char *kLast = "Last"; static const char *kThis = "This"; diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/RelativeDateTimeFormatter.java b/icu4j/main/classes/core/src/com/ibm/icu/text/RelativeDateTimeFormatter.java index df61c8498158..6e90d417d365 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/RelativeDateTimeFormatter.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/RelativeDateTimeFormatter.java @@ -970,9 +970,9 @@ private static final DateTimeUnit orNullFromString(CharSequence keyword) { } EnumMap>> qualitativeUnitMap = - new EnumMap>>(Style.class); + new EnumMap<>(Style.class); EnumMap> styleRelUnitPatterns = - new EnumMap>(Style.class); + new EnumMap<>(Style.class); StringBuilder sb = new StringBuilder(); @@ -1023,7 +1023,7 @@ public void consumeTableRelative(UResource.Key key, UResource.Value value) { // Handle Zero seconds for "now". EnumMap unitStrings = absMap.get(AbsoluteUnit.NOW); if (unitStrings == null) { - unitStrings = new EnumMap(Direction.class); + unitStrings = new EnumMap<>(Direction.class); absMap.put(AbsoluteUnit.NOW, unitStrings); } if (unitStrings.get(Direction.PLAIN) == null) { @@ -1042,12 +1042,12 @@ public void consumeTableRelative(UResource.Key key, UResource.Value value) { } if (absMap == null) { - absMap = new EnumMap>(AbsoluteUnit.class); + absMap = new EnumMap<>(AbsoluteUnit.class); qualitativeUnitMap.put(style, absMap); } EnumMap dirMap = absMap.get(absUnit); if (dirMap == null) { - dirMap = new EnumMap(Direction.class); + dirMap = new EnumMap<>(Direction.class); absMap.put(absUnit, dirMap); } if (dirMap.get(keyDirection) == null) { @@ -1082,7 +1082,7 @@ public void consumeTimeDetail(UResource.Key key, UResource.Value value) { EnumMap unitPatterns = styleRelUnitPatterns.get(style); if (unitPatterns == null) { - unitPatterns = new EnumMap(RelativeUnit.class); + unitPatterns = new EnumMap<>(RelativeUnit.class); styleRelUnitPatterns.put(style, unitPatterns); } String[][] patterns = unitPatterns.get(unit.relUnit); @@ -1112,12 +1112,12 @@ private void handlePlainDirection(UResource.Key key, UResource.Value value) { EnumMap> unitMap = qualitativeUnitMap.get(style); if (unitMap == null) { - unitMap = new EnumMap>(AbsoluteUnit.class); + unitMap = new EnumMap<>(AbsoluteUnit.class); qualitativeUnitMap.put(style, unitMap); } EnumMap dirMap = unitMap.get(absUnit); if (dirMap == null) { - dirMap = new EnumMap(Direction.class); + dirMap = new EnumMap<>(Direction.class); unitMap.put(absUnit, dirMap); } if (dirMap.get(Direction.PLAIN) == null) { diff --git a/icu4j/main/shared/data/icudata.jar b/icu4j/main/shared/data/icudata.jar index 57a2a8608bfd..2d6f0c14375b 100644 --- a/icu4j/main/shared/data/icudata.jar +++ b/icu4j/main/shared/data/icudata.jar @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:605d9be70f081c26ec0c632d4a73a121a2c80f8b5cc1d8da265458264c5474e1 -size 12683589 +oid sha256:7000d5c698e9d3ec24a866694d719a51cbfe4929220c1c3043f4405eeb33f288 +size 12683583 diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RelativeDateTimeFormatterTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RelativeDateTimeFormatterTest.java index 7abe32a61525..5e1866721979 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RelativeDateTimeFormatterTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/RelativeDateTimeFormatterTest.java @@ -973,4 +973,13 @@ public void TestSidewaysDataLoading() { String w = fmt.format(6.0, Direction.NEXT, RelativeUnit.QUARTERS); assertEquals("narrow: in 6 qtr", "in 6 qtr", w); } + +@Test +public void TestLocales() { + ULocale[] availableLocales = ULocale.getAvailableLocales(); + for (ULocale loc: availableLocales) { + RelativeDateTimeFormatter.getInstance(loc); + } +} + }