Skip to content

Commit 2a0f460

Browse files
authored
CLDR-17179 Flag n/a as forbidden value in CheckForExemplars (#4541)
1 parent 7fcd00f commit 2a0f460

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckCLDR.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,8 @@ public enum Subtype {
939939
nullOrEmptyValue,
940940
ttsAnnotationMissing,
941941
illegalCharacter,
942-
missingNumberingSystem;
942+
missingNumberingSystem,
943+
forbiddenValue;
943944

944945
@Override
945946
public String toString() {

tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckForExemplars.java

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import com.ibm.icu.text.Transform;
2121
import com.ibm.icu.text.UnicodeSet;
2222
import com.ibm.icu.util.ULocale;
23+
import java.util.ArrayList;
24+
import java.util.Arrays;
2325
import java.util.BitSet;
2426
import java.util.Date;
2527
import java.util.HashMap;
@@ -63,9 +65,18 @@ public class CheckForExemplars extends FactoryCheckCLDR {
6365

6466
private static final String STAND_IN = "#";
6567

66-
// private final UnicodeSet commonAndInherited = new
67-
// UnicodeSet(CheckExemplars.Allowed).complement();
68-
// "[[:script=common:][:script=inherited:][:alphabetic=false:]]");
68+
/**
69+
* These values, and their uppercase variants, are forbidden for any path. They should all be
70+
* lowercase.
71+
*/
72+
private static final List<String> FORBIDDEN_VALUES = new ArrayList<>(Arrays.asList("n/a"));
73+
74+
private static final String FORBIDDEN_VALUE_MESSAGE =
75+
"This value is forbidden for any path. If you believe this item is not an error, "
76+
+ "add a forum post with an explanation about why this value is not an error. "
77+
+ "The CLDR Technical Committee will reply to your forum post if they need any more information in "
78+
+ "order to resolve the error or next steps on how to resolve if they still believe it is an error.";
79+
6980
static String[] EXEMPLAR_SKIPS = {
7081
"/currencySpacing",
7182
"/exemplarCharacters",
@@ -329,7 +340,13 @@ public CheckCLDR handleCheck(
329340
}
330341

331342
// Check all paths for illegal characters, even EXEMPLAR_SKIPS
332-
checkIllegalCharacters(path, value, result);
343+
checkIllegalCharacters(value, result);
344+
345+
// If you believe this item is not an error, add forum post with an explanation about why
346+
// the current value is not an error. The CLDR Technical Committee will reply to your forum
347+
// post if they need any more information in order to resolve the error or next steps on how
348+
// to resolve if they still believe it is an error
349+
checkForbiddenValues(value, result);
333350

334351
if (containsPart(path, EXEMPLAR_SKIPS)) {
335352
return this;
@@ -583,7 +600,7 @@ public CheckCLDR handleCheck(
583600

584601
// Check for characters that are always illegal in values.
585602
// Currently those are just the paired bidi marks.
586-
private void checkIllegalCharacters(String path, String value, List<CheckStatus> result) {
603+
private void checkIllegalCharacters(String value, List<CheckStatus> result) {
587604
if (ILLEGAL_RTL_CONTROLS.containsSome(value)) {
588605
result.add(
589606
new CheckStatus()
@@ -595,6 +612,17 @@ private void checkIllegalCharacters(String path, String value, List<CheckStatus>
595612
}
596613
}
597614

615+
private void checkForbiddenValues(String value, List<CheckStatus> result) {
616+
if (FORBIDDEN_VALUES.contains(value.toLowerCase())) {
617+
result.add(
618+
new CheckStatus()
619+
.setCause(this)
620+
.setMainType(CheckStatus.errorType)
621+
.setSubtype(Subtype.forbiddenValue)
622+
.setMessage(FORBIDDEN_VALUE_MESSAGE));
623+
}
624+
}
625+
598626
private String checkAndReplacePlaceholders(
599627
String path, String value, List<CheckStatus> result) {
600628
CheckStatus.Type statusType =

0 commit comments

Comments
 (0)