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


Java Locale.toString方法代码示例

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


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

示例1: getLCIDFromLocale

import java.util.Locale; //导入方法依赖的package包/类
private static short getLCIDFromLocale(Locale locale) {
    // optimize for common case
    if (locale.equals(Locale.US)) {
        return US_LCID;
    }

    if (lcidMap == null) {
        createLCIDMap();
    }

    String key = locale.toString();
    while (!"".equals(key)) {
        Short lcidObject = lcidMap.get(key);
        if (lcidObject != null) {
            return lcidObject.shortValue();
        }
        int pos = key.lastIndexOf('_');
        if (pos < 1) {
            return US_LCID;
        }
        key = key.substring(0, pos);
    }

    return US_LCID;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:TrueTypeFont.java

示例2: getLCIDFromLocale

import java.util.Locale; //导入方法依赖的package包/类
private static short getLCIDFromLocale(Locale locale) {
    // optimize for common case
    if (locale.equals(Locale.US)) {
        return US_LCID;
    }

    if (lcidMap == null) {
        createLCIDMap();
    }

    String key = locale.toString();
    while (!"".equals(key)) {
        Short lcidObject = (Short) lcidMap.get(key);
        if (lcidObject != null) {
            return lcidObject.shortValue();
        }
        int pos = key.lastIndexOf('_');
        if (pos < 1) {
            return US_LCID;
        }
        key = key.substring(0, pos);
    }

    return US_LCID;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:TrueTypeFont.java

示例3: toULocale6

import java.util.Locale; //导入方法依赖的package包/类
private static ULocale toULocale6(Locale loc) {
    ULocale uloc = null;
    String locStr = loc.toString();
    if (locStr.length() == 0) {
        uloc = ULocale.ROOT;
    } else {
        for (int i = 0; i < JAVA6_MAPDATA.length; i++) {
            if (JAVA6_MAPDATA[i][0].equals(locStr)) {
                LocaleIDParser p = new LocaleIDParser(JAVA6_MAPDATA[i][1]);
                p.setKeywordValue(JAVA6_MAPDATA[i][2], JAVA6_MAPDATA[i][3]);
                locStr = p.getName();
                break;
            }
        }
        uloc = new ULocale(getName(locStr), loc);
    }
    return uloc;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:19,代码来源:ULocale.java

示例4: _getLocaleString

import java.util.Locale; //导入方法依赖的package包/类
private String _getLocaleString (FacesContext context)
{
  Locale dateTimeConverterLocale = getLocale();
  if (dateTimeConverterLocale != null)
  {
    Locale defaultLocale = RenderingContext.getCurrentInstance()
        .getLocaleContext().getFormattingLocale();
    if (!(dateTimeConverterLocale.equals (defaultLocale)))
    {
      String loc = dateTimeConverterLocale.toString();
      StringBuffer sb = new StringBuffer (2 + loc.length());
      sb.append ("'");
      sb.append (loc);
      sb.append ("'");
      return (sb.toString());
    }
  }
  return "null";
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:20,代码来源:DateTimeConverter.java

示例5: getHelpTopicURL

import java.util.Locale; //导入方法依赖的package包/类
/**
 * The getHelpTopicURL() method should return a string URL
 * for the given key string (topic-id)
 * <p>
 * @param key criterion (topic-id)
 */
@Override
protected String getHelpTopicURL(Object key)
{
  String helpURL = null;
  if (key != null)
  {
    FacesContext context = FacesContext.getCurrentInstance();
    Locale locale = context.getViewRoot().getLocale();
    String servletLocation = _getLocaleSpecificServlet(context);
    boolean hasQueryParams = servletLocation.indexOf('?') >= 0;
    helpURL = (servletLocation + (hasQueryParams ? "&" : "?") +
               _TOPIC_PARAM + "=" + key.toString() + "&" +
               _LOCALE_PARAM + "=" + locale.toString());
  }

  return helpURL;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:24,代码来源:OracleHelpProvider.java

示例6: getHelpSystemURL

import java.util.Locale; //导入方法依赖的package包/类
/**
 * The getHelpSystemURL() method should return a string URL
 * for the given key string (HelpProvider key constant)
 * <p>
 * @param key criterion (HelpProvider key constant)
 */
@Override
protected String getHelpSystemURL(Object key)
{
  if (HelpProvider.FRONT_PAGE_KEY.equals(key))
  {
    FacesContext context = FacesContext.getCurrentInstance();
    Locale locale = context.getViewRoot().getLocale();
    String servletLocation = _getLocaleSpecificServlet(context);
    if (servletLocation != null)
    {
      boolean hasQueryParams = servletLocation.indexOf('?') >= 0;
      servletLocation  = servletLocation + (hasQueryParams ? "&" : "?") +
           _LOCALE_PARAM + "=" + locale.toString();
    }

    return servletLocation;
  }

  return null;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:27,代码来源:OracleHelpProvider.java

示例7: getBundle

import java.util.Locale; //导入方法依赖的package包/类
public ResourceBundle getBundle(String baseName, Locale locale) throws MissingResourceException {
  if (baseName == null || locale == null) {
    return null;
  }
  // Get the resource bundle, if not already present
  String key = baseName + "_" + locale.toString();
  xLogger.fine("Resources.getBundle(): trying first key = {0}", key);
  ResourceBundle bundle = rmap.get(key);
  if (bundle == null) {
    key = baseName + "_" + locale.getLanguage();
    bundle = rmap.get(key);
    xLogger.fine("Resources.getBundle(): tried second key = {0}, bundle = {1}", key, bundle);
    if (bundle == null) {
      bundle = getUTF8Bundle(baseName, locale);
      key =
          baseName + "_" + bundle.getLocale()
              .toString(); // actual (fallback) locale used to get the file
      xLogger.fine(
          "Resource.getBundle(): getting it first time using locale = {0}, actual key = {0}",
          locale.toString(), key);
      rmap.put(key, bundle);
    }
  }
  return bundle;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:26,代码来源:Resources.java

示例8: addLikelySubtags

import java.util.Locale; //导入方法依赖的package包/类
private static String addLikelySubtags(Locale locale) {
    String localeStr = locale.toString();
    try {
        if (sAddLikelySubtagsMethod != null) {
            return (String) sAddLikelySubtagsMethod.invoke(null, new Object[]{localeStr});
        }
    } catch (IllegalAccessException e) {
        Log.w(TAG, e);
    } catch (InvocationTargetException e2) {
        Log.w(TAG, e2);
    }
    return localeStr;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:ICUCompatIcs.java

示例9: LocaleDescriptor

import java.util.Locale; //导入方法依赖的package包/类
public LocaleDescriptor(Locale locale, String tag) {
    this.tag = tag;

    final String displayName;

    if (languageCodeToNameMap.containsKey(locale.getLanguage())) {
        displayName = languageCodeToNameMap.get(locale.getLanguage());
    } else {
        displayName = locale.getDisplayName(locale);
    }

    if (TextUtils.isEmpty(displayName)) {
        // There's nothing sane we can do.
        Log.w(LOG_TAG, "Display name is empty. Using " + locale.toString());
        this.nativeName = locale.toString();
        return;
    }

    // For now, uppercase the first character of LTR locale names.
    // This is pretty much what Android does. This is a reasonable hack
    // for Bug 1014602, but it won't generalize to all locales.
    final byte directionality = Character.getDirectionality(displayName.charAt(0));
    if (directionality == Character.DIRECTIONALITY_LEFT_TO_RIGHT) {
        this.nativeName = displayName.substring(0, 1).toUpperCase(locale) +
                displayName.substring(1);
        return;
    }

    this.nativeName = displayName;
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:31,代码来源:LocaleListPreference.java

示例10: prepareModel

import java.util.Locale; //导入方法依赖的package包/类
@Override
protected void prepareModel(RenderContext info)
{
	super.prepareModel(info);
	final MultiEditBoxState state = getState(info);
	Map<String, HtmlValueState> map = new LinkedHashMap<String, HtmlValueState>();

	TreeSet<Locale> languages = new TreeSet<Locale>(localeComparator);
	languages.addAll(getContributeLocales());
	languages.addAll(getBundleLocales(info));

	for( Locale locale : languages )
	{
		String id = locale.toString();
		HtmlValueState valState = langMap.getValueState(info, id);

		// Build format into: Language [(country)] where country
		String displayString = Constants.BLANK;

		String displayLanguage = locale.getDisplayLanguage();
		String displayCountry = locale.getCountry();
		displayString = !Check.isEmpty(displayCountry) ? MessageFormat.format(
			"{0} ({1})", displayLanguage, displayCountry) : displayLanguage; //$NON-NLS-1$

		valState.setLabel(new TextLabel(displayString));
		map.put(id, valState);
	}
	state.setSize(size);
	state.setLocaleMap(map);
}
 
开发者ID:equella,项目名称:Equella,代码行数:31,代码来源:MultiEditBox.java

示例11: writePropertiesSet

import java.util.Locale; //导入方法依赖的package包/类
public void writePropertiesSet(	List<MessageResourceEntry> entries,
								Set<Locale> locales,
								Locale defaultLocale,
								String resourceName,
								File outputDir,
								String encoding,
								long lastModified) throws I18nException
{
	if (!outputDir.exists())
	{
		LOG.info("create output directory  [{}]", outputDir.getName());
		outputDir.mkdirs();
	}

	String fileName = resourceName + ".properties";
	File master = new File(outputDir, fileName);
	if (this.checkLastModified && master.exists() && master.lastModified() >= lastModified)
	{
		LOG.info("skip properties creation, files ({}) are newer then source ({})", new Date(master.lastModified()), new Date(lastModified));
		return;
	}
	LOG.info("write master properties file {}", master.getAbsoluteFile());
	this.writeProperties(entries, defaultLocale, master, encoding);
	for (Locale locale : locales)
	{
		String name = resourceName + "_" + locale.toString() + ".properties";
		File file = new File(outputDir, name);
		LOG.info("write locale [{}] properties file {}", locale, file);
		this.writeProperties(entries, locale, file, encoding);
	}
}
 
开发者ID:namics,项目名称:spring-i18n-support,代码行数:32,代码来源:PropertiesWriter.java

示例12: PopupPanel

import java.util.Locale; //导入方法依赖的package包/类
public PopupPanel(JPopupMenu popup)
{
	this.popup = popup;
	this.mapping = new HashMap<Locale, JTextComponent>();

	setLayout(new MigLayout("wrap,fill", "[grow]r[]", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	for( Locale locale : editableLocales )
	{
		String actionCommand = locale.toString();
		JTextComponent field = getTextComponent();

		JButton button = new JButton(locale.getDisplayName());
		button.setActionCommand(actionCommand);
		button.addActionListener(this);

		field.setText(textMap.get(locale));
		mapping.put(locale, field);

		add(prepareTextComponent(field), "growx, sizegroup f, hmax 100px"); //$NON-NLS-1$
		add(button, "sizegroup b"); //$NON-NLS-1$
	}

	closeButton = new JLinkButton(CurrentLocale.get("prompts.close")); //$NON-NLS-1$
	closeButton.addActionListener(this);
	closeButton.setActionCommand(""); //$NON-NLS-1$
	closeButton.setIcon(new ArrowIcon(SwingConstants.NORTH));
	closeButton.setHorizontalTextPosition(SwingConstants.LEFT);
	add(closeButton, "span 2, align right, shrink"); //$NON-NLS-1$

	setBorder(BorderFactory.createLineBorder(Color.BLACK));

	final int width = Math.max(400, I18nTextField.this.getSize().width);
	setPreferredSize(new Dimension(width, getPreferredSize().height));

	popup.addPopupMenuListener(this);
}
 
开发者ID:equella,项目名称:Equella,代码行数:37,代码来源:I18nTextField.java

示例13: getEquivalentLoc

import java.util.Locale; //导入方法依赖的package包/类
/**
 * This method returns equivalent CLDR supported locale for zh-HK,
 * no, no-NO locales so that COMPAT locales do not precede
 * those locales during ResourceBundle search path.
 */
private static Locale getEquivalentLoc(Locale locale) {
    switch (locale.toString()) {
        case "zh_HK":
            return Locale.forLanguageTag("zh-Hant-HK");
        case "no":
        case "no_NO":
            return Locale.forLanguageTag("nb");
    }
    return locale;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:CLDRLocaleProviderAdapter.java

示例14: localeKey

import java.util.Locale; //导入方法依赖的package包/类
/** Compute and return a key to be used in caching information by a Locale.
 * This appends the variation for the authenticated user to the toString() output of the Locale object.
 * @param locale The locale for which a key is desired
 * @return a key to be used in caching information by a Locale.
 */
protected String localeKey(Locale locale) {
    if (locale == null)
        return "";
    else if (locale.getVariant() != null && locale.getVariant().length() > 0)
        return locale.toString();
    else
        return locale.toString() + '_' + VariationContext.getVariation();
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:14,代码来源:PropertyMessageResources.java

示例15: getResourceFromDatabase

import java.util.Locale; //导入方法依赖的package包/类
/**
 * Depending on the number of key values passed queries for the localized
 * string matching the given resource. If two matches are found, always the
 * one matching the given key, not it's parent key, is returned.
 *
 * @param objectType
 *            The object type the localized resource has to be retrieved
 *            for.
 * @param locale
 *            The locale the information has to be retrieved for.
 * @param keysForObjects
 *            The key values the resource must have assigned.
 * @return The localized resource.
 */
private LocalizedResource getResourceFromDatabase(
        LocalizedObjectTypes objectType, Locale locale,
        KeysForOneObject keysForObjects) {

    LocalizedResource resource = null;
    if (keysForObjects.getAllObjKeys().size() == 1) {
        LocalizedResource template = new LocalizedResource(
                locale.toString(), keysForObjects.getPrimaryObjKey()
                        .longValue(), objectType);
        resource = (LocalizedResource) dm.find(template);
    } else {
        Query query = dm
                .createNamedQuery("LocalizedResource.getForCurrAndParentKey");
        query.setParameter("locale", locale.getLanguage());
        query.setParameter("objectType", objectType);
        query.setParameter("objectKeyChild",
                keysForObjects.getPrimaryObjKey());
        query.setParameter("objectKeyParent", keysForObjects
                .getAllObjKeys().get(1));

        List<LocalizedResource> resultList = ParameterizedTypes.list(
                query.getResultList(), LocalizedResource.class);
        if (resultList.size() == 1) {
            resource = resultList.get(0);
        } else if (resultList.size() == 2) {
            if (resultList.get(0).getObjectKey() == keysForObjects
                    .getPrimaryObjKey().longValue()) {
                resource = resultList.get(0);
            } else {
                resource = resultList.get(1);
            }
        }
    }

    return resource;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:51,代码来源:LocalizerServiceBean.java


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