当前位置: 首页>>代码示例>>Java>>正文


Java LocaleNameProvider.getAvailableLocales方法代码示例

本文整理汇总了Java中java.util.spi.LocaleNameProvider.getAvailableLocales方法的典型用法代码示例。如果您正苦于以下问题:Java LocaleNameProvider.getAvailableLocales方法的具体用法?Java LocaleNameProvider.getAvailableLocales怎么用?Java LocaleNameProvider.getAvailableLocales使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.spi.LocaleNameProvider的用法示例。


在下文中一共展示了LocaleNameProvider.getAvailableLocales方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDisplayLanguage

import java.util.spi.LocaleNameProvider; //导入方法依赖的package包/类
/**
 * <p>
 * Gets the name of the language specified by this locale, in a form suitable
 * for display to the user.  If possible, the display name will be localized
 * to the specified locale.  For example, if the locale instance is
 * <code>Locale.GERMANY</code>, and the specified locale is <code>Locale.UK</code>,
 * the result would be 'German'.  Using the German locale would instead give
 * 'Deutsch'.  If the display name can not be localized to the supplied
 * locale, it will fall back on other output in the following order:
 * </p>
 * <ul>
 * <li>the display name in the default locale</li>
 * <li>the display name in English</li>
 * <li>the ISO code</li>
 * </ul>
 * <p>
 * If the language is unspecified by this locale, then the empty string is
 * returned.
 * </p>
 *
 * @param inLocale the locale to use for formatting the display string.
 * @return the language name of this locale localized to the given locale,
 *         with the default locale, English and the ISO code as backups.
 * @throws NullPointerException if the supplied locale is null.
 */
public String getDisplayLanguage(Locale inLocale)
{
  if (language.isEmpty())
    return "";
  try
    {
      ResourceBundle res =
        ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
                                 inLocale,
                                 ClassLoader.getSystemClassLoader());

      return res.getString("languages." + language);
    }
  catch (MissingResourceException e)
    {
      /* This means runtime support for the locale
       * is not available, so we check providers. */
    }
  for (LocaleNameProvider p :
         ServiceLoader.load(LocaleNameProvider.class))
    {
      for (Locale loc : p.getAvailableLocales())
        {
          if (loc.equals(inLocale))
            {
              String locLang = p.getDisplayLanguage(language,
                                                    inLocale);
              if (locLang != null)
                return locLang;
              break;
            }
        }
    }
  if (inLocale.equals(Locale.ROOT)) // Base case
    return language;
  return getDisplayLanguage(LocaleHelper.getFallbackLocale(inLocale));
}
 
开发者ID:vilie,项目名称:javify,代码行数:63,代码来源:Locale.java

示例2: getDisplayCountry

import java.util.spi.LocaleNameProvider; //导入方法依赖的package包/类
/**
 * <p>
 * Gets the name of the country specified by this locale, in a form suitable
 * for display to the user.  If possible, the display name will be localized
 * to the specified locale.  For example, if the locale instance is
 * <code>Locale.GERMANY</code>, and the specified locale is <code>Locale.UK</code>,
 * the result would be 'Germany'.  Using the German locale would instead give
 * 'Deutschland'.  If the display name can not be localized to the supplied
 * locale, it will fall back on other output in the following order:
 * </p>
 * <ul>
 * <li>the display name in the default locale</li>
 * <li>the display name in English</li>
 * <li>the ISO code</li>
 * </ul>
 * <p>
 * If the country is unspecified by this locale, then the empty string is
 * returned.
 * </p>
 *
 * @param inLocale the locale to use for formatting the display string.
 * @return the country name of this locale localized to the given locale,
 *         with the default locale, English and the ISO code as backups.
 * @throws NullPointerException if the supplied locale is null.
 */
public String getDisplayCountry(Locale inLocale)
{
  if (country.isEmpty())
    return "";
  try
    {
      ResourceBundle res =
        ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
                                 inLocale,
                                 ClassLoader.getSystemClassLoader());

      return res.getString("territories." + country);
    }
  catch (MissingResourceException e)
    {
      /* This means runtime support for the locale
       * is not available, so we check providers. */
    }
  for (LocaleNameProvider p :
         ServiceLoader.load(LocaleNameProvider.class))
    {
      for (Locale loc : p.getAvailableLocales())
        {
          if (loc.equals(inLocale))
            {
              String locCountry = p.getDisplayCountry(country,
                                                      inLocale);
              if (locCountry != null)
                return locCountry;
              break;
            }
        }
    }
  if (inLocale.equals(Locale.ROOT)) // Base case
    return country;
  return getDisplayCountry(LocaleHelper.getFallbackLocale(inLocale));
}
 
开发者ID:vilie,项目名称:javify,代码行数:63,代码来源:Locale.java

示例3: getDisplayVariant

import java.util.spi.LocaleNameProvider; //导入方法依赖的package包/类
/**
 * <p>
 * Gets the name of the variant specified by this locale, in a form suitable
 * for display to the user.  If possible, the display name will be localized
 * to the specified locale.  For example, if the locale instance is a revised
 * variant, and the specified locale is <code>Locale.UK</code>, the result
 * would be 'REVISED'.  Using the German locale would instead give
 * 'Revidiert'.  If the display name can not be localized to the supplied
 * locale, it will fall back on other output in the following order:
 * </p>
 * <ul>
 * <li>the display name in the default locale</li>
 * <li>the display name in English</li>
 * <li>the ISO code</li>
 * </ul>
 * <p>
 * If the variant is unspecified by this locale, then the empty string is
 * returned.
 * </p>
 *
 * @param inLocale the locale to use for formatting the display string.
 * @return the variant name of this locale localized to the given locale,
 *         with the default locale, English and the ISO code as backups.
 * @throws NullPointerException if the supplied locale is null.
 */
public String getDisplayVariant(Locale inLocale)
{
  if (variant.isEmpty())
    return "";
  try
    {
      ResourceBundle res =
        ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
                                 inLocale,
                                 ClassLoader.getSystemClassLoader());

      return res.getString("variants." + variant);
    }
  catch (MissingResourceException e)
    {
      /* This means runtime support for the locale
       * is not available, so we check providers. */
    }
  for (LocaleNameProvider p :
         ServiceLoader.load(LocaleNameProvider.class))
    {
      for (Locale loc : p.getAvailableLocales())
        {
          if (loc.equals(inLocale))
            {
              String locVar = p.getDisplayVariant(variant,
                                                  inLocale);
              if (locVar != null)
                return locVar;
              break;
            }
        }
    }
  if (inLocale.equals(Locale.ROOT)) // Base case
    return country;
  return getDisplayVariant(LocaleHelper.getFallbackLocale(inLocale));
}
 
开发者ID:vilie,项目名称:javify,代码行数:63,代码来源:Locale.java

示例4: getDisplayLanguage

import java.util.spi.LocaleNameProvider; //导入方法依赖的package包/类
/**
  * <p>
  * Gets the name of the language specified by this locale, in a form suitable
  * for display to the user.  If possible, the display name will be localized
  * to the specified locale.  For example, if the locale instance is
  * <code>Locale.GERMANY</code>, and the specified locale is <code>Locale.UK</code>,
  * the result would be 'German'.  Using the German locale would instead give
  * 'Deutsch'.  If the display name can not be localized to the supplied
  * locale, it will fall back on other output in the following order:
  * </p>
  * <ul>
  * <li>the display name in the default locale</li>
  * <li>the display name in English</li>
  * <li>the ISO code</li>
  * </ul>
  * <p>
  * If the language is unspecified by this locale, then the empty string is
  * returned.
  * </p>
  *
  * @param inLocale the locale to use for formatting the display string.
  * @return the language name of this locale localized to the given locale,
  *         with the default locale, English and the ISO code as backups.
  * @throws NullPointerException if the supplied locale is null.
  */
 public String getDisplayLanguage(Locale inLocale)
 {
   if (language.isEmpty())
     return "";
   try
     {
ResourceBundle res =
         ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
                                  inLocale,
                                  ClassLoader.getSystemClassLoader());

       return res.getString("languages." + language);
     }
   catch (MissingResourceException e)
     {
/* This means runtime support for the locale
 * is not available, so we check providers. */
     }
   for (LocaleNameProvider p :
   ServiceLoader.load(LocaleNameProvider.class))
     {
for (Locale loc : p.getAvailableLocales())
  {
    if (loc.equals(inLocale))
      {
	String locLang = p.getDisplayLanguage(language,
					      inLocale);
	if (locLang != null)
	  return locLang;
	break;
      }
  }
     }
   if (inLocale.equals(Locale.ROOT)) // Base case
     return language;
   return getDisplayLanguage(LocaleHelper.getFallbackLocale(inLocale));
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:63,代码来源:Locale.java

示例5: getDisplayCountry

import java.util.spi.LocaleNameProvider; //导入方法依赖的package包/类
/**
  * <p>
  * Gets the name of the country specified by this locale, in a form suitable
  * for display to the user.  If possible, the display name will be localized
  * to the specified locale.  For example, if the locale instance is
  * <code>Locale.GERMANY</code>, and the specified locale is <code>Locale.UK</code>,
  * the result would be 'Germany'.  Using the German locale would instead give
  * 'Deutschland'.  If the display name can not be localized to the supplied
  * locale, it will fall back on other output in the following order:
  * </p>
  * <ul>
  * <li>the display name in the default locale</li>
  * <li>the display name in English</li>
  * <li>the ISO code</li>
  * </ul>
  * <p>
  * If the country is unspecified by this locale, then the empty string is
  * returned.
  * </p>
  *
  * @param inLocale the locale to use for formatting the display string.
  * @return the country name of this locale localized to the given locale,
  *         with the default locale, English and the ISO code as backups.
  * @throws NullPointerException if the supplied locale is null.
  */
 public String getDisplayCountry(Locale inLocale)
 {
   if (country.isEmpty())
     return "";
   try
     {
       ResourceBundle res =
         ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
                                  inLocale,
                                  ClassLoader.getSystemClassLoader());
   
       return res.getString("territories." + country);
     }
   catch (MissingResourceException e)
     {
/* This means runtime support for the locale
 * is not available, so we check providers. */
     }
   for (LocaleNameProvider p :
   ServiceLoader.load(LocaleNameProvider.class))
     {
for (Locale loc : p.getAvailableLocales())
  {
    if (loc.equals(inLocale))
      {
	String locCountry = p.getDisplayCountry(country,
						inLocale);
	if (locCountry != null)
	  return locCountry;
	break;
      }
  }
     }
   if (inLocale.equals(Locale.ROOT)) // Base case
     return country;
   return getDisplayCountry(LocaleHelper.getFallbackLocale(inLocale));
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:63,代码来源:Locale.java

示例6: getDisplayVariant

import java.util.spi.LocaleNameProvider; //导入方法依赖的package包/类
/**
  * <p>
  * Gets the name of the variant specified by this locale, in a form suitable
  * for display to the user.  If possible, the display name will be localized
  * to the specified locale.  For example, if the locale instance is a revised
  * variant, and the specified locale is <code>Locale.UK</code>, the result
  * would be 'REVISED'.  Using the German locale would instead give
  * 'Revidiert'.  If the display name can not be localized to the supplied
  * locale, it will fall back on other output in the following order:
  * </p>
  * <ul>
  * <li>the display name in the default locale</li>
  * <li>the display name in English</li>
  * <li>the ISO code</li>
  * </ul>
  * <p>
  * If the variant is unspecified by this locale, then the empty string is
  * returned.
  * </p>
  *
  * @param inLocale the locale to use for formatting the display string.
  * @return the variant name of this locale localized to the given locale,
  *         with the default locale, English and the ISO code as backups.
  * @throws NullPointerException if the supplied locale is null.
  */
 public String getDisplayVariant(Locale inLocale)
 {
   if (variant.isEmpty())
     return "";
   try
     {
       ResourceBundle res =
         ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
                                  inLocale,
                                  ClassLoader.getSystemClassLoader());
   
       return res.getString("variants." + variant);
     }
   catch (MissingResourceException e)
     {
/* This means runtime support for the locale
 * is not available, so we check providers. */
     }
   for (LocaleNameProvider p :
   ServiceLoader.load(LocaleNameProvider.class))
     {
for (Locale loc : p.getAvailableLocales())
  {
    if (loc.equals(inLocale))
      {
	String locVar = p.getDisplayVariant(variant,
					    inLocale);
	if (locVar != null)
	  return locVar;
	break;
      }
  }
     }
   if (inLocale.equals(Locale.ROOT)) // Base case
     return country;
   return getDisplayVariant(LocaleHelper.getFallbackLocale(inLocale));
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:63,代码来源:Locale.java

示例7: addImpl

import java.util.spi.LocaleNameProvider; //导入方法依赖的package包/类
@Override
public void addImpl(LocaleNameProvider impl) {
    for (Locale l : impl.getAvailableLocales()) {
        map.putIfAbsent(l, impl);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:SPILocaleProviderAdapter.java


注:本文中的java.util.spi.LocaleNameProvider.getAvailableLocales方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。