23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package build.tools.cldrconverter; |
26 package build.tools.cldrconverter; |
27 |
27 |
|
28 import static build.tools.cldrconverter.Bundle.jreTimeZoneNames; |
28 import build.tools.cldrconverter.BundleGenerator.BundleType; |
29 import build.tools.cldrconverter.BundleGenerator.BundleType; |
29 import java.io.File; |
30 import java.io.File; |
30 import java.nio.file.DirectoryStream; |
31 import java.nio.file.DirectoryStream; |
31 import java.nio.file.FileSystems; |
32 import java.nio.file.FileSystems; |
32 import java.nio.file.Files; |
33 import java.nio.file.Files; |
562 return currencyNames; |
563 return currencyNames; |
563 } |
564 } |
564 |
565 |
565 private static Map<String, Object> extractZoneNames(Map<String, Object> map, String id) { |
566 private static Map<String, Object> extractZoneNames(Map<String, Object> map, String id) { |
566 Map<String, Object> names = new HashMap<>(); |
567 Map<String, Object> names = new HashMap<>(); |
|
568 |
|
569 // Copy over missing time zone ids from JRE for English locale |
|
570 if (id.equals("en")) { |
|
571 Map<String[], String> jreMetaMap = new HashMap<>(); |
|
572 jreTimeZoneNames.stream().forEach(e -> { |
|
573 String tzid = (String)e[0]; |
|
574 String[] data = (String[])e[1]; |
|
575 |
|
576 if (map.get(TIMEZONE_ID_PREFIX + tzid) == null && |
|
577 handlerMetaZones.get(tzid) == null) { |
|
578 // First, check the CLDR meta key |
|
579 Optional<Map.Entry<String, String>> cldrMeta = |
|
580 handlerMetaZones.getData().entrySet().stream() |
|
581 .filter(me -> |
|
582 Arrays.deepEquals(data, |
|
583 (String[])map.get(METAZONE_ID_PREFIX + me.getValue()))) |
|
584 .findAny(); |
|
585 if (cldrMeta.isPresent()) { |
|
586 names.put(tzid, cldrMeta.get().getValue()); |
|
587 } else { |
|
588 // check the JRE meta key, add if there is not. |
|
589 Optional<Map.Entry<String[], String>> jreMeta = |
|
590 jreMetaMap.entrySet().stream() |
|
591 .filter(jm -> Arrays.deepEquals(data, jm.getKey())) |
|
592 .findAny(); |
|
593 if (jreMeta.isPresent()) { |
|
594 names.put(tzid, jreMeta.get().getValue()); |
|
595 } else { |
|
596 String metaName = "JRE_" + tzid.replaceAll("[/-]", "_"); |
|
597 names.put(METAZONE_ID_PREFIX + metaName, data); |
|
598 names.put(tzid, metaName); |
|
599 jreMetaMap.put(data, metaName); |
|
600 } |
|
601 } |
|
602 } |
|
603 }); |
|
604 } |
|
605 |
567 for (String tzid : handlerMetaZones.keySet()) { |
606 for (String tzid : handlerMetaZones.keySet()) { |
568 String tzKey = TIMEZONE_ID_PREFIX + tzid; |
607 String tzKey = TIMEZONE_ID_PREFIX + tzid; |
569 Object data = map.get(tzKey); |
608 Object data = map.get(tzKey); |
570 if (data instanceof String[]) { |
609 if (data instanceof String[]) { |
571 names.put(tzid, data); |
610 names.put(tzid, data); |