1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/unicode/locdspnm.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,206 @@ 1.4 +/* 1.5 +****************************************************************************** 1.6 +* Copyright (C) 2010-2012, International Business Machines Corporation and 1.7 +* others. All Rights Reserved. 1.8 +****************************************************************************** 1.9 +*/ 1.10 + 1.11 +#ifndef LOCDSPNM_H 1.12 +#define LOCDSPNM_H 1.13 + 1.14 +#include "unicode/utypes.h" 1.15 + 1.16 +/** 1.17 + * \file 1.18 + * \brief C++ API: Provides display names of Locale and its components. 1.19 + */ 1.20 + 1.21 +#if !UCONFIG_NO_FORMATTING 1.22 + 1.23 +#include "unicode/locid.h" 1.24 +#include "unicode/uscript.h" 1.25 +#include "unicode/uldnames.h" 1.26 +#include "unicode/udisplaycontext.h" 1.27 + 1.28 +U_NAMESPACE_BEGIN 1.29 + 1.30 +/** 1.31 + * Returns display names of Locales and components of Locales. For 1.32 + * more information on language, script, region, variant, key, and 1.33 + * values, see Locale. 1.34 + * @stable ICU 4.4 1.35 + */ 1.36 +class U_I18N_API LocaleDisplayNames : public UObject { 1.37 +public: 1.38 + /** 1.39 + * Destructor. 1.40 + * @stable ICU 4.4 1.41 + */ 1.42 + virtual ~LocaleDisplayNames(); 1.43 + 1.44 + /** 1.45 + * Convenience overload of 1.46 + * {@link #createInstance(const Locale& locale, UDialectHandling dialectHandling)} 1.47 + * that specifies STANDARD dialect handling. 1.48 + * @param locale the display locale 1.49 + * @return a LocaleDisplayNames instance 1.50 + * @stable ICU 4.4 1.51 + */ 1.52 + static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale); 1.53 + 1.54 + /** 1.55 + * Returns an instance of LocaleDisplayNames that returns names 1.56 + * formatted for the provided locale, using the provided 1.57 + * dialectHandling. 1.58 + * 1.59 + * @param locale the display locale 1.60 + * @param dialectHandling how to select names for locales 1.61 + * @return a LocaleDisplayNames instance 1.62 + * @stable ICU 4.4 1.63 + */ 1.64 + static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale, 1.65 + UDialectHandling dialectHandling); 1.66 + 1.67 +#ifndef U_HIDE_DRAFT_API 1.68 + /** 1.69 + * Returns an instance of LocaleDisplayNames that returns names formatted 1.70 + * for the provided locale, using the provided UDisplayContext settings. 1.71 + * 1.72 + * @param locale the display locale 1.73 + * @param contexts List of one or more context settings (e.g. for dialect 1.74 + * handling, capitalization, etc. 1.75 + * @param length Number of items in the contexts list 1.76 + * @return a LocaleDisplayNames instance 1.77 + * @draft ICU 51 1.78 + */ 1.79 + static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale, 1.80 + UDisplayContext *contexts, int32_t length); 1.81 +#endif /* U_HIDE_DRAFT_API */ 1.82 + 1.83 + // getters for state 1.84 + /** 1.85 + * Returns the locale used to determine the display names. This is 1.86 + * not necessarily the same locale passed to {@link #createInstance}. 1.87 + * @return the display locale 1.88 + * @stable ICU 4.4 1.89 + */ 1.90 + virtual const Locale& getLocale() const = 0; 1.91 + 1.92 + /** 1.93 + * Returns the dialect handling used in the display names. 1.94 + * @return the dialect handling enum 1.95 + * @stable ICU 4.4 1.96 + */ 1.97 + virtual UDialectHandling getDialectHandling() const = 0; 1.98 + 1.99 + /** 1.100 + * Returns the UDisplayContext value for the specified UDisplayContextType. 1.101 + * @param type the UDisplayContextType whose value to return 1.102 + * @return the UDisplayContext for the specified type. 1.103 + * @draft ICU 51 1.104 + */ 1.105 + virtual UDisplayContext getContext(UDisplayContextType type) const = 0; 1.106 + 1.107 + // names for entire locales 1.108 + /** 1.109 + * Returns the display name of the provided locale. 1.110 + * @param locale the locale whose display name to return 1.111 + * @param result receives the locale's display name 1.112 + * @return the display name of the provided locale 1.113 + * @stable ICU 4.4 1.114 + */ 1.115 + virtual UnicodeString& localeDisplayName(const Locale& locale, 1.116 + UnicodeString& result) const = 0; 1.117 + 1.118 + /** 1.119 + * Returns the display name of the provided locale id. 1.120 + * @param localeId the id of the locale whose display name to return 1.121 + * @param result receives the locale's display name 1.122 + * @return the display name of the provided locale 1.123 + * @stable ICU 4.4 1.124 + */ 1.125 + virtual UnicodeString& localeDisplayName(const char* localeId, 1.126 + UnicodeString& result) const = 0; 1.127 + 1.128 + // names for components of a locale id 1.129 + /** 1.130 + * Returns the display name of the provided language code. 1.131 + * @param lang the language code 1.132 + * @param result receives the language code's display name 1.133 + * @return the display name of the provided language code 1.134 + * @stable ICU 4.4 1.135 + */ 1.136 + virtual UnicodeString& languageDisplayName(const char* lang, 1.137 + UnicodeString& result) const = 0; 1.138 + 1.139 + /** 1.140 + * Returns the display name of the provided script code. 1.141 + * @param script the script code 1.142 + * @param result receives the script code's display name 1.143 + * @return the display name of the provided script code 1.144 + * @stable ICU 4.4 1.145 + */ 1.146 + virtual UnicodeString& scriptDisplayName(const char* script, 1.147 + UnicodeString& result) const = 0; 1.148 + 1.149 + /** 1.150 + * Returns the display name of the provided script code. 1.151 + * @param scriptCode the script code number 1.152 + * @param result receives the script code's display name 1.153 + * @return the display name of the provided script code 1.154 + * @stable ICU 4.4 1.155 + */ 1.156 + virtual UnicodeString& scriptDisplayName(UScriptCode scriptCode, 1.157 + UnicodeString& result) const = 0; 1.158 + 1.159 + /** 1.160 + * Returns the display name of the provided region code. 1.161 + * @param region the region code 1.162 + * @param result receives the region code's display name 1.163 + * @return the display name of the provided region code 1.164 + * @stable ICU 4.4 1.165 + */ 1.166 + virtual UnicodeString& regionDisplayName(const char* region, 1.167 + UnicodeString& result) const = 0; 1.168 + 1.169 + /** 1.170 + * Returns the display name of the provided variant. 1.171 + * @param variant the variant string 1.172 + * @param result receives the variant's display name 1.173 + * @return the display name of the provided variant 1.174 + * @stable ICU 4.4 1.175 + */ 1.176 + virtual UnicodeString& variantDisplayName(const char* variant, 1.177 + UnicodeString& result) const = 0; 1.178 + 1.179 + /** 1.180 + * Returns the display name of the provided locale key. 1.181 + * @param key the locale key name 1.182 + * @param result receives the locale key's display name 1.183 + * @return the display name of the provided locale key 1.184 + * @stable ICU 4.4 1.185 + */ 1.186 + virtual UnicodeString& keyDisplayName(const char* key, 1.187 + UnicodeString& result) const = 0; 1.188 + 1.189 + /** 1.190 + * Returns the display name of the provided value (used with the provided key). 1.191 + * @param key the locale key name 1.192 + * @param value the locale key's value 1.193 + * @param result receives the value's display name 1.194 + * @return the display name of the provided value 1.195 + * @stable ICU 4.4 1.196 + */ 1.197 + virtual UnicodeString& keyValueDisplayName(const char* key, const char* value, 1.198 + UnicodeString& result) const = 0; 1.199 +}; 1.200 + 1.201 +inline LocaleDisplayNames* LocaleDisplayNames::createInstance(const Locale& locale) { 1.202 + return LocaleDisplayNames::createInstance(locale, ULDN_STANDARD_NAMES); 1.203 +} 1.204 + 1.205 +U_NAMESPACE_END 1.206 + 1.207 +#endif 1.208 + 1.209 +#endif