make/tools/src/build/tools/cldrconverter/CLDRConverter.java
Print this page
*** 23,32 ****
--- 23,33 ----
* questions.
*/
package build.tools.cldrconverter;
+ import build.tools.cldrconverter.BundleGenerator.BundleType;
import java.io.File;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
*** 56,68 ****
static final String LOCALE_NAME_PREFIX = "locale.displayname.";
static final String CURRENCY_SYMBOL_PREFIX = "currency.symbol.";
static final String CURRENCY_NAME_PREFIX = "currency.displayname.";
static final String TIMEZONE_ID_PREFIX = "timezone.id.";
! static final String TIMEZONE_NAME_PREFIX = "timezone.displayname.";
static final String METAZONE_ID_PREFIX = "metazone.id.";
- static final String METAZONE_NAME_PREFIX = "metazone.displayname.";
private static SupplementDataParseHandler handlerSuppl;
static NumberingSystemsParseHandler handlerNumbering;
static MetaZonesParseHandler handlerMetaZones;
private static BundleGenerator bundleGenerator;
--- 57,68 ----
static final String LOCALE_NAME_PREFIX = "locale.displayname.";
static final String CURRENCY_SYMBOL_PREFIX = "currency.symbol.";
static final String CURRENCY_NAME_PREFIX = "currency.displayname.";
static final String TIMEZONE_ID_PREFIX = "timezone.id.";
! static final String ZONE_NAME_PREFIX = "timezone.displayname.";
static final String METAZONE_ID_PREFIX = "metazone.id.";
private static SupplementDataParseHandler handlerSuppl;
static NumberingSystemsParseHandler handlerNumbering;
static MetaZonesParseHandler handlerMetaZones;
private static BundleGenerator bundleGenerator;
*** 234,244 ****
}
}
if (sb.indexOf("root") == -1) {
sb.append("root");
}
! retList.add(new Bundle(id, sb.toString(), null, null));
}
}
}
return retList;
}
--- 234,251 ----
}
}
if (sb.indexOf("root") == -1) {
sb.append("root");
}
! Bundle b = new Bundle(id, sb.toString(), null, null);
! // Insert the bundle for en at the top so that it will get
! // processed first.
! if ("en".equals(id)) {
! retList.add(0, b);
! } else {
! retList.add(b);
! }
}
}
}
return retList;
}
*** 310,319 ****
--- 317,327 ----
// For generating information on supported locales.
Map<String, SortedSet<String>> metaInfo = new HashMap<>();
metaInfo.put("LocaleNames", new TreeSet<String>());
metaInfo.put("CurrencyNames", new TreeSet<String>());
+ metaInfo.put("TimeZoneNames", new TreeSet<String>());
metaInfo.put("CalendarData", new TreeSet<String>());
metaInfo.put("FormatData", new TreeSet<String>());
for (Bundle bundle : bundles) {
// Get the target map, which contains all the data that should be
*** 346,383 ****
// Go ahead and generate them.
if (bundleTypes.contains(Bundle.Type.LOCALENAMES)) {
Map<String, Object> localeNamesMap = extractLocaleNames(targetMap, bundle.getID());
if (!localeNamesMap.isEmpty() || bundle.isRoot()) {
metaInfo.get("LocaleNames").add(toLanguageTag(bundle.getID()));
! bundleGenerator.generateBundle("util", "LocaleNames", bundle.getID(), true, localeNamesMap, true);
}
}
if (bundleTypes.contains(Bundle.Type.CURRENCYNAMES)) {
Map<String, Object> currencyNamesMap = extractCurrencyNames(targetMap, bundle.getID(), bundle.getCurrencies());
if (!currencyNamesMap.isEmpty() || bundle.isRoot()) {
metaInfo.get("CurrencyNames").add(toLanguageTag(bundle.getID()));
! bundleGenerator.generateBundle("util", "CurrencyNames", bundle.getID(), true, currencyNamesMap, true);
}
}
if (bundleTypes.contains(Bundle.Type.TIMEZONENAMES)) {
Map<String, Object> zoneNamesMap = extractZoneNames(targetMap, bundle.getID());
}
if (bundleTypes.contains(Bundle.Type.CALENDARDATA)) {
Map<String, Object> calendarDataMap = extractCalendarData(targetMap, bundle.getID());
if (!calendarDataMap.isEmpty() || bundle.isRoot()) {
metaInfo.get("CalendarData").add(toLanguageTag(bundle.getID()));
! bundleGenerator.generateBundle("util", "CalendarData", bundle.getID(), true, calendarDataMap, false);
}
}
if (bundleTypes.contains(Bundle.Type.FORMATDATA)) {
Map<String, Object> formatDataMap = extractFormatData(targetMap, bundle.getID());
// LocaleData.getAvailableLocales depends on having FormatData bundles around
if (!formatDataMap.isEmpty() || bundle.isRoot()) {
metaInfo.get("FormatData").add(toLanguageTag(bundle.getID()));
! bundleGenerator.generateBundle("text", "FormatData", bundle.getID(), true, formatDataMap, false);
}
}
// For testing
SortedSet<String> allLocales = new TreeSet<>();
allLocales.addAll(metaInfo.get("CurrencyNames"));
allLocales.addAll(metaInfo.get("LocaleNames"));
allLocales.addAll(metaInfo.get("CalendarData"));
--- 354,396 ----
// Go ahead and generate them.
if (bundleTypes.contains(Bundle.Type.LOCALENAMES)) {
Map<String, Object> localeNamesMap = extractLocaleNames(targetMap, bundle.getID());
if (!localeNamesMap.isEmpty() || bundle.isRoot()) {
metaInfo.get("LocaleNames").add(toLanguageTag(bundle.getID()));
! bundleGenerator.generateBundle("util", "LocaleNames", bundle.getID(), true, localeNamesMap, BundleType.OPEN);
}
}
if (bundleTypes.contains(Bundle.Type.CURRENCYNAMES)) {
Map<String, Object> currencyNamesMap = extractCurrencyNames(targetMap, bundle.getID(), bundle.getCurrencies());
if (!currencyNamesMap.isEmpty() || bundle.isRoot()) {
metaInfo.get("CurrencyNames").add(toLanguageTag(bundle.getID()));
! bundleGenerator.generateBundle("util", "CurrencyNames", bundle.getID(), true, currencyNamesMap, BundleType.OPEN);
}
}
if (bundleTypes.contains(Bundle.Type.TIMEZONENAMES)) {
Map<String, Object> zoneNamesMap = extractZoneNames(targetMap, bundle.getID());
+ if (!zoneNamesMap.isEmpty() || bundle.isRoot()) {
+ metaInfo.get("TimeZoneNames").add(toLanguageTag(bundle.getID()));
+ bundleGenerator.generateBundle("util", "TimeZoneNames", bundle.getID(), true, zoneNamesMap, BundleType.TIMEZONE);
+ }
}
if (bundleTypes.contains(Bundle.Type.CALENDARDATA)) {
Map<String, Object> calendarDataMap = extractCalendarData(targetMap, bundle.getID());
if (!calendarDataMap.isEmpty() || bundle.isRoot()) {
metaInfo.get("CalendarData").add(toLanguageTag(bundle.getID()));
! bundleGenerator.generateBundle("util", "CalendarData", bundle.getID(), true, calendarDataMap, BundleType.PLAIN);
}
}
if (bundleTypes.contains(Bundle.Type.FORMATDATA)) {
Map<String, Object> formatDataMap = extractFormatData(targetMap, bundle.getID());
// LocaleData.getAvailableLocales depends on having FormatData bundles around
if (!formatDataMap.isEmpty() || bundle.isRoot()) {
metaInfo.get("FormatData").add(toLanguageTag(bundle.getID()));
! bundleGenerator.generateBundle("text", "FormatData", bundle.getID(), true, formatDataMap, BundleType.OPEN);
}
}
+
// For testing
SortedSet<String> allLocales = new TreeSet<>();
allLocales.addAll(metaInfo.get("CurrencyNames"));
allLocales.addAll(metaInfo.get("LocaleNames"));
allLocales.addAll(metaInfo.get("CalendarData"));
*** 429,438 ****
--- 442,452 ----
static KeyComparator INSTANCE = new KeyComparator();
private KeyComparator() {
}
+ @Override
public int compare(String o1, String o2) {
int len1 = o1.length();
int len2 = o2.length();
if (!isDigit(o1.charAt(0)) && !isDigit(o2.charAt(0))) {
// Shorter string comes first unless either starts with a digit.
*** 474,484 ****
}
return currencyNames;
}
private static Map<String, Object> extractZoneNames(Map<String, Object> map, String id) {
! return null;
}
private static Map<String, Object> extractCalendarData(Map<String, Object> map, String id) {
Map<String, Object> calendarData = new LinkedHashMap<>();
copyIfPresent(map, "firstDayOfWeek", calendarData);
--- 488,517 ----
}
return currencyNames;
}
private static Map<String, Object> extractZoneNames(Map<String, Object> map, String id) {
! Map<String, Object> names = new HashMap<>();
! for (String tzid : handlerMetaZones.keySet()) {
! String tzKey = TIMEZONE_ID_PREFIX + tzid;
! Object data = map.get(tzKey);
! if (data instanceof String[]) {
! names.put(tzid, data);
! } else {
! String meta = handlerMetaZones.get(tzid);
! if (meta != null) {
! String metaKey = METAZONE_ID_PREFIX + meta;
! data = map.get(metaKey);
! if (data instanceof String[]) {
! // Keep the metazone prefix here.
! names.put(metaKey, data);
! names.put(tzid, meta);
! }
! }
! }
! }
! return names;
}
private static Map<String, Object> extractCalendarData(Map<String, Object> map, String id) {
Map<String, Object> calendarData = new LinkedHashMap<>();
copyIfPresent(map, "firstDayOfWeek", calendarData);
*** 492,506 ****
String prefix = calendarType.keyElementName();
copyIfPresent(map, prefix + "MonthNames", formatData); // default FORMAT since JDK8
copyIfPresent(map, prefix + "standalone.MonthNames", formatData);
copyIfPresent(map, prefix + "MonthAbbreviations", formatData);
copyIfPresent(map, prefix + "standalone.MonthAbbreviations", formatData);
copyIfPresent(map, prefix + "DayNames", formatData);
copyIfPresent(map, prefix + "DayAbbreviations", formatData);
copyIfPresent(map, prefix + "AmPmMarkers", formatData);
copyIfPresent(map, prefix + "Eras", formatData);
! copyIfPresent(map, prefix + "short.Eras", formatData);
copyIfPresent(map, prefix + "TimePatterns", formatData);
copyIfPresent(map, prefix + "DatePatterns", formatData);
copyIfPresent(map, prefix + "DateTimePatterns", formatData);
copyIfPresent(map, prefix + "DateTimePatternChars", formatData);
}
--- 525,547 ----
String prefix = calendarType.keyElementName();
copyIfPresent(map, prefix + "MonthNames", formatData); // default FORMAT since JDK8
copyIfPresent(map, prefix + "standalone.MonthNames", formatData);
copyIfPresent(map, prefix + "MonthAbbreviations", formatData);
copyIfPresent(map, prefix + "standalone.MonthAbbreviations", formatData);
+ copyIfPresent(map, prefix + "MonthNarrow", formatData);
+ copyIfPresent(map, prefix + "standalone.MonthNarrows", formatData);
copyIfPresent(map, prefix + "DayNames", formatData);
+ copyIfPresent(map, prefix + "standalone.DayNames", formatData);
copyIfPresent(map, prefix + "DayAbbreviations", formatData);
+ copyIfPresent(map, prefix + "standalone.DayAbbreviations", formatData);
+ copyIfPresent(map, prefix + "DayNarrows", formatData);
+ copyIfPresent(map, prefix + "standalone.DayNarrows", formatData);
copyIfPresent(map, prefix + "AmPmMarkers", formatData);
+ copyIfPresent(map, prefix + "narrow.AmPmMarkers", formatData);
+ copyIfPresent(map, prefix + "long.Eras", formatData);
copyIfPresent(map, prefix + "Eras", formatData);
! copyIfPresent(map, prefix + "narrow.Eras", formatData);
copyIfPresent(map, prefix + "TimePatterns", formatData);
copyIfPresent(map, prefix + "DatePatterns", formatData);
copyIfPresent(map, prefix + "DateTimePatterns", formatData);
copyIfPresent(map, prefix + "DateTimePatternChars", formatData);
}
*** 558,568 ****
switch (aChar) {
case ' ':
if (x == 0 || escapeSpace) {
outBuffer.append('\\');
}
-
outBuffer.append(' ');
break;
case '\\':
outBuffer.append('\\');
outBuffer.append('\\');
--- 599,608 ----
*** 582,592 ****
case '\f':
outBuffer.append('\\');
outBuffer.append('f');
break;
default:
! if (!USE_UTF8 && ((aChar < 0x0020) || (aChar > 0x007e))) {
formatter.format("\\u%04x", (int)aChar);
} else {
if (specialSaveChars.indexOf(aChar) != -1) {
outBuffer.append('\\');
}
--- 622,632 ----
case '\f':
outBuffer.append('\\');
outBuffer.append('f');
break;
default:
! if (aChar < 0x0020 || (!USE_UTF8 && aChar > 0x007e)) {
formatter.format("\\u%04x", (int)aChar);
} else {
if (specialSaveChars.indexOf(aChar) != -1) {
outBuffer.append('\\');
}