ICU-7902 TimeUnitFormat uses unlocalized short time units for Greek, icu4j part
X-SVN-Rev: 28871
This commit is contained in:
parent
aa3ebc300a
commit
8f55656334
@ -470,6 +470,18 @@ public class TimeUnitFormat extends MeasureFormat {
|
|||||||
}
|
}
|
||||||
parentLocale=parentLocale.getFallback();
|
parentLocale=parentLocale.getFallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if no unitsShort resource was found even after fallback to root locale
|
||||||
|
// then search the units resource fallback from the current level to root
|
||||||
|
if ( parentLocale == null && resourceKey.equals("unitsShort") ) {
|
||||||
|
searchInTree("units", styl, timeUnit, srcPluralCount, searchPluralCount, countToPatterns);
|
||||||
|
if ( countToPatterns != null &&
|
||||||
|
countToPatterns.get(srcPluralCount) != null &&
|
||||||
|
countToPatterns.get(srcPluralCount)[styl] != null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if not found the pattern for this plural count at all,
|
// if not found the pattern for this plural count at all,
|
||||||
// fall-back to plural count "other"
|
// fall-back to plural count "other"
|
||||||
if ( searchPluralCount.equals("other") ) {
|
if ( searchPluralCount.equals("other") ) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
* Copyright (C) 2009, International Business Machines Corporation and *
|
* Copyright (C) 2008-2010, International Business Machines Corporation and *
|
||||||
* others. All Rights Reserved. *
|
* others. All Rights Reserved. *
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
*/
|
*/
|
||||||
@ -90,6 +90,98 @@ public class TimeUnitTest extends TestFmwk {
|
|||||||
formatParsing(format);
|
formatParsing(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @bug 7902
|
||||||
|
* This tests that requests for short unit names correctly fall back
|
||||||
|
* to long unit names for a locale where the locale data does not
|
||||||
|
* provide short unit names. As of CLDR 1.9, Greek is one such language.
|
||||||
|
*/
|
||||||
|
public void TestGreek() {
|
||||||
|
String[] locales = {"el_GR", "el"};
|
||||||
|
final TimeUnit[] units = TimeUnit.values();
|
||||||
|
int[] styles = new int[] {TimeUnitFormat.FULL_NAME, TimeUnitFormat.ABBREVIATED_NAME};
|
||||||
|
int[] numbers = new int[] {1, 7};
|
||||||
|
|
||||||
|
String[] expected = {"1 \u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03CC\u03BB\u03B5\u03C0\u03C4\u03BF",
|
||||||
|
"1 \u03BB\u03B5\u03C0\u03C4\u03CC",
|
||||||
|
"1 \u03CE\u03C1\u03B1",
|
||||||
|
"1 \u03B7\u03BC\u03AD\u03C1\u03B1",
|
||||||
|
"1 \u03B5\u03B2\u03B4\u03BF\u03BC\u03AC\u03B4\u03B1",
|
||||||
|
"1 \u03BC\u03AE\u03BD\u03B1\u03C2",
|
||||||
|
"1 \u03AD\u03C4\u03BF\u03C2",
|
||||||
|
"1 \u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03CC\u03BB\u03B5\u03C0\u03C4\u03BF",
|
||||||
|
"1 \u03BB\u03B5\u03C0\u03C4\u03CC",
|
||||||
|
"1 \u03CE\u03C1\u03B1",
|
||||||
|
"1 \u03B7\u03BC\u03AD\u03C1\u03B1",
|
||||||
|
"1 \u03B5\u03B2\u03B4\u03BF\u03BC\u03AC\u03B4\u03B1",
|
||||||
|
"1 \u03BC\u03AE\u03BD\u03B1\u03C2",
|
||||||
|
"1 \u03AD\u03C4\u03BF\u03C2",
|
||||||
|
"7 \u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03CC\u03BB\u03B5\u03C0\u03C4\u03B1",
|
||||||
|
"7 \u03BB\u03B5\u03C0\u03C4\u03AC",
|
||||||
|
"7 \u03CE\u03C1\u03B5\u03C2",
|
||||||
|
"7 \u03B7\u03BC\u03AD\u03C1\u03B5\u03C2",
|
||||||
|
"7 \u03B5\u03B2\u03B4\u03BF\u03BC\u03AC\u03B4\u03B5\u03C2",
|
||||||
|
"7 \u03BC\u03AE\u03BD\u03B5\u03C2",
|
||||||
|
"7 \u03AD\u03C4\u03B7",
|
||||||
|
"7 \u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03CC\u03BB\u03B5\u03C0\u03C4\u03B1",
|
||||||
|
"7 \u03BB\u03B5\u03C0\u03C4\u03AC",
|
||||||
|
"7 \u03CE\u03C1\u03B5\u03C2",
|
||||||
|
"7 \u03B7\u03BC\u03AD\u03C1\u03B5\u03C2",
|
||||||
|
"7 \u03B5\u03B2\u03B4\u03BF\u03BC\u03AC\u03B4\u03B5\u03C2",
|
||||||
|
"7 \u03BC\u03AE\u03BD\u03B5\u03C2",
|
||||||
|
"7 \u03AD\u03C4\u03B7",
|
||||||
|
"1 \u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03CC\u03BB\u03B5\u03C0\u03C4\u03BF",
|
||||||
|
"1 \u03BB\u03B5\u03C0\u03C4\u03CC",
|
||||||
|
"1 \u03CE\u03C1\u03B1",
|
||||||
|
"1 \u03B7\u03BC\u03AD\u03C1\u03B1",
|
||||||
|
"1 \u03B5\u03B2\u03B4\u03BF\u03BC\u03AC\u03B4\u03B1",
|
||||||
|
"1 \u03BC\u03AE\u03BD\u03B1\u03C2",
|
||||||
|
"1 \u03AD\u03C4\u03BF\u03C2",
|
||||||
|
"1 \u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03CC\u03BB\u03B5\u03C0\u03C4\u03BF",
|
||||||
|
"1 \u03BB\u03B5\u03C0\u03C4\u03CC",
|
||||||
|
"1 \u03CE\u03C1\u03B1",
|
||||||
|
"1 \u03B7\u03BC\u03AD\u03C1\u03B1",
|
||||||
|
"1 \u03B5\u03B2\u03B4\u03BF\u03BC\u03AC\u03B4\u03B1",
|
||||||
|
"1 \u03BC\u03AE\u03BD\u03B1\u03C2",
|
||||||
|
"1 \u03AD\u03C4\u03BF\u03C2",
|
||||||
|
"7 \u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03CC\u03BB\u03B5\u03C0\u03C4\u03B1",
|
||||||
|
"7 \u03BB\u03B5\u03C0\u03C4\u03AC",
|
||||||
|
"7 \u03CE\u03C1\u03B5\u03C2",
|
||||||
|
"7 \u03B7\u03BC\u03AD\u03C1\u03B5\u03C2",
|
||||||
|
"7 \u03B5\u03B2\u03B4\u03BF\u03BC\u03AC\u03B4\u03B5\u03C2",
|
||||||
|
"7 \u03BC\u03AE\u03BD\u03B5\u03C2",
|
||||||
|
"7 \u03AD\u03C4\u03B7",
|
||||||
|
"7 \u03B4\u03B5\u03C5\u03C4\u03B5\u03C1\u03CC\u03BB\u03B5\u03C0\u03C4\u03B1",
|
||||||
|
"7 \u03BB\u03B5\u03C0\u03C4\u03AC",
|
||||||
|
"7 \u03CE\u03C1\u03B5\u03C2",
|
||||||
|
"7 \u03B7\u03BC\u03AD\u03C1\u03B5\u03C2",
|
||||||
|
"7 \u03B5\u03B2\u03B4\u03BF\u03BC\u03AC\u03B4\u03B5\u03C2",
|
||||||
|
"7 \u03BC\u03AE\u03BD\u03B5\u03C2",
|
||||||
|
"7 \u03AD\u03C4\u03B7"};
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
|
TimeUnitFormat timeUnitFormat;
|
||||||
|
TimeUnitAmount timeUnitAmount;
|
||||||
|
String formatted;
|
||||||
|
|
||||||
|
for ( int locIndex = 0; locIndex < locales.length; ++locIndex ) {
|
||||||
|
for( int numIndex = 0; numIndex < numbers.length; ++numIndex ) {
|
||||||
|
for ( int styleIndex = 0; styleIndex < styles.length; ++styleIndex ) {
|
||||||
|
for ( int unitIndex = 0; unitIndex < units.length; ++unitIndex ) {
|
||||||
|
|
||||||
|
timeUnitAmount = new TimeUnitAmount(numbers[numIndex], units[unitIndex]);
|
||||||
|
timeUnitFormat = new TimeUnitFormat(new ULocale(locales[locIndex]), styles[styleIndex]);
|
||||||
|
formatted = timeUnitFormat.format(timeUnitAmount);
|
||||||
|
|
||||||
|
assertEquals("formatted time string is not expected, locale: " + locales[locIndex] +
|
||||||
|
" style: " + styles[styleIndex] + " units: " + units[unitIndex], expected[counter], formatted);
|
||||||
|
++counter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void formatParsing(TimeUnitFormat format) {
|
private void formatParsing(TimeUnitFormat format) {
|
||||||
final TimeUnit[] values = TimeUnit.values();
|
final TimeUnit[] values = TimeUnit.values();
|
||||||
for (int j = 0; j < values.length; ++j) {
|
for (int j = 0; j < values.length; ++j) {
|
||||||
|
Loading…
Reference in New Issue
Block a user