< prev index next >

src/java.base/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java

Print this page


   1 /*
   2  * Copyright (c) 2012, 2016, 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


 493             }
 494 
 495             @Override
 496             public boolean isSupportedLocale(Locale locale) {
 497                 return supportedLocaleSet.contains(locale.stripExtensions()) &&
 498                        locale.getLanguage().equals(nativeDisplayLanguage);
 499             }
 500 
 501             @Override
 502             public String getDisplayLanguage(String languageCode, Locale locale) {
 503                 // Retrieves the display language name by calling
 504                 // GetLocaleInfoEx(LOCALE_SLOCALIZEDLANGUAGENAME).
 505                 return getDisplayString(locale.toLanguageTag(),
 506                             DN_LOCALE_LANGUAGE, languageCode);
 507             }
 508 
 509             @Override
 510             public String getDisplayCountry(String countryCode, Locale locale) {
 511                 // Retrieves the display country name by calling
 512                 // GetLocaleInfoEx(LOCALE_SLOCALIZEDCOUNTRYNAME).
 513                 return getDisplayString(locale.toLanguageTag(),
 514                             DN_LOCALE_REGION, nativeDisplayLanguage+"-"+countryCode);







 515             }
 516 
 517             @Override
 518             public String getDisplayScript(String scriptCode, Locale locale) {
 519                 return null;
 520             }
 521 
 522             @Override
 523             public String getDisplayVariant(String variantCode, Locale locale) {
 524                 return null;
 525             }
 526         };
 527     }
 528 
 529     public static JavaTimeDateTimePatternProvider getJavaTimeDateTimePatternProvider() {
 530         return new JavaTimeDateTimePatternProvider() {
 531             @Override
 532             public Locale[] getAvailableLocales() {
 533                 return getSupportedCalendarLocales();
 534             }


   1 /*
   2  * Copyright (c) 2012, 2019, 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


 493             }
 494 
 495             @Override
 496             public boolean isSupportedLocale(Locale locale) {
 497                 return supportedLocaleSet.contains(locale.stripExtensions()) &&
 498                        locale.getLanguage().equals(nativeDisplayLanguage);
 499             }
 500 
 501             @Override
 502             public String getDisplayLanguage(String languageCode, Locale locale) {
 503                 // Retrieves the display language name by calling
 504                 // GetLocaleInfoEx(LOCALE_SLOCALIZEDLANGUAGENAME).
 505                 return getDisplayString(locale.toLanguageTag(),
 506                             DN_LOCALE_LANGUAGE, languageCode);
 507             }
 508 
 509             @Override
 510             public String getDisplayCountry(String countryCode, Locale locale) {
 511                 // Retrieves the display country name by calling
 512                 // GetLocaleInfoEx(LOCALE_SLOCALIZEDCOUNTRYNAME).
 513                 String str = getDisplayString(locale.toLanguageTag(),
 514                                  DN_LOCALE_REGION,
 515                                  nativeDisplayLanguage+"-"+countryCode);
 516                 // Hack: Windows 10 returns translated "Unknown Region (XX)"
 517                 // for localized XX region name. Take that as not known.
 518                 if (str != null && str.contains("("+countryCode+")")) {
 519                     return null;
 520                 }
 521                 return str;
 522             }
 523 
 524             @Override
 525             public String getDisplayScript(String scriptCode, Locale locale) {
 526                 return null;
 527             }
 528 
 529             @Override
 530             public String getDisplayVariant(String variantCode, Locale locale) {
 531                 return null;
 532             }
 533         };
 534     }
 535 
 536     public static JavaTimeDateTimePatternProvider getJavaTimeDateTimePatternProvider() {
 537         return new JavaTimeDateTimePatternProvider() {
 538             @Override
 539             public Locale[] getAvailableLocales() {
 540                 return getSupportedCalendarLocales();
 541             }


< prev index next >