74 // |
74 // |
75 case "identity": |
75 case "identity": |
76 // ignore this element - it has language and territory elements that aren't locale data |
76 // ignore this element - it has language and territory elements that aren't locale data |
77 pushIgnoredContainer(qName); |
77 pushIgnoredContainer(qName); |
78 break; |
78 break; |
79 case "type": |
79 |
80 if ("calendar".equals(attributes.getValue("key"))) { |
80 // for LocaleNames |
81 pushStringEntry(qName, attributes, CLDRConverter.CALENDAR_NAME_PREFIX + attributes.getValue("type")); |
81 // copy string |
82 } else { |
82 case "localeSeparator": |
83 pushIgnoredContainer(qName); |
83 pushStringEntry(qName, attributes, |
84 } |
84 CLDRConverter.LOCALE_SEPARATOR); |
|
85 break; |
|
86 case "localeKeyTypePattern": |
|
87 pushStringEntry(qName, attributes, |
|
88 CLDRConverter.LOCALE_KEYTYPE); |
85 break; |
89 break; |
86 |
90 |
87 case "language": |
91 case "language": |
88 case "script": |
92 case "script": |
89 case "territory": |
93 case "territory": |
92 // copy string |
96 // copy string |
93 pushStringEntry(qName, attributes, |
97 pushStringEntry(qName, attributes, |
94 CLDRConverter.LOCALE_NAME_PREFIX + |
98 CLDRConverter.LOCALE_NAME_PREFIX + |
95 (qName.equals("variant") ? "%%" : "") + |
99 (qName.equals("variant") ? "%%" : "") + |
96 attributes.getValue("type")); |
100 attributes.getValue("type")); |
|
101 break; |
|
102 |
|
103 case "key": |
|
104 // for LocaleNames |
|
105 // copy string |
|
106 pushStringEntry(qName, attributes, |
|
107 CLDRConverter.LOCALE_KEY_PREFIX + |
|
108 convertOldKeyName(attributes.getValue("type"))); |
|
109 break; |
|
110 |
|
111 case "type": |
|
112 // for LocaleNames/CalendarNames |
|
113 // copy string |
|
114 pushStringEntry(qName, attributes, |
|
115 CLDRConverter.LOCALE_TYPE_PREFIX + |
|
116 convertOldKeyName(attributes.getValue("key")) + "." + |
|
117 attributes.getValue("type")); |
|
118 |
97 break; |
119 break; |
98 |
120 |
99 // |
121 // |
100 // Currency information |
122 // Currency information |
101 // |
123 // |
513 |
535 |
514 // Use keys as <script>."NumberElements/<symbol>" |
536 // Use keys as <script>."NumberElements/<symbol>" |
515 currentNumberingSystem = script + "."; |
537 currentNumberingSystem = script + "."; |
516 String digits = CLDRConverter.handlerNumbering.get(script); |
538 String digits = CLDRConverter.handlerNumbering.get(script); |
517 if (digits == null) { |
539 if (digits == null) { |
518 throw new InternalError("null digits for " + script); |
540 pushIgnoredContainer(qName); |
519 } |
541 break; |
520 if (Character.isSurrogate(digits.charAt(0))) { |
542 } |
521 // DecimalFormatSymbols doesn't support supplementary characters as digit zero. |
543 |
522 pushIgnoredContainer(qName); |
|
523 break; |
|
524 } |
|
525 // in case digits are in the reversed order, reverse back the order. |
|
526 if (digits.charAt(0) > digits.charAt(digits.length() - 1)) { |
|
527 StringBuilder sb = new StringBuilder(digits); |
|
528 digits = sb.reverse().toString(); |
|
529 } |
|
530 // Check if the order is sequential. |
|
531 char c0 = digits.charAt(0); |
|
532 for (int i = 1; i < digits.length(); i++) { |
|
533 if (digits.charAt(i) != c0 + i) { |
|
534 pushIgnoredContainer(qName); |
|
535 break symbols; |
|
536 } |
|
537 } |
|
538 @SuppressWarnings("unchecked") |
544 @SuppressWarnings("unchecked") |
539 List<String> numberingScripts = (List<String>) get("numberingScripts"); |
545 List<String> numberingScripts = (List<String>) get("numberingScripts"); |
540 if (numberingScripts == null) { |
546 if (numberingScripts == null) { |
541 numberingScripts = new ArrayList<>(); |
547 numberingScripts = new ArrayList<>(); |
542 put("numberingScripts", numberingScripts); |
548 put("numberingScripts", numberingScripts); |
922 CLDRConverter.aliases.put(src.replaceFirst("^gregorian.", ""), |
928 CLDRConverter.aliases.put(src.replaceFirst("^gregorian.", ""), |
923 target.replaceFirst("^gregorian.", "")); |
929 target.replaceFirst("^gregorian.", "")); |
924 } |
930 } |
925 } |
931 } |
926 } else if (currentContainer instanceof Entry) { |
932 } else if (currentContainer instanceof Entry) { |
927 Entry<?> entry = (Entry<?>) currentContainer; |
933 Entry<?> entry = (Entry<?>) currentContainer; |
928 Object value = entry.getValue(); |
934 Object value = entry.getValue(); |
929 if (value != null) { |
935 if (value != null) { |
930 String key = entry.getKey(); |
936 String key = entry.getKey(); |
931 // Tweak for MonthNames for the root locale, Needed for |
937 // Tweak for MonthNames for the root locale, Needed for |
932 // SimpleDateFormat.format()/parse() roundtrip. |
938 // SimpleDateFormat.format()/parse() roundtrip. |
933 if (id.equals("root") && key.startsWith("MonthNames")) { |
939 if (id.equals("root") && key.startsWith("MonthNames")) { |
934 value = new DateFormatSymbols(Locale.US).getShortMonths(); |
940 value = new DateFormatSymbols(Locale.US).getShortMonths(); |
935 } |
941 } |
936 put(entry.getKey(), value); |
942 put(entry.getKey(), value); |
937 } |
943 } |
938 } |
944 } |
939 } |
945 } |
940 } |
946 |
|
947 public String convertOldKeyName(String key) { |
|
948 // Explicitly obtained from "alias" attribute in each "key" element. |
|
949 switch (key) { |
|
950 case "calendar": |
|
951 return "ca"; |
|
952 case "currency": |
|
953 return "cu"; |
|
954 case "collation": |
|
955 return "co"; |
|
956 case "numbers": |
|
957 return "nu"; |
|
958 case "timezone": |
|
959 return "tz"; |
|
960 default: |
|
961 return key; |
|
962 } |
|
963 } |
|
964 } |