From 3f3e93dba91b98d2e0115d17c1d785de2a897c60 Mon Sep 17 00:00:00 2001 From: Peter Edberg Date: Sat, 13 Jul 2024 14:43:29 -0700 Subject: [PATCH] CLDR-17792 Don't strip ZWSP for value compare, allow currency symbol collision for it --- .../unicode/cldr/test/CheckDisplayCollisions.java | 9 +++++++++ .../java/org/unicode/cldr/util/SimpleXMLSource.java | 6 ++++-- .../cldr/unittest/TestCheckDisplayCollisions.java | 13 +++++++++++++ .../cldr/unittest/TestDisplayAndInputProcessor.java | 7 +++++++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDisplayCollisions.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDisplayCollisions.java index e98642d9ff5..2d074ec9769 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDisplayCollisions.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/CheckDisplayCollisions.java @@ -491,6 +491,15 @@ public CheckCLDR handleCheck( if (path.contains("/decimal") || path.contains("/group")) { return this; } + // Currency symbol value \u200B (ZWSP) is allowed to match other paths; when it is used, + // the actual currency symbol must be in a decimal element for the specific currency. + if (path.contains("/symbol") && value.equals("\\u200B")) { + String decimalPath = path.replace("/symbol", "/decimal"); + String decimalValue = getResolvedCldrFileToCheck().getWinningValue(decimalPath); + if (decimalValue != null && decimalValue.length() > 0) { + return this; + } + } XPathParts parts = XPathParts.getFrozenInstance(path); String currency = parts.getAttributeValue(-2, "type"); Iterator iterator = paths.iterator(); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/SimpleXMLSource.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/SimpleXMLSource.java index e97ba9d9484..0b791e49c4d 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/SimpleXMLSource.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/SimpleXMLSource.java @@ -170,10 +170,12 @@ public void getPathsWithValue(String valueToMatch, String pathPrefix, Set pt_PTPathValuePairs = + ImmutableMap.of( + "ldml/numbers/currencies/currency[@type=\"EUR\"]/symbol", "€", + "ldml/numbers/currencies/currency[@type=\"GBP\"]/symbol", "£", + "ldml/numbers/currencies/currency[@type=\"PTE\"]/symbol", "\u200B", + "ldml/numbers/currencies/currency[@type=\"PTE\"]/decimal", "$", + "ldml/numbers/currencies/currency[@type=\"USD\"]/symbol", "US$"); + TestFactory pt_PTFactory = makeFakeCldrFile("pt_PT", pt_PTPathValuePairs); + checkDisplayCollisions("pt_PT", pt_PTPathValuePairs, pt_PTFactory); + } + public void checkDisplayCollisions( String locale, Map pathValuePairs, TestFactory factory) { CheckDisplayCollisions cdc = new CheckDisplayCollisions(factory); diff --git a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestDisplayAndInputProcessor.java b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestDisplayAndInputProcessor.java index 2963c34aabb..82270a558e4 100644 --- a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestDisplayAndInputProcessor.java +++ b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestDisplayAndInputProcessor.java @@ -600,6 +600,13 @@ public static PathSpaceData[] getArray() { // PathSpaceData("//ldml/dates/calendars/calendar[@type=\"gregorian\"]/dayPeriods/dayPeriodContext[@type=\"format\"]/dayPeriodWidth[@type=\"narrow\"]/dayPeriod[@type=\"am\"]", // " pizza \u00A0\u202F cardboard ", "pizza\u202Fcardboard", // PathSpaceType.allowNNbsp), + + // Verify that ZWSP u200B as symbol for PTE (in e.g. pt_PT) is not altered + new PathSpaceData( + "//ldml/numbers/currencies/currency[@type=\"PTE\"]/symbol", + "\u200B", + "\u200B", + PathSpaceType.allowSpOrNbsp), }; return a; }