• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.unicode.cldr.tool;
2 
3 import java.util.List;
4 import java.util.Set;
5 
6 import org.unicode.cldr.util.CLDRPaths;
7 import org.unicode.cldr.util.CldrUtility;
8 
9 import com.google.common.collect.ImmutableList;
10 import com.google.common.collect.ImmutableSet;
11 import com.ibm.icu.util.VersionInfo;
12 
13 /**
14  * Constants specific to CLDR tools.
15  * Not to be used with the Survey Tool.
16  * Moved here from CldrUtilities
17  * @author srl
18  *
19  */
20 public class ToolConstants {
21 
22     // We are now having charts point to the appropriate source, so this may take some tweaking!
23     public enum ChartStatus {
24         beta, // at the start of the release
25         trunk, // before the release is tagged
26         release // for release version
27     }
28 
29     // TODO change this to CldrVersion, add add in the ShowLocaleCoverage years.
30     public static final List<String> CLDR_VERSIONS = ImmutableList.of(
31         "1.1.1",
32         "1.2",
33         "1.3",
34         "1.4.1",
35         "1.5.1",
36         "1.6.1",
37         "1.7.2",
38         "1.8.1",
39         "1.9.1",
40         "2.0.1",
41         "21.0",
42         "22.1",
43         "23.1",
44         "24.0",
45         "25.0",
46         "26.0",
47         "27.0",
48         "28.0",
49         "29.0",
50         "30.0",
51         "31.0",
52         "32.0",
53         "33.0",
54         "33.1",
55         "34.0",
56         "35.0",
57         "35.1",
58         "36.0",
59         "36.1",
60         "37.0"
61         // add to this once the release is final!
62         );
63     public static final String DEV_VERSION = "38";
64 
65     public static final Set<String> CLDR_RELEASE_VERSION_SET = ImmutableSet.copyOf(ToolConstants.CLDR_VERSIONS);
66     public static final Set<String> CLDR_RELEASE_AND_DEV_VERSION_SET = ImmutableSet.<String>builder().addAll(CLDR_RELEASE_VERSION_SET).add(DEV_VERSION).build();
67 
previousVersion(String version)68     public static String previousVersion(String version) {
69         String last = "";
70         for (String current : CLDR_VERSIONS) {
71             if (current.equals(version)) {
72                 break;
73             }
74             last = current;
75         }
76         return last;
77     }
78 
getBaseDirectory(String version)79     public static String getBaseDirectory(String version) {
80         if (version.equals(DEV_VERSION) || version.equals(DEV_VERSION + ".0")) {
81             return CLDRPaths.BASE_DIRECTORY;
82         } else if (CLDR_RELEASE_VERSION_SET.contains(version)) {
83             return CLDRPaths.ARCHIVE_DIRECTORY + "cldr-" + version + "/";
84         } else {
85             throw new IllegalArgumentException("not a known version: " + version);
86         }
87     }
88 
89     // allows overriding with -D
90     public static final String CHART_VERSION = CldrUtility.getProperty("CHART_VERSION", DEV_VERSION);
91     public static final VersionInfo CHART_VI = VersionInfo.getInstance(CHART_VERSION);
92 
93     public static final String PREV_CHART_VERSION = CldrUtility.getProperty("PREV_CHART_VERSION", previousVersion(CHART_VERSION));
94     public static final VersionInfo PREV_CHART_VI = VersionInfo.getInstance(PREV_CHART_VERSION);
95     public static final String PREV_CHART_VERSION_WITH0 = PREV_CHART_VI.getVersionString(2, 2); // must have 1 decimal
96 
97     public static final ChartStatus CHART_STATUS = ChartStatus.valueOf(CldrUtility.getProperty("CHART_STATUS",
98         CLDR_RELEASE_VERSION_SET.contains(CHART_VERSION)
99         ? "release"
100             : "beta"));
101     public static final boolean BETA = CHART_STATUS == ChartStatus.beta;
102 
103     // DON'T CHANGE ANY OF THE FOLLOWING DEFINITIONS; THEY ARE DRIVEN BY THE ABOVE
104 
105     public static final String CHART_DISPLAY_VERSION = CHART_VI.getVersionString(2, 2) + (BETA ? "β" : "");
106 
107     public static final String LAST_RELEASE_VERSION = CLDR_VERSIONS.get(CLDR_VERSIONS.size()-1);
108     public static final VersionInfo LAST_RELEASE_VI = VersionInfo.getInstance(LAST_RELEASE_VERSION);
109     public static final String LAST_RELEASE_VERSION_WITH0 = LAST_RELEASE_VI.getVersionString(2, 2); // must have 1 decimal
110 
111 
112     //public static final String CHART_SOURCE_DIRECTORY = CLDR_VERSIONS.contains(CHART_VERSION) ? ""
113 
114     public static final String CHART_SOURCE = "http://unicode.org/repos/cldr/"
115         + (CHART_STATUS != ChartStatus.release ? "trunk/" : "tags/release-" + CHART_VERSION + "/");
116 
117 }
118