1 /*
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
178 for (Map.Entry<Locale, String[]> entry : baseMetaInfo.parentLocales().entrySet()) {
179 if (Arrays.binarySearch(entry.getValue(), tag) >= 0) {
180 parent = entry.getKey();
181 break;
182 }
183 }
184 if (parent == null) {
185 parent = locale; // non existent marker
186 }
187 parentLocalesMap.putIfAbsent(locale, parent);
188 }
189
190 if (locale.equals(parent)) {
191 // means no irregular parent.
192 parent = null;
193 }
194
195 return parent;
196 }
197
198 @Override
199 public boolean isSupportedProviderLocale(Locale locale, Set<String> langtags) {
200 return Locale.ROOT.equals(locale) ||
201 langtags.contains(locale.stripExtensions().toLanguageTag());
202 }
203 }
|
1 /*
2 * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
178 for (Map.Entry<Locale, String[]> entry : baseMetaInfo.parentLocales().entrySet()) {
179 if (Arrays.binarySearch(entry.getValue(), tag) >= 0) {
180 parent = entry.getKey();
181 break;
182 }
183 }
184 if (parent == null) {
185 parent = locale; // non existent marker
186 }
187 parentLocalesMap.putIfAbsent(locale, parent);
188 }
189
190 if (locale.equals(parent)) {
191 // means no irregular parent.
192 parent = null;
193 }
194
195 return parent;
196 }
197
198 /**
199 * This method returns equivalent CLDR supported locale for zh-HK,
200 * no, no-NO locales so that COMPAT locales do not precede
201 * those locales during ResourceBundle search path.
202 */
203 private static Locale getEquivalentLoc(Locale locale) {
204 switch (locale.toString()) {
205 case "zh_HK":
206 return Locale.forLanguageTag("zh-Hant-HK");
207 case "no":
208 case "no_NO":
209 return Locale.forLanguageTag("nb");
210 }
211 return locale;
212 }
213
214 @Override
215 public boolean isSupportedProviderLocale(Locale locale, Set<String> langtags) {
216 return Locale.ROOT.equals(locale)
217 || langtags.contains(locale.stripExtensions().toLanguageTag())
218 || langtags.contains(getEquivalentLoc(locale).toLanguageTag());
219 }
220 }
|