jpayne@69
|
1 // © 2016 and later: Unicode, Inc. and others.
|
jpayne@69
|
2 // License & terms of use: http://www.unicode.org/copyright.html
|
jpayne@69
|
3 /*
|
jpayne@69
|
4 ******************************************************************************
|
jpayne@69
|
5 * Copyright (C) 2010-2016, International Business Machines Corporation and
|
jpayne@69
|
6 * others. All Rights Reserved.
|
jpayne@69
|
7 ******************************************************************************
|
jpayne@69
|
8 */
|
jpayne@69
|
9
|
jpayne@69
|
10 #ifndef LOCDSPNM_H
|
jpayne@69
|
11 #define LOCDSPNM_H
|
jpayne@69
|
12
|
jpayne@69
|
13 #include "unicode/utypes.h"
|
jpayne@69
|
14
|
jpayne@69
|
15 #if U_SHOW_CPLUSPLUS_API
|
jpayne@69
|
16
|
jpayne@69
|
17 /**
|
jpayne@69
|
18 * \file
|
jpayne@69
|
19 * \brief C++ API: Provides display names of Locale and its components.
|
jpayne@69
|
20 */
|
jpayne@69
|
21
|
jpayne@69
|
22 #if !UCONFIG_NO_FORMATTING
|
jpayne@69
|
23
|
jpayne@69
|
24 #include "unicode/locid.h"
|
jpayne@69
|
25 #include "unicode/strenum.h"
|
jpayne@69
|
26 #include "unicode/uscript.h"
|
jpayne@69
|
27 #include "unicode/uldnames.h"
|
jpayne@69
|
28 #include "unicode/udisplaycontext.h"
|
jpayne@69
|
29
|
jpayne@69
|
30 U_NAMESPACE_BEGIN
|
jpayne@69
|
31
|
jpayne@69
|
32 /**
|
jpayne@69
|
33 * Returns display names of Locales and components of Locales. For
|
jpayne@69
|
34 * more information on language, script, region, variant, key, and
|
jpayne@69
|
35 * values, see Locale.
|
jpayne@69
|
36 * @stable ICU 4.4
|
jpayne@69
|
37 */
|
jpayne@69
|
38 class U_COMMON_API LocaleDisplayNames : public UObject {
|
jpayne@69
|
39 public:
|
jpayne@69
|
40 /**
|
jpayne@69
|
41 * Destructor.
|
jpayne@69
|
42 * @stable ICU 4.4
|
jpayne@69
|
43 */
|
jpayne@69
|
44 virtual ~LocaleDisplayNames();
|
jpayne@69
|
45
|
jpayne@69
|
46 /**
|
jpayne@69
|
47 * Convenience overload of
|
jpayne@69
|
48 * {@link #createInstance(const Locale& locale, UDialectHandling dialectHandling)}
|
jpayne@69
|
49 * that specifies STANDARD dialect handling.
|
jpayne@69
|
50 * @param locale the display locale
|
jpayne@69
|
51 * @return a LocaleDisplayNames instance
|
jpayne@69
|
52 * @stable ICU 4.4
|
jpayne@69
|
53 */
|
jpayne@69
|
54 inline static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale);
|
jpayne@69
|
55
|
jpayne@69
|
56 /**
|
jpayne@69
|
57 * Returns an instance of LocaleDisplayNames that returns names
|
jpayne@69
|
58 * formatted for the provided locale, using the provided
|
jpayne@69
|
59 * dialectHandling.
|
jpayne@69
|
60 *
|
jpayne@69
|
61 * @param locale the display locale
|
jpayne@69
|
62 * @param dialectHandling how to select names for locales
|
jpayne@69
|
63 * @return a LocaleDisplayNames instance
|
jpayne@69
|
64 * @stable ICU 4.4
|
jpayne@69
|
65 */
|
jpayne@69
|
66 static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale,
|
jpayne@69
|
67 UDialectHandling dialectHandling);
|
jpayne@69
|
68
|
jpayne@69
|
69 /**
|
jpayne@69
|
70 * Returns an instance of LocaleDisplayNames that returns names formatted
|
jpayne@69
|
71 * for the provided locale, using the provided UDisplayContext settings.
|
jpayne@69
|
72 *
|
jpayne@69
|
73 * @param locale the display locale
|
jpayne@69
|
74 * @param contexts List of one or more context settings (e.g. for dialect
|
jpayne@69
|
75 * handling, capitalization, etc.
|
jpayne@69
|
76 * @param length Number of items in the contexts list
|
jpayne@69
|
77 * @return a LocaleDisplayNames instance
|
jpayne@69
|
78 * @stable ICU 51
|
jpayne@69
|
79 */
|
jpayne@69
|
80 static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale,
|
jpayne@69
|
81 UDisplayContext *contexts, int32_t length);
|
jpayne@69
|
82
|
jpayne@69
|
83 // getters for state
|
jpayne@69
|
84 /**
|
jpayne@69
|
85 * Returns the locale used to determine the display names. This is
|
jpayne@69
|
86 * not necessarily the same locale passed to {@link #createInstance}.
|
jpayne@69
|
87 * @return the display locale
|
jpayne@69
|
88 * @stable ICU 4.4
|
jpayne@69
|
89 */
|
jpayne@69
|
90 virtual const Locale& getLocale() const = 0;
|
jpayne@69
|
91
|
jpayne@69
|
92 /**
|
jpayne@69
|
93 * Returns the dialect handling used in the display names.
|
jpayne@69
|
94 * @return the dialect handling enum
|
jpayne@69
|
95 * @stable ICU 4.4
|
jpayne@69
|
96 */
|
jpayne@69
|
97 virtual UDialectHandling getDialectHandling() const = 0;
|
jpayne@69
|
98
|
jpayne@69
|
99 /**
|
jpayne@69
|
100 * Returns the UDisplayContext value for the specified UDisplayContextType.
|
jpayne@69
|
101 * @param type the UDisplayContextType whose value to return
|
jpayne@69
|
102 * @return the UDisplayContext for the specified type.
|
jpayne@69
|
103 * @stable ICU 51
|
jpayne@69
|
104 */
|
jpayne@69
|
105 virtual UDisplayContext getContext(UDisplayContextType type) const = 0;
|
jpayne@69
|
106
|
jpayne@69
|
107 // names for entire locales
|
jpayne@69
|
108 /**
|
jpayne@69
|
109 * Returns the display name of the provided locale.
|
jpayne@69
|
110 * @param locale the locale whose display name to return
|
jpayne@69
|
111 * @param result receives the locale's display name
|
jpayne@69
|
112 * @return the display name of the provided locale
|
jpayne@69
|
113 * @stable ICU 4.4
|
jpayne@69
|
114 */
|
jpayne@69
|
115 virtual UnicodeString& localeDisplayName(const Locale& locale,
|
jpayne@69
|
116 UnicodeString& result) const = 0;
|
jpayne@69
|
117
|
jpayne@69
|
118 /**
|
jpayne@69
|
119 * Returns the display name of the provided locale id.
|
jpayne@69
|
120 * @param localeId the id of the locale whose display name to return
|
jpayne@69
|
121 * @param result receives the locale's display name
|
jpayne@69
|
122 * @return the display name of the provided locale
|
jpayne@69
|
123 * @stable ICU 4.4
|
jpayne@69
|
124 */
|
jpayne@69
|
125 virtual UnicodeString& localeDisplayName(const char* localeId,
|
jpayne@69
|
126 UnicodeString& result) const = 0;
|
jpayne@69
|
127
|
jpayne@69
|
128 // names for components of a locale id
|
jpayne@69
|
129 /**
|
jpayne@69
|
130 * Returns the display name of the provided language code.
|
jpayne@69
|
131 * @param lang the language code
|
jpayne@69
|
132 * @param result receives the language code's display name
|
jpayne@69
|
133 * @return the display name of the provided language code
|
jpayne@69
|
134 * @stable ICU 4.4
|
jpayne@69
|
135 */
|
jpayne@69
|
136 virtual UnicodeString& languageDisplayName(const char* lang,
|
jpayne@69
|
137 UnicodeString& result) const = 0;
|
jpayne@69
|
138
|
jpayne@69
|
139 /**
|
jpayne@69
|
140 * Returns the display name of the provided script code.
|
jpayne@69
|
141 * @param script the script code
|
jpayne@69
|
142 * @param result receives the script code's display name
|
jpayne@69
|
143 * @return the display name of the provided script code
|
jpayne@69
|
144 * @stable ICU 4.4
|
jpayne@69
|
145 */
|
jpayne@69
|
146 virtual UnicodeString& scriptDisplayName(const char* script,
|
jpayne@69
|
147 UnicodeString& result) const = 0;
|
jpayne@69
|
148
|
jpayne@69
|
149 /**
|
jpayne@69
|
150 * Returns the display name of the provided script code.
|
jpayne@69
|
151 * @param scriptCode the script code number
|
jpayne@69
|
152 * @param result receives the script code's display name
|
jpayne@69
|
153 * @return the display name of the provided script code
|
jpayne@69
|
154 * @stable ICU 4.4
|
jpayne@69
|
155 */
|
jpayne@69
|
156 virtual UnicodeString& scriptDisplayName(UScriptCode scriptCode,
|
jpayne@69
|
157 UnicodeString& result) const = 0;
|
jpayne@69
|
158
|
jpayne@69
|
159 /**
|
jpayne@69
|
160 * Returns the display name of the provided region code.
|
jpayne@69
|
161 * @param region the region code
|
jpayne@69
|
162 * @param result receives the region code's display name
|
jpayne@69
|
163 * @return the display name of the provided region code
|
jpayne@69
|
164 * @stable ICU 4.4
|
jpayne@69
|
165 */
|
jpayne@69
|
166 virtual UnicodeString& regionDisplayName(const char* region,
|
jpayne@69
|
167 UnicodeString& result) const = 0;
|
jpayne@69
|
168
|
jpayne@69
|
169 /**
|
jpayne@69
|
170 * Returns the display name of the provided variant.
|
jpayne@69
|
171 * @param variant the variant string
|
jpayne@69
|
172 * @param result receives the variant's display name
|
jpayne@69
|
173 * @return the display name of the provided variant
|
jpayne@69
|
174 * @stable ICU 4.4
|
jpayne@69
|
175 */
|
jpayne@69
|
176 virtual UnicodeString& variantDisplayName(const char* variant,
|
jpayne@69
|
177 UnicodeString& result) const = 0;
|
jpayne@69
|
178
|
jpayne@69
|
179 /**
|
jpayne@69
|
180 * Returns the display name of the provided locale key.
|
jpayne@69
|
181 * @param key the locale key name
|
jpayne@69
|
182 * @param result receives the locale key's display name
|
jpayne@69
|
183 * @return the display name of the provided locale key
|
jpayne@69
|
184 * @stable ICU 4.4
|
jpayne@69
|
185 */
|
jpayne@69
|
186 virtual UnicodeString& keyDisplayName(const char* key,
|
jpayne@69
|
187 UnicodeString& result) const = 0;
|
jpayne@69
|
188
|
jpayne@69
|
189 /**
|
jpayne@69
|
190 * Returns the display name of the provided value (used with the provided key).
|
jpayne@69
|
191 * @param key the locale key name
|
jpayne@69
|
192 * @param value the locale key's value
|
jpayne@69
|
193 * @param result receives the value's display name
|
jpayne@69
|
194 * @return the display name of the provided value
|
jpayne@69
|
195 * @stable ICU 4.4
|
jpayne@69
|
196 */
|
jpayne@69
|
197 virtual UnicodeString& keyValueDisplayName(const char* key, const char* value,
|
jpayne@69
|
198 UnicodeString& result) const = 0;
|
jpayne@69
|
199 };
|
jpayne@69
|
200
|
jpayne@69
|
201 inline LocaleDisplayNames* LocaleDisplayNames::createInstance(const Locale& locale) {
|
jpayne@69
|
202 return LocaleDisplayNames::createInstance(locale, ULDN_STANDARD_NAMES);
|
jpayne@69
|
203 }
|
jpayne@69
|
204
|
jpayne@69
|
205 U_NAMESPACE_END
|
jpayne@69
|
206
|
jpayne@69
|
207 #endif
|
jpayne@69
|
208
|
jpayne@69
|
209 #endif /* U_SHOW_CPLUSPLUS_API */
|
jpayne@69
|
210
|
jpayne@69
|
211 #endif
|