2 ******************************************************************************
3 * Copyright (C) 2010, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 ******************************************************************************
11 #include "unicode/utypes.h"
15 * \brief C++ API: Provides display names of Locale and its components.
18 #if !UCONFIG_NO_FORMATTING
20 #include "unicode/locid.h"
21 #include "unicode/uscript.h"
22 #include "unicode/uldnames.h"
27 * Returns display names of Locales and components of Locales. For
28 * more information on language, script, region, variant, key, and
32 class U_I18N_API LocaleDisplayNames
: public UObject
{
38 virtual ~LocaleDisplayNames();
41 * Convenience overload of
42 * {@link #createInstance(const Locale& locale, UDialectHandling dialectHandling)}
43 * that specifies STANDARD dialect handling.
44 * @param locale the display locale
45 * @return a LocaleDisplayNames instance
48 static LocaleDisplayNames
* U_EXPORT2
createInstance(const Locale
& locale
);
51 * Returns an instance of LocaleDisplayNames that returns names
52 * formatted for the provided locale, using the provided
55 * @param locale the display locale
56 * @param dialectHandling how to select names for locales
57 * @return a LocaleDisplayNames instance
60 static LocaleDisplayNames
* U_EXPORT2
createInstance(const Locale
& locale
,
61 UDialectHandling dialectHandling
);
65 * Returns the locale used to determine the display names. This is
66 * not necessarily the same locale passed to {@link #getInstance}.
67 * @return the display locale
70 virtual const Locale
& getLocale() const = 0;
73 * Returns the dialect handling used in the display names.
74 * @return the dialect handling enum
77 virtual UDialectHandling
getDialectHandling() const = 0;
79 // names for entire locales
81 * Returns the display name of the provided locale.
82 * @param locale the locale whose display name to return
83 * @param result receives the locale's display name
84 * @return the display name of the provided locale
87 virtual UnicodeString
& localeDisplayName(const Locale
& locale
,
88 UnicodeString
& result
) const = 0;
91 * Returns the display name of the provided locale id.
92 * @param localeId the id of the locale whose display name to return
93 * @param result receives the locale's display name
94 * @return the display name of the provided locale
97 virtual UnicodeString
& localeDisplayName(const char* localeId
,
98 UnicodeString
& result
) const = 0;
100 // names for components of a locale id
102 * Returns the display name of the provided language code.
103 * @param lang the language code
104 * @param result receives the language code's display name
105 * @return the display name of the provided language code
108 virtual UnicodeString
& languageDisplayName(const char* lang
,
109 UnicodeString
& result
) const = 0;
112 * Returns the display name of the provided script code.
113 * @param script the script code
114 * @param result receives the script code's display name
115 * @return the display name of the provided script code
118 virtual UnicodeString
& scriptDisplayName(const char* script
,
119 UnicodeString
& result
) const = 0;
122 * Returns the display name of the provided script code.
123 * @param scriptCode the script code number
124 * @param result receives the script code's display name
125 * @return the display name of the provided script code
128 virtual UnicodeString
& scriptDisplayName(UScriptCode scriptCode
,
129 UnicodeString
& result
) const = 0;
132 * Returns the display name of the provided region code.
133 * @param region the region code
134 * @param result receives the region code's display name
135 * @return the display name of the provided region code
138 virtual UnicodeString
& regionDisplayName(const char* region
,
139 UnicodeString
& result
) const = 0;
142 * Returns the display name of the provided variant.
143 * @param variant the variant string
144 * @param result receives the variant's display name
145 * @return the display name of the provided variant
148 virtual UnicodeString
& variantDisplayName(const char* variant
,
149 UnicodeString
& result
) const = 0;
152 * Returns the display name of the provided locale key.
153 * @param key the locale key name
154 * @param result receives the locale key's display name
155 * @return the display name of the provided locale key
158 virtual UnicodeString
& keyDisplayName(const char* key
,
159 UnicodeString
& result
) const = 0;
162 * Returns the display name of the provided value (used with the provided key).
163 * @param key the locale key name
164 * @param value the locale key's value
165 * @param result receives the value's display name
166 * @return the display name of the provided value
169 virtual UnicodeString
& keyValueDisplayName(const char* key
, const char* value
,
170 UnicodeString
& result
) const = 0;
173 // No ICU "poor man's RTTI" for this class nor its subclasses.
174 virtual UClassID
getDynamicClassID() const;
177 inline LocaleDisplayNames::~LocaleDisplayNames() {
180 inline LocaleDisplayNames
* LocaleDisplayNames::createInstance(const Locale
& locale
) {
181 return LocaleDisplayNames::createInstance(locale
, ULDN_STANDARD_NAMES
);