intl/icu/source/i18n/unicode/uldnames.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 *******************************************************************************
michael@0 3 * Copyright (C) 2010-2012, International Business Machines Corporation and *
michael@0 4 * others. All Rights Reserved. *
michael@0 5 *******************************************************************************
michael@0 6 */
michael@0 7
michael@0 8 #ifndef __ULDNAMES_H__
michael@0 9 #define __ULDNAMES_H__
michael@0 10
michael@0 11 /**
michael@0 12 * \file
michael@0 13 * \brief C API: Provides display names of Locale ids and their components.
michael@0 14 */
michael@0 15
michael@0 16 #include "unicode/utypes.h"
michael@0 17 #include "unicode/localpointer.h"
michael@0 18 #include "unicode/uscript.h"
michael@0 19 #include "unicode/udisplaycontext.h"
michael@0 20
michael@0 21 /**
michael@0 22 * Enum used in LocaleDisplayNames::createInstance.
michael@0 23 * @stable ICU 4.4
michael@0 24 */
michael@0 25 typedef enum {
michael@0 26 /**
michael@0 27 * Use standard names when generating a locale name,
michael@0 28 * e.g. en_GB displays as 'English (United Kingdom)'.
michael@0 29 * @stable ICU 4.4
michael@0 30 */
michael@0 31 ULDN_STANDARD_NAMES = 0,
michael@0 32 /**
michael@0 33 * Use dialect names, when generating a locale name,
michael@0 34 * e.g. en_GB displays as 'British English'.
michael@0 35 * @stable ICU 4.4
michael@0 36 */
michael@0 37 ULDN_DIALECT_NAMES
michael@0 38 } UDialectHandling;
michael@0 39
michael@0 40 /**
michael@0 41 * Opaque C service object type for the locale display names API
michael@0 42 * @stable ICU 4.4
michael@0 43 */
michael@0 44 struct ULocaleDisplayNames;
michael@0 45
michael@0 46 /**
michael@0 47 * C typedef for struct ULocaleDisplayNames.
michael@0 48 * @stable ICU 4.4
michael@0 49 */
michael@0 50 typedef struct ULocaleDisplayNames ULocaleDisplayNames;
michael@0 51
michael@0 52 #if !UCONFIG_NO_FORMATTING
michael@0 53
michael@0 54 /**
michael@0 55 * Returns an instance of LocaleDisplayNames that returns names
michael@0 56 * formatted for the provided locale, using the provided
michael@0 57 * dialectHandling. The usual value for dialectHandling is
michael@0 58 * ULOC_STANDARD_NAMES.
michael@0 59 *
michael@0 60 * @param locale the display locale
michael@0 61 * @param dialectHandling how to select names for locales
michael@0 62 * @return a ULocaleDisplayNames instance
michael@0 63 * @param pErrorCode the status code
michael@0 64 * @stable ICU 4.4
michael@0 65 */
michael@0 66 U_STABLE ULocaleDisplayNames * U_EXPORT2
michael@0 67 uldn_open(const char * locale,
michael@0 68 UDialectHandling dialectHandling,
michael@0 69 UErrorCode *pErrorCode);
michael@0 70
michael@0 71 /**
michael@0 72 * Closes a ULocaleDisplayNames instance obtained from uldn_open().
michael@0 73 * @param ldn the ULocaleDisplayNames instance to be closed
michael@0 74 * @stable ICU 4.4
michael@0 75 */
michael@0 76 U_STABLE void U_EXPORT2
michael@0 77 uldn_close(ULocaleDisplayNames *ldn);
michael@0 78
michael@0 79 #if U_SHOW_CPLUSPLUS_API
michael@0 80
michael@0 81 U_NAMESPACE_BEGIN
michael@0 82
michael@0 83 /**
michael@0 84 * \class LocalULocaleDisplayNamesPointer
michael@0 85 * "Smart pointer" class, closes a ULocaleDisplayNames via uldn_close().
michael@0 86 * For most methods see the LocalPointerBase base class.
michael@0 87 *
michael@0 88 * @see LocalPointerBase
michael@0 89 * @see LocalPointer
michael@0 90 * @stable ICU 4.4
michael@0 91 */
michael@0 92 U_DEFINE_LOCAL_OPEN_POINTER(LocalULocaleDisplayNamesPointer, ULocaleDisplayNames, uldn_close);
michael@0 93
michael@0 94 U_NAMESPACE_END
michael@0 95
michael@0 96 #endif
michael@0 97
michael@0 98 /* getters for state */
michael@0 99
michael@0 100 /**
michael@0 101 * Returns the locale used to determine the display names. This is
michael@0 102 * not necessarily the same locale passed to {@link #uldn_open}.
michael@0 103 * @param ldn the LocaleDisplayNames instance
michael@0 104 * @return the display locale
michael@0 105 * @stable ICU 4.4
michael@0 106 */
michael@0 107 U_STABLE const char * U_EXPORT2
michael@0 108 uldn_getLocale(const ULocaleDisplayNames *ldn);
michael@0 109
michael@0 110 /**
michael@0 111 * Returns the dialect handling used in the display names.
michael@0 112 * @param ldn the LocaleDisplayNames instance
michael@0 113 * @return the dialect handling enum
michael@0 114 * @stable ICU 4.4
michael@0 115 */
michael@0 116 U_STABLE UDialectHandling U_EXPORT2
michael@0 117 uldn_getDialectHandling(const ULocaleDisplayNames *ldn);
michael@0 118
michael@0 119 /* names for entire locales */
michael@0 120
michael@0 121 /**
michael@0 122 * Returns the display name of the provided locale.
michael@0 123 * @param ldn the LocaleDisplayNames instance
michael@0 124 * @param locale the locale whose display name to return
michael@0 125 * @param result receives the display name
michael@0 126 * @param maxResultSize the size of the result buffer
michael@0 127 * @param pErrorCode the status code
michael@0 128 * @return the actual buffer size needed for the display name. If it's
michael@0 129 * greater than maxResultSize, the returned name will be truncated.
michael@0 130 * @stable ICU 4.4
michael@0 131 */
michael@0 132 U_STABLE int32_t U_EXPORT2
michael@0 133 uldn_localeDisplayName(const ULocaleDisplayNames *ldn,
michael@0 134 const char *locale,
michael@0 135 UChar *result,
michael@0 136 int32_t maxResultSize,
michael@0 137 UErrorCode *pErrorCode);
michael@0 138
michael@0 139 /* names for components of a locale */
michael@0 140
michael@0 141 /**
michael@0 142 * Returns the display name of the provided language code.
michael@0 143 * @param ldn the LocaleDisplayNames instance
michael@0 144 * @param lang the language code whose display name to return
michael@0 145 * @param result receives the display name
michael@0 146 * @param maxResultSize the size of the result buffer
michael@0 147 * @param pErrorCode the status code
michael@0 148 * @return the actual buffer size needed for the display name. If it's
michael@0 149 * greater than maxResultSize, the returned name will be truncated.
michael@0 150 * @stable ICU 4.4
michael@0 151 */
michael@0 152 U_STABLE int32_t U_EXPORT2
michael@0 153 uldn_languageDisplayName(const ULocaleDisplayNames *ldn,
michael@0 154 const char *lang,
michael@0 155 UChar *result,
michael@0 156 int32_t maxResultSize,
michael@0 157 UErrorCode *pErrorCode);
michael@0 158
michael@0 159 /**
michael@0 160 * Returns the display name of the provided script.
michael@0 161 * @param ldn the LocaleDisplayNames instance
michael@0 162 * @param script the script whose display name to return
michael@0 163 * @param result receives the display name
michael@0 164 * @param maxResultSize the size of the result buffer
michael@0 165 * @param pErrorCode the status code
michael@0 166 * @return the actual buffer size needed for the display name. If it's
michael@0 167 * greater than maxResultSize, the returned name will be truncated.
michael@0 168 * @stable ICU 4.4
michael@0 169 */
michael@0 170 U_STABLE int32_t U_EXPORT2
michael@0 171 uldn_scriptDisplayName(const ULocaleDisplayNames *ldn,
michael@0 172 const char *script,
michael@0 173 UChar *result,
michael@0 174 int32_t maxResultSize,
michael@0 175 UErrorCode *pErrorCode);
michael@0 176
michael@0 177 /**
michael@0 178 * Returns the display name of the provided script code.
michael@0 179 * @param ldn the LocaleDisplayNames instance
michael@0 180 * @param scriptCode the script code whose display name to return
michael@0 181 * @param result receives the display name
michael@0 182 * @param maxResultSize the size of the result buffer
michael@0 183 * @param pErrorCode the status code
michael@0 184 * @return the actual buffer size needed for the display name. If it's
michael@0 185 * greater than maxResultSize, the returned name will be truncated.
michael@0 186 * @stable ICU 4.4
michael@0 187 */
michael@0 188 U_STABLE int32_t U_EXPORT2
michael@0 189 uldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn,
michael@0 190 UScriptCode scriptCode,
michael@0 191 UChar *result,
michael@0 192 int32_t maxResultSize,
michael@0 193 UErrorCode *pErrorCode);
michael@0 194
michael@0 195 /**
michael@0 196 * Returns the display name of the provided region code.
michael@0 197 * @param ldn the LocaleDisplayNames instance
michael@0 198 * @param region the region code whose display name to return
michael@0 199 * @param result receives the display name
michael@0 200 * @param maxResultSize the size of the result buffer
michael@0 201 * @param pErrorCode the status code
michael@0 202 * @return the actual buffer size needed for the display name. If it's
michael@0 203 * greater than maxResultSize, the returned name will be truncated.
michael@0 204 * @stable ICU 4.4
michael@0 205 */
michael@0 206 U_STABLE int32_t U_EXPORT2
michael@0 207 uldn_regionDisplayName(const ULocaleDisplayNames *ldn,
michael@0 208 const char *region,
michael@0 209 UChar *result,
michael@0 210 int32_t maxResultSize,
michael@0 211 UErrorCode *pErrorCode);
michael@0 212
michael@0 213 /**
michael@0 214 * Returns the display name of the provided variant
michael@0 215 * @param ldn the LocaleDisplayNames instance
michael@0 216 * @param variant the variant whose display name to return
michael@0 217 * @param result receives the display name
michael@0 218 * @param maxResultSize the size of the result buffer
michael@0 219 * @param pErrorCode the status code
michael@0 220 * @return the actual buffer size needed for the display name. If it's
michael@0 221 * greater than maxResultSize, the returned name will be truncated.
michael@0 222 * @stable ICU 4.4
michael@0 223 */
michael@0 224 U_STABLE int32_t U_EXPORT2
michael@0 225 uldn_variantDisplayName(const ULocaleDisplayNames *ldn,
michael@0 226 const char *variant,
michael@0 227 UChar *result,
michael@0 228 int32_t maxResultSize,
michael@0 229 UErrorCode *pErrorCode);
michael@0 230
michael@0 231 /**
michael@0 232 * Returns the display name of the provided locale key
michael@0 233 * @param ldn the LocaleDisplayNames instance
michael@0 234 * @param key the locale key whose display name to return
michael@0 235 * @param result receives the display name
michael@0 236 * @param maxResultSize the size of the result buffer
michael@0 237 * @param pErrorCode the status code
michael@0 238 * @return the actual buffer size needed for the display name. If it's
michael@0 239 * greater than maxResultSize, the returned name will be truncated.
michael@0 240 * @stable ICU 4.4
michael@0 241 */
michael@0 242 U_STABLE int32_t U_EXPORT2
michael@0 243 uldn_keyDisplayName(const ULocaleDisplayNames *ldn,
michael@0 244 const char *key,
michael@0 245 UChar *result,
michael@0 246 int32_t maxResultSize,
michael@0 247 UErrorCode *pErrorCode);
michael@0 248
michael@0 249 /**
michael@0 250 * Returns the display name of the provided value (used with the provided key).
michael@0 251 * @param ldn the LocaleDisplayNames instance
michael@0 252 * @param key the locale key
michael@0 253 * @param value the locale key's value
michael@0 254 * @param result receives the display name
michael@0 255 * @param maxResultSize the size of the result buffer
michael@0 256 * @param pErrorCode the status code
michael@0 257 * @return the actual buffer size needed for the display name. If it's
michael@0 258 * greater than maxResultSize, the returned name will be truncated.
michael@0 259 * @stable ICU 4.4
michael@0 260 */
michael@0 261 U_STABLE int32_t U_EXPORT2
michael@0 262 uldn_keyValueDisplayName(const ULocaleDisplayNames *ldn,
michael@0 263 const char *key,
michael@0 264 const char *value,
michael@0 265 UChar *result,
michael@0 266 int32_t maxResultSize,
michael@0 267 UErrorCode *pErrorCode);
michael@0 268
michael@0 269 #ifndef U_HIDE_DRAFT_API
michael@0 270 /**
michael@0 271 * Returns an instance of LocaleDisplayNames that returns names formatted
michael@0 272 * for the provided locale, using the provided UDisplayContext settings.
michael@0 273 *
michael@0 274 * @param locale The display locale
michael@0 275 * @param contexts List of one or more context settings (e.g. for dialect
michael@0 276 * handling, capitalization, etc.
michael@0 277 * @param length Number of items in the contexts list
michael@0 278 * @param pErrorCode Pointer to UErrorCode input/output status. If at entry this indicates
michael@0 279 * a failure status, the function will do nothing; otherwise this will be
michael@0 280 * updated with any new status from the function.
michael@0 281 * @return a ULocaleDisplayNames instance
michael@0 282 * @draft ICU 51
michael@0 283 */
michael@0 284 U_DRAFT ULocaleDisplayNames * U_EXPORT2
michael@0 285 uldn_openForContext(const char * locale, UDisplayContext *contexts,
michael@0 286 int32_t length, UErrorCode *pErrorCode);
michael@0 287
michael@0 288 /**
michael@0 289 * Returns the UDisplayContext value for the specified UDisplayContextType.
michael@0 290 * @param ldn the ULocaleDisplayNames instance
michael@0 291 * @param type the UDisplayContextType whose value to return
michael@0 292 * @param pErrorCode Pointer to UErrorCode input/output status. If at entry this indicates
michael@0 293 * a failure status, the function will do nothing; otherwise this will be
michael@0 294 * updated with any new status from the function.
michael@0 295 * @return the UDisplayContextValue for the specified type.
michael@0 296 * @draft ICU 51
michael@0 297 */
michael@0 298 U_DRAFT UDisplayContext U_EXPORT2
michael@0 299 uldn_getContext(const ULocaleDisplayNames *ldn, UDisplayContextType type,
michael@0 300 UErrorCode *pErrorCode);
michael@0 301
michael@0 302 #endif /* U_HIDE_DRAFT_API */
michael@0 303
michael@0 304 #endif /* !UCONFIG_NO_FORMATTING */
michael@0 305 #endif /* __ULDNAMES_H__ */

mercurial