Skip to content

Commit

Permalink
CLDR-13523 add test for valid short day length; fix resulting data er…
Browse files Browse the repository at this point in the history
…rs (#3739)
  • Loading branch information
pedberg-icu authored May 22, 2024
1 parent 4bfec42 commit 9b13676
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 30 deletions.
14 changes: 7 additions & 7 deletions common/main/fil.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2246,13 +2246,13 @@ Warnings: All cp values have U+FE0F characters removed. See /annotationsDerived/
<day type="sat">↑↑↑</day>
</dayWidth>
<dayWidth type="narrow">
<day type="sun">Lin</day>
<day type="mon">Lun</day>
<day type="tue">Mar</day>
<day type="wed">Miy</day>
<day type="thu">Huw</day>
<day type="fri">Biy</day>
<day type="sat">Sab</day>
<day type="sun">Li</day>
<day type="mon">Lu</day>
<day type="tue">Ma</day>
<day type="wed">Mi</day>
<day type="thu">Hu</day>
<day type="fri">Bi</day>
<day type="sat">Sa</day>
</dayWidth>
<dayWidth type="short">
<day type="sun">↑↑↑</day>
Expand Down
2 changes: 1 addition & 1 deletion common/main/mai.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ CLDR data files are interpreted according to the LDML specification (http://unic
<day type="mon">↑↑↑</day>
<day type="tue">↑↑↑</day>
<day type="wed">↑↑↑</day>
<day type="thu">बृहस्पति</day>
<day type="thu">↑↑↑</day>
<day type="fri">↑↑↑</day>
<day type="sat">↑↑↑</day>
</dayWidth>
Expand Down
28 changes: 14 additions & 14 deletions common/main/mgo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ CLDR data files are interpreted according to the LDML specification (http://unic
<day type="sat">↑↑↑</day>
</dayWidth>
<dayWidth type="short">
<day type="sun">1</day>
<day type="mon">2</day>
<day type="tue">3</day>
<day type="wed">4</day>
<day type="thu">5</day>
<day type="fri">6</day>
<day type="sat">7</day>
<day type="sun">A1</day>
<day type="mon">A2</day>
<day type="tue">A3</day>
<day type="wed">A4</day>
<day type="thu">A5</day>
<day type="fri">A6</day>
<day type="sat">A7</day>
</dayWidth>
<dayWidth type="wide">
<day type="sun">Aneg 1</day>
Expand All @@ -250,13 +250,13 @@ CLDR data files are interpreted according to the LDML specification (http://unic
<day type="sat">↑↑↑</day>
</dayWidth>
<dayWidth type="narrow">
<day type="sun">A1</day>
<day type="mon">A2</day>
<day type="tue">A3</day>
<day type="wed">A4</day>
<day type="thu">A5</day>
<day type="fri">A6</day>
<day type="sat">A7</day>
<day type="sun">1</day>
<day type="mon">2</day>
<day type="tue">3</day>
<day type="wed">4</day>
<day type="thu">5</day>
<day type="fri">6</day>
<day type="sat">7</day>
</dayWidth>
<dayWidth type="short">
<day type="sun">↑↑↑</day>
Expand Down
14 changes: 7 additions & 7 deletions common/main/sa.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,13 @@ CLDR data files are interpreted according to the LDML specification (http://unic
<day type="sat">↑↑↑</day>
</dayWidth>
<dayWidth type="short">
<day type="sun">Sun</day>
<day type="mon">Mon</day>
<day type="tue">Tue</day>
<day type="wed">Wed</day>
<day type="thu">Thu</day>
<day type="fri">Fri</day>
<day type="sat">Sat</day>
<day type="sun">↑↑↑</day>
<day type="mon">↑↑↑</day>
<day type="tue">↑↑↑</day>
<day type="wed">↑↑↑</day>
<day type="thu">↑↑↑</day>
<day type="fri">↑↑↑</day>
<day type="sat">↑↑↑</day>
</dayWidth>
<dayWidth type="wide">
<day type="sun">रविवासरः</day>
Expand Down
2 changes: 1 addition & 1 deletion common/main/so.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3363,7 +3363,7 @@ CLDR data files are interpreted according to the LDML specification (http://unic
<day type="sun">↑↑↑</day>
<day type="mon">↑↑↑</day>
<day type="tue">↑↑↑</day>
<day type="wed">Arbaco</day>
<day type="wed">↑↑↑</day>
<day type="thu">↑↑↑</day>
<day type="fri">↑↑↑</day>
<day type="sat">↑↑↑</day>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,7 @@ public enum Subtype {
missingLanguage,
namePlaceholderProblem,
missingSpaceBetweenNameFields,
shortDateFieldInconsistentLength,
illegalParameterValue,
illegalAnnotationCode,
illegalCharacter;
Expand All @@ -939,6 +940,7 @@ public String toString() {
Subtype.inconsistentPeriods,
Subtype.abbreviatedDateFieldTooWide,
Subtype.narrowDateFieldTooWide,
Subtype.shortDateFieldInconsistentLength,
Subtype.coverageLevel);

public static Set<Subtype> errorCodesPath =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ public CheckCLDR handleCheck(

try {
if (path.indexOf("[@type=\"abbreviated\"]") >= 0) {
// ensures abbreviated <= wide for quarters, months, days, dayPeriods
String pathToWide = path.replace("[@type=\"abbreviated\"]", "[@type=\"wide\"]");
String wideValue = getCldrFileToCheck().getWinningValueWithBailey(pathToWide);
if (wideValue != null && isTooMuchWiderThan(value, wideValue)) {
Expand Down Expand Up @@ -420,6 +421,7 @@ public CheckCLDR handleCheck(
}
}
} else if (path.indexOf("[@type=\"narrow\"]") >= 0) {
// ensures narrow <= abbreviated for quarters, months, days, dayPeriods
String pathToAbbr = path.replace("[@type=\"narrow\"]", "[@type=\"abbreviated\"]");
String abbrValue = getCldrFileToCheck().getWinningValueWithBailey(pathToAbbr);
if (abbrValue != null && isTooMuchWiderThan(value, abbrValue)) {
Expand All @@ -436,7 +438,43 @@ public CheckCLDR handleCheck(
value, abbrValue);
result.add(item);
}
} else if (path.indexOf("[@type=\"short\"]") >= 0) {
// ensures short <= abbreviated and short >= narrow for days
String pathToAbbr = path.replace("[@type=\"short\"]", "[@type=\"abbreviated\"]");
String abbrValue = getCldrFileToCheck().getWinningValueWithBailey(pathToAbbr);
String pathToNarrow = path.replace("[@type=\"short\"]", "[@type=\"narrow\"]");
String narrowValue = getCldrFileToCheck().getWinningValueWithBailey(pathToNarrow);
if ((abbrValue != null
&& isTooMuchWiderThan(value, abbrValue)
&& value.length() > abbrValue.length())
|| (narrowValue != null
&& isTooMuchWiderThan(narrowValue, value)
&& narrowValue.length() > value.length())) {
// Without the additional check on length() above, the test is too sensitive
// and flags reasonable things like lettercase differences
String message;
String compareValue;
if (abbrValue != null
&& isTooMuchWiderThan(value, abbrValue)
&& value.length() > abbrValue.length()) {
message =
"Short value \"{0}\" can't be longer than the corresponding abbreviated value \"{1}\"";
compareValue = abbrValue;
} else {
message =
"Short value \"{0}\" can't be shorter than the corresponding narrow value \"{1}\"";
compareValue = narrowValue;
}
CheckStatus item =
new CheckStatus()
.setCause(this)
.setMainType(CheckStatus.errorType)
.setSubtype(Subtype.shortDateFieldInconsistentLength)
.setMessage(message, value, compareValue);
result.add(item);
}
} else if (path.indexOf("/eraNarrow") >= 0) {
// ensures eraNarrow <= eraAbbr for eras
String pathToAbbr = path.replace("/eraNarrow", "/eraAbbr");
String abbrValue = getCldrFileToCheck().getWinningValueWithBailey(pathToAbbr);
if (abbrValue != null && isTooMuchWiderThan(value, abbrValue)) {
Expand All @@ -451,6 +489,7 @@ public CheckCLDR handleCheck(
result.add(item);
}
} else if (path.indexOf("/eraAbbr") >= 0) {
// ensures eraAbbr <= eraNames for eras
String pathToWide = path.replace("/eraAbbr", "/eraNames");
String wideValue = getCldrFileToCheck().getWinningValueWithBailey(pathToWide);
if (wideValue != null && isTooMuchWiderThan(value, wideValue)) {
Expand Down

0 comments on commit 9b13676

Please sign in to comment.