Skip to content

Commit

Permalink
CLDR-17560 CheckCLDR UI for non-path checks
Browse files Browse the repository at this point in the history
- rollup non-path checks into a single warning in the info panel
- fix Voting API to expose this data
  • Loading branch information
srl295 committed Apr 30, 2024
1 parent 553cda3 commit 7774140
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 5 deletions.
14 changes: 13 additions & 1 deletion tools/cldr-apps/js/src/esm/cldrSurvey.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,15 @@ function testsToHtml(tests) {
if (!tests) {
return newHtml;
}
var hadEntireLocale = false;

for (var i = 0; i < tests.length; i++) {
var testItem = tests[i];
const { entireLocale } = testItem;
if (entireLocale) {
hadEntireLocale = true;
continue;
}
newHtml += "<p class='trInfo tr_" + testItem.type;
if (testItem.type == "Warning") {
newHtml += " alert alert-warning fix-popover-help";
Expand All @@ -780,7 +787,12 @@ function testsToHtml(tests) {
newHtml += ' <a href="' + testItem.subtypeUrl + '">(how to fix…)</a>';
}

newHtml += "</p>";
newHtml += "</p>\n";
}
if (hadEntireLocale) {
newHtml += `<p class='trInfo tr_Warning alert alert-warning fix-popover-help'>See also <a href='#r_supplemental/${cldrStatus.getCurrentLocale()}//'>${cldrText.get(
"special_r_supplemental"
)}</a></p>\n`;
}
return newHtml;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public static JSONObject wrap(CheckStatus status) throws JSONException {
put("subtype", subtype.name());
put("subtypeUrl", SubtypeToURLMap.forSubtype(subtype)); // could be null.
}
put("entireLocale", cs.getEntireLocale());
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ public static final class CheckStatusSummary {
public String subtypeUrl;
public Phase phase;
public String cause;
public boolean entireLocale;

public CheckStatusSummary(CheckStatus checkStatus) {
this.message = checkStatus.getMessage();
Expand All @@ -366,6 +367,7 @@ public CheckStatusSummary(CheckStatus checkStatus) {
if (this.subtype != null) {
this.subtypeUrl = SubtypeToURLMap.forSubtype(this.subtype); // could be null.
}
this.entireLocale = checkStatus.getEntireLocale();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ public static boolean hasType(List<CheckStatus> result, Type type) {
/**
* @returns true if this status applies to the entire locale, not a single path
*/
public boolean isEntireLocale() {
public boolean getEntireLocale() {
return entireLocale;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ public static void main(String[] args) throws Throwable {
boolean showedOne = false;
for (Iterator<CheckStatus> it3 = result.iterator(); it3.hasNext(); ) {
CheckStatus status = it3.next();
if (status.isEntireLocale()) {
if (status.getEntireLocale()) {
possibleProblems.add(status);
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void writeContents(
List<CheckStatus> result = new ArrayList<CheckStatus>();
test.check(x, result, cldrFile.getStringValue(x));
for (final CheckStatus s : result) {
if (s.isEntireLocale()) pp.add(s);
if (s.getEntireLocale()) pp.add(s);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public Status getErrorStatus(
StringBuilder errorMessage = new StringBuilder();
factory.getTestCache().getBundle(options).check(path, result, value);
for (CheckStatus checkStatus : result) {
if (checkStatus.isEntireLocale())
if (checkStatus.getEntireLocale())
continue; // these will show up in the Entire Locale (supplemental) report
final CheckCLDR cause = checkStatus.getCause();
/*
Expand Down

0 comments on commit 7774140

Please sign in to comment.