Class LocaleDisplayNames


  • public abstract class LocaleDisplayNames
    extends Object
    Returns display names of ULocales and components of ULocales. For more information on language, script, region, variant, key, and values, see ULocale.
    Status:
    Stable ICU 4.4.
    • Constructor Detail

      • LocaleDisplayNames

        @Deprecated
        protected LocaleDisplayNames()
        Deprecated.
        This API is ICU internal only.
        Sole constructor. (For invocation by subclass constructors, typically implicit.)
        Status:
        Internal. This API is ICU internal only.
    • Method Detail

      • getInstance

        public static LocaleDisplayNames getInstance​(ULocale locale,
                                                     LocaleDisplayNames.DialectHandling dialectHandling)
        Returns an instance of LocaleDisplayNames that returns names formatted for the provided locale, using the provided dialectHandling.
        Parameters:
        locale - the display locale
        dialectHandling - how to select names for locales
        Returns:
        a LocaleDisplayNames instance
        Status:
        Stable ICU 4.4.
      • getInstance

        public static LocaleDisplayNames getInstance​(ULocale locale,
                                                     DisplayContext... contexts)
        Returns an instance of LocaleDisplayNames that returns names formatted for the provided locale, using the provided DisplayContext settings
        Parameters:
        locale - the display locale
        contexts - one or more context settings (e.g. for dialect handling, capitalization, etc.
        Returns:
        a LocaleDisplayNames instance
        Status:
        Stable ICU 51.
      • getInstance

        public static LocaleDisplayNames getInstance​(Locale locale,
                                                     DisplayContext... contexts)
        Returns an instance of LocaleDisplayNames that returns names formatted for the provided Locale, using the provided DisplayContext settings
        Parameters:
        locale - the display Locale
        contexts - one or more context settings (e.g. for dialect handling, capitalization, etc.
        Returns:
        a LocaleDisplayNames instance
        Status:
        Stable ICU 54.
      • getLocale

        public abstract ULocale getLocale()
        Returns the locale used to determine the display names. This is not necessarily the same locale passed to getInstance(com.ibm.icu.util.ULocale).
        Returns:
        the display locale
        Status:
        Stable ICU 4.4.
      • getDialectHandling

        public abstract LocaleDisplayNames.DialectHandling getDialectHandling()
        Returns the dialect handling used in the display names.
        Returns:
        the dialect handling enum
        Status:
        Stable ICU 4.4.
      • getContext

        public abstract DisplayContext getContext​(DisplayContext.Type type)
        Returns the current value for a specified DisplayContext.Type.
        Parameters:
        type - the DisplayContext.Type whose value to return
        Returns:
        the current DisplayContext setting for the specified type
        Status:
        Stable ICU 51.
      • localeDisplayName

        public abstract String localeDisplayName​(ULocale locale)
        Returns the display name of the provided ulocale. When no display names are available for all or portions of the original locale ID, those portions may be used directly (possibly in a more canonical form) as part of the returned display name.
        Parameters:
        locale - the locale whose display name to return
        Returns:
        the display name of the provided locale
        Status:
        Stable ICU 4.4.
      • localeDisplayName

        public abstract String localeDisplayName​(Locale locale)
        Returns the display name of the provided locale. When no display names are available for all or portions of the original locale ID, those portions may be used directly (possibly in a more canonical form) as part of the returned display name.
        Parameters:
        locale - the locale whose display name to return
        Returns:
        the display name of the provided locale
        Status:
        Stable ICU 4.4.
      • localeDisplayName

        public abstract String localeDisplayName​(String localeId)
        Returns the display name of the provided locale id. When no display names are available for all or portions of the original locale ID, those portions may be used directly (possibly in a more canonical form) as part of the returned display name.
        Parameters:
        localeId - the id of the locale whose display name to return
        Returns:
        the display name of the provided locale
        Status:
        Stable ICU 4.4.
      • languageDisplayName

        public abstract String languageDisplayName​(String lang)
        Returns the display name of the provided language code.
        Parameters:
        lang - the language code
        Returns:
        the display name of the provided language code
        Status:
        Stable ICU 4.4.
      • scriptDisplayName

        public abstract String scriptDisplayName​(String script)
        Returns the display name of the provided script code.
        Parameters:
        script - the script code
        Returns:
        the display name of the provided script code
        Status:
        Stable ICU 4.4.
      • scriptDisplayNameInContext

        @Deprecated
        public String scriptDisplayNameInContext​(String script)
        Deprecated.
        This API is ICU internal only.
        Returns the display name of the provided script code when used in the context of a full locale name.
        Parameters:
        script - the script code
        Returns:
        the display name of the provided script code
        Status:
        Internal. This API is ICU internal only.
      • scriptDisplayName

        public abstract String scriptDisplayName​(int scriptCode)
        Returns the display name of the provided script code. See UScript for recognized script codes.
        Parameters:
        scriptCode - the script code number
        Returns:
        the display name of the provided script code
        Status:
        Stable ICU 4.4.
      • regionDisplayName

        public abstract String regionDisplayName​(String region)
        Returns the display name of the provided region code.
        Parameters:
        region - the region code
        Returns:
        the display name of the provided region code
        Status:
        Stable ICU 4.4.
      • variantDisplayName

        public abstract String variantDisplayName​(String variant)
        Returns the display name of the provided variant.
        Parameters:
        variant - the variant string
        Returns:
        the display name of the provided variant
        Status:
        Stable ICU 4.4.
      • keyDisplayName

        public abstract String keyDisplayName​(String key)
        Returns the display name of the provided locale key.
        Parameters:
        key - the locale key name
        Returns:
        the display name of the provided locale key
        Status:
        Stable ICU 4.4.
      • keyValueDisplayName

        public abstract String keyValueDisplayName​(String key,
                                                   String value)
        Returns the display name of the provided value (used with the provided key).
        Parameters:
        key - the locale key name
        value - the locale key's value
        Returns:
        the display name of the provided value
        Status:
        Stable ICU 4.4.
      • getUiList

        public List<LocaleDisplayNames.UiListItem> getUiList​(Set<ULocale> localeSet,
                                                             boolean inSelf,
                                                             Comparator<Object> collator)
        Return a list of information used to construct a UI list of locale names.
        Parameters:
        collator - how to collate—should normally be Collator.getInstance(getDisplayLocale())
        inSelf - if true, compares the nameInSelf, otherwise the nameInDisplayLocale. Set depending on which field (displayLocale vs self) is to show up in the UI. If both are to show up in the UI, then it should be the one used for the primary sort order.
        localeSet - a list of locales to present in a UI list. The casing uses the settings in the LocaleDisplayNames instance.
        Returns:
        an ordered list of UiListItems.
        Throws:
        IllformedLocaleException - if any of the locales in localeSet are malformed.
        Status:
        Stable ICU 55.
      • getUiListCompareWholeItems

        public abstract List<LocaleDisplayNames.UiListItem> getUiListCompareWholeItems​(Set<ULocale> localeSet,
                                                                                       Comparator<LocaleDisplayNames.UiListItem> comparator)
        Return a list of information used to construct a UI list of locale names, providing more access to control the sorting. Normally use getUiList instead.
        Parameters:
        comparator - how to sort the UiListItems in the result.
        localeSet - a list of locales to present in a UI list. The casing uses the settings in the LocaleDisplayNames instance.
        Returns:
        an ordered list of UiListItems.
        Throws:
        IllformedLocaleException - if any of the locales in localeSet are malformed.
        Status:
        Stable ICU 55.