From 1976c60a86e9a45cacbba2eff33f1d93e67dcde3 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Tue, 6 Aug 2024 12:22:29 -0500 Subject: [PATCH] CLDR-15882 add a test to verify coverage for locale names --- .../cldr/unittest/LikelySubtagsTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/LikelySubtagsTest.java b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/LikelySubtagsTest.java index 6bfa2a607ff..462cf1ce7db 100644 --- a/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/LikelySubtagsTest.java +++ b/tools/cldr-code/src/test/java/org/unicode/cldr/unittest/LikelySubtagsTest.java @@ -25,6 +25,7 @@ import java.util.TreeSet; import org.unicode.cldr.draft.ScriptMetadata; import org.unicode.cldr.draft.ScriptMetadata.Info; +import org.unicode.cldr.test.SubmissionLocales; import org.unicode.cldr.tool.LikelySubtags; import org.unicode.cldr.util.CLDRConfig; import org.unicode.cldr.util.CLDRFile; @@ -36,6 +37,7 @@ import org.unicode.cldr.util.ChainedMap.M3; import org.unicode.cldr.util.CldrUtility; import org.unicode.cldr.util.Containment; +import org.unicode.cldr.util.CoverageInfo; import org.unicode.cldr.util.Factory; import org.unicode.cldr.util.LanguageTagParser; import org.unicode.cldr.util.Level; @@ -323,10 +325,14 @@ public void TestForMissingScriptMetadata() { public void TestMissingInfoForLanguage() { CLDRFile english = CLDR_CONFIG.getEnglish().getUnresolved(); + // this is the calculated coverage - coverageLevels.txt CalculatedCoverageLevels ccl = CalculatedCoverageLevels.getInstance(); + CoverageInfo covInfo = CLDR_CONFIG.getCoverageInfo(); + for (String language : CLDR_CONFIG.getCldrFactory().getAvailableLanguages()) { if (language.contains("_") || language.equals("root")) { + // skip root and any sublocales (scripts, regions, variants, etc.) continue; } String likelyExpansion = likely.get(language); @@ -335,6 +341,7 @@ public void TestMissingInfoForLanguage() { } else { logln("Likely subtags for " + language + ":\t " + likely); } + // path for the name String path = CLDRFile.getKey(CLDRFile.LANGUAGE_NAME, language); String englishName = english.getStringValue(path); if (englishName == null) { @@ -349,6 +356,30 @@ public void TestMissingInfoForLanguage() { } errln("Missing English translation for: " + language + " which is at " + covLevel); } + // now, check general coverage level. Use "und" so it is neutral. + Level undCovLevel = covInfo.getCoverageLevel(path, "und"); + if (undCovLevel == null || undCovLevel.isAbove(Level.MODERN)) { + // What is the coverage level of the language? + final Level langCovLevel = ccl.getEffectiveCoverageLevel(language); + // Is it a TC org locale? + final boolean isTcLocale = + SubmissionLocales.isTcLocale(CLDRLocale.getInstance(language)); + + if (!isTcLocale && (langCovLevel == null || !langCovLevel.isAtLeast(Level.BASIC))) { + continue; // skip: Neither a TC locale nor at least BASIC. + } + errln( + "Language " + + language + + ": fix coverageLevels.txt: Expected MODERN but got " + + undCovLevel + + " for " + + path + + " - tcLocale:" + + isTcLocale + + ", locale calculated coverage:" + + langCovLevel); + } } }