• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.unicode.cldr.test;
2 
3 import java.util.Set;
4 import java.util.regex.Pattern;
5 
6 import org.unicode.cldr.util.Organization;
7 import org.unicode.cldr.util.StandardCodes;
8 
9 import com.google.common.collect.ImmutableSet;
10 
11 public final class SubmissionLocales {
12     static Set<String> NEW_CLDR_LOCALES = ImmutableSet.of("jv", "so", "ceb", "ha", "ig", "yo");
13     static Set<String> HIGH_LEVEL_LOCALES = ImmutableSet.of("chr", "gd", "fo");
14     // have to have a lazy eval because otherwise CLDRConfig is called too early in the boot process
15     static Set<String> CLDR_LOCALES = ImmutableSet.<String>builder()
16         .addAll(HIGH_LEVEL_LOCALES)
17         .addAll(NEW_CLDR_LOCALES)
18         .addAll(StandardCodes.make().getLocaleToLevel(Organization.cldr).keySet()).build();
19 
20 //            synchronized (SUBMISSION) {
21 //                if (CLDR_LOCALES == null) {
22 //                    CLDR_LOCALES = ImmutableSet.<String>builder()
23 //                        .addAll(HIGH_LEVEL_LOCALES)
24 //                        .addAll(StandardCodes.make().getLocaleToLevel(Organization.cldr).keySet()).build();
25 //                }
26 //            }
27 
28     public static final Pattern ALLOWED_IN_LIMITED_PATHS = Pattern.compile(
29         "//ldml/"
30             + "(listPatterns/listPattern\\[@type=\"standard"
31             + "|annotations/annotation\\[@cp=\"([©®‼⁉☑✅✔✖✨✳✴❇❌❎❓-❕❗❣ ➕-➗��-��������������������������⭕��������������⭕��������������������]|��‍♀|��‍♂)\""
32             + "|localeDisplayNames/"
33             +   "(scripts/script\\[@type=\"(Elym|Hmnp|Nand|Wcho)\""
34             +    "|territories/territory\\[@type=\"(MO|SZ)\"](\\[@alt=\"variant\"])?"
35             +    "|types/type\\[@key=\"numbers\"]\\[@type=\"(hmnp|wcho)\"]"
36             +   ")"
37             + "|dates/timeZoneNames/(metazone\\[@type=\"Macau\"]"
38             +   "|zone\\[@type=\"Asia/Macau\"]"
39             +   ")"
40             + ")"
41             );
42 
43 //ldml/dates/timeZoneNames/metazone[@type="Macau"]/long/daylight, old: Macau Summer Time, new: Macao Summer Time
44 //ldml/dates/timeZoneNames/metazone[@type="Macau"]/long/standard, old: Macau Standard Time, new: Macao Standard Time
45 //ldml/localeDisplayNames/territories/territory[@type="SZ"][@alt="variant"], old: SZ, new: Swaziland
46 //ldml/dates/timeZoneNames/zone[@type="Asia/Macau"]/exemplarCity, old: Macau, new: Macao
47 //ldml/dates/timeZoneNames/metazone[@type="Macau"]/long/generic, old: Macau Time, new: Macao Time
48 //ldml/localeDisplayNames/territories/territory[@type="SZ"], old: Swaziland, new: Eswatini
49 
50 
51     /**
52      * Only call this if LIMITED_SUBMISSION
53      * @param localeString
54      * @param path
55      * @param isError
56      * @param missingInLastRelease
57      * @return
58      */
allowEvenIfLimited(String localeString, String path, boolean isError, boolean missingInLastRelease)59     public static boolean allowEvenIfLimited(String localeString, String path, boolean isError, boolean missingInLastRelease) {
60 
61         // don't limit new locales or errors
62 
63         if (SubmissionLocales.NEW_CLDR_LOCALES.contains(localeString) || isError) {
64             return true;
65         } else {
66             int debug = 0; // for debugging
67         }
68 
69         // all but CLDR locales are otherwise locked
70 
71         if (!SubmissionLocales.CLDR_LOCALES.contains(localeString)) {
72             return false;
73         } else {
74             int debug = 0; // for debugging
75         }
76 
77         // in those locales, lock all paths except missing and special
78 
79         if (missingInLastRelease) {
80             return true;
81         } else {
82             int debug = 0; // for debugging
83         }
84 
85         if (pathAllowedInLimitedSubmission(path)) {
86             return true;
87         } else {
88             int debug = 0; // for debugging
89         }
90 
91         return false; // skip
92     }
93 
pathAllowedInLimitedSubmission(String path)94     public static boolean pathAllowedInLimitedSubmission(String path) {
95         return SubmissionLocales.ALLOWED_IN_LIMITED_PATHS.matcher(path).lookingAt();
96     }
97 }