Skip to content

Commit c7c38a0

Browse files
authored
CLDR-19188 Fix the version 48 and 48.1 DTD delta charts (#5308)
1 parent acfdf22 commit c7c38a0

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

tools/cldr-code/src/main/java/org/unicode/cldr/tool/ChartDtdDelta.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.Set;
2323
import java.util.regex.Matcher;
2424
import org.unicode.cldr.draft.FileUtilities;
25-
import org.unicode.cldr.tool.ToolConstants.ChartStatus;
2625
import org.unicode.cldr.util.CLDRConfig;
2726
import org.unicode.cldr.util.CLDRPaths;
2827
import org.unicode.cldr.util.CldrUtility;
@@ -139,21 +138,22 @@ public void writeContents(FormattedFileWriter pw) throws IOException {
139138
.addColumn("Attributes", "class='target'", null, "class='target'", true)
140139
.setSpanRows(false);
141140

142-
String last = null;
141+
CldrVersion last = null;
143142

144-
for (String current :
145-
ToolConstants.CHART_STATUS != ChartStatus.release
146-
? ToolConstants.CLDR_RELEASE_AND_DEV_VERSION_SET
147-
: ToolConstants.CLDR_RELEASE_VERSION_SET) {
143+
for (CldrVersion current : CldrVersion.CLDR_VERSIONS_ASCENDING) {
144+
if (current.compareTo(CldrVersion.from(ToolConstants.CHART_VERSION)) > 0) {
145+
continue;
146+
}
148147
System.out.println("DTD delta: " + current);
149-
final boolean finalVersion = current.equals(ToolConstants.DEV_VERSION);
150-
String currentName = finalVersion ? ToolConstants.CHART_DISPLAY_VERSION : current;
148+
final boolean finalVersion =
149+
current.equals(CldrVersion.from(ToolConstants.DEV_VERSION));
150+
String currentName =
151+
finalVersion ? ToolConstants.CHART_DISPLAY_VERSION : current.toString();
151152
for (DtdType type : TYPES) {
152153
String firstVersion = type.firstVersion; // FIRST_VERSION.get(type);
153154
if (firstVersion != null
154155
&& current != null
155-
&& VersionInfo.getInstance(current)
156-
.compareTo(VersionInfo.getInstance(firstVersion))
156+
&& current.getVersionInfo().compareTo(VersionInfo.getInstance(firstVersion))
157157
< 0) {
158158
// skip if current is too old to have “type”
159159
continue;
@@ -167,7 +167,7 @@ public void writeContents(FormattedFileWriter pw) throws IOException {
167167
// && ToolConstants.CHART_STATUS !=
168168
// ToolConstants.ChartStatus.release
169169
? null
170-
: current);
170+
: current.toString());
171171
} catch (Exception e) {
172172
if (!(e.getCause() instanceof FileNotFoundException)) {
173173
throw e;
@@ -178,18 +178,15 @@ public void writeContents(FormattedFileWriter pw) throws IOException {
178178
DtdData dtdLast = null;
179179
if (last != null
180180
&& (firstVersion == null
181-
|| VersionInfo.getInstance(last)
181+
|| last.getVersionInfo()
182182
.compareTo(VersionInfo.getInstance(firstVersion))
183183
>= 0)) {
184184
// only read if last isn’t too old to have “type”
185-
dtdLast = DtdData.getInstance(type, last);
185+
dtdLast = DtdData.getInstance(type, last.toString());
186186
}
187187
diff(currentName, dtdLast, dtdCurrent);
188188
}
189189
last = current;
190-
if (current.contentEquals(ToolConstants.CHART_VERSION)) {
191-
break;
192-
}
193190
}
194191

195192
for (DiffElement datum : data) {

tools/cldr-code/src/main/java/org/unicode/cldr/tool/CldrVersion.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Map;
1313
import java.util.Set;
1414
import java.util.TreeSet;
15+
import java.util.stream.Collectors;
1516
import org.unicode.cldr.util.CLDRFile;
1617
import org.unicode.cldr.util.CLDRPaths;
1718

@@ -73,6 +74,7 @@ public enum CldrVersion {
7374
v46_1,
7475
v47_0,
7576
v48_0,
77+
v48_1,
7678
/**
7779
* @see CLDRFile#GEN_VERSION
7880
*/
@@ -112,10 +114,9 @@ public static CldrVersion from(String versionString) {
112114
|| versionString.equals(CLDRFile.GEN_VERSION + ".0")) {
113115
return CldrVersion.baseline;
114116
}
115-
return valueOf(
116-
versionString.charAt(0) < 'A'
117-
? "v" + versionString.replace('.', '_')
118-
: versionString);
117+
return versionString.charAt(0) > '9'
118+
? valueOf(versionString)
119+
: from(VersionInfo.getInstance(versionString));
119120
}
120121

121122
public VersionInfo getVersionInfo() {
@@ -156,10 +157,11 @@ private CldrVersion() {
156157

157158
static {
158159
EnumSet<CldrVersion> temp = EnumSet.allOf(CldrVersion.class);
159-
CLDR_VERSIONS_ASCENDING = ImmutableList.copyOf(temp);
160+
CLDR_VERSIONS_ASCENDING =
161+
temp.stream().filter(x -> x != x.unknown).collect(Collectors.toUnmodifiableList());
160162
CLDR_VERSIONS_DESCENDING = ImmutableList.copyOf(Lists.reverse(CLDR_VERSIONS_ASCENDING));
161163
Map<VersionInfo, CldrVersion> temp2 = new LinkedHashMap<>();
162-
for (CldrVersion item : CLDR_VERSIONS_ASCENDING) {
164+
for (CldrVersion item : temp) {
163165
VersionInfo version2 = item.versionInfo;
164166
temp2.put(version2, item);
165167
if (version2.getMilli() != 0) {

tools/cldr-code/src/main/java/org/unicode/cldr/tool/ToolConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public enum ChartStatus {
3131
"1.7.2", "1.8.1", "1.9.1", "2.0.1", "21.0", "22.1", "23.1", "24.0", "25.0",
3232
"26.0", "27.0", "28.0", "29.0", "30.0", "31.0", "32.0", "33.0", "33.1", "34.0",
3333
"35.0", "35.1", "36.0", "36.1", "37.0", "38.0", "38.1", "39.0", "40.0", "41.0",
34-
"42.0", "43.0", "44.0", "44.1", "45.0", "46.0", "46.1", "47.0", "48.0"
34+
"42.0", "43.0", "44.0", "44.1", "45.0", "46.0", "46.1", "47.0", "48.0", "48.1"
3535
// add to this once the release is final!
3636
);
3737
public static final Set<VersionInfo> CLDR_VERSIONS_VI =

0 commit comments

Comments
 (0)