icu4c/source/i18n/i18n.vcxproj -text
icu4c/source/i18n/i18n.vcxproj.filters -text
icu4c/source/i18n/unicode/gender.h -text
+icu4c/source/i18n/unicode/udisplaycontext.h -text
icu4c/source/i18n/unicode/ugender.h -text
icu4c/source/io/io.vcxproj -text
icu4c/source/io/io.vcxproj.filters -text
</Command>\r
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>\r
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" ..\..\include\unicode\r
+</Command>\r
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>\r
+ </CustomBuild>\r
+ <CustomBuild Include="unicode\udisplaycontext.h">\r
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" ..\..\include\unicode\r
+</Command>\r
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>\r
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy "%(FullPath)" ..\..\include\unicode\r
+</Command>\r
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>\r
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy "%(FullPath)" ..\..\include\unicode\r
+</Command>\r
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>\r
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy "%(FullPath)" ..\..\include\unicode\r
</Command>\r
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>\r
</CustomBuild>\r
<CustomBuild Include="unicode\udatpg.h">\r
<Filter>formatting</Filter>\r
</CustomBuild>\r
+ <CustomBuild Include="unicode\udisplaycontext.h">\r
+ <Filter>formatting</Filter>\r
+ </CustomBuild>\r
<CustomBuild Include="unicode\ugender.h">\r
<Filter>formatting</Filter>\r
</CustomBuild>\r
virtual const Locale& getLocale() const;
virtual UDialectHandling getDialectHandling() const;
+
virtual UnicodeString& localeDisplayName(const Locale& locale,
UnicodeString& result) const;
virtual UnicodeString& localeDisplayName(const char* localeId,
UnicodeString sep;
MessageFormat *format;
MessageFormat *keyTypeFormat;
+ UDisplayContext capitalizationContext;
public:
// constructor
LocaleDisplayNamesImpl(const Locale& locale, UDialectHandling dialectHandling);
+ LocaleDisplayNamesImpl(const Locale& locale, UDisplayContext *contexts, int32_t length);
virtual ~LocaleDisplayNamesImpl();
virtual const Locale& getLocale() const;
virtual UDialectHandling getDialectHandling() const;
+ virtual UDisplayContext getContext(UDisplayContextType type) const;
virtual UnicodeString& localeDisplayName(const Locale& locale,
UnicodeString& result) const;
UnicodeString& localeIdName(const char* localeId,
UnicodeString& result) const;
UnicodeString& appendWithSep(UnicodeString& buffer, const UnicodeString& src) const;
+ void initialize(void);
};
LocaleDisplayNamesImpl::LocaleDisplayNamesImpl(const Locale& locale,
, regionData(U_ICUDATA_REGION, locale)
, format(NULL)
, keyTypeFormat(NULL)
+ , capitalizationContext(UDISPCTX_CAPITALIZATION_NONE)
+{
+ initialize();
+}
+
+LocaleDisplayNamesImpl::LocaleDisplayNamesImpl(const Locale& locale,
+ UDisplayContext *contexts, int32_t length)
+ : dialectHandling(ULDN_STANDARD_NAMES)
+ , langData(U_ICUDATA_LANG, locale)
+ , regionData(U_ICUDATA_REGION, locale)
+ , format(NULL)
+ , keyTypeFormat(NULL)
+ , capitalizationContext(UDISPCTX_CAPITALIZATION_NONE)
{
+ while (length-- > 0) {
+ UDisplayContext value = *contexts++;
+ UDisplayContextType selector = (UDisplayContextType)(value & ~0xFF);
+ switch (selector) {
+ case UDISPCTX_TYPE_DIALECT_HANDLING:
+ dialectHandling = (UDialectHandling)value;
+ break;
+ case UDISPCTX_TYPE_CAPITALIZATION:
+ capitalizationContext = value;
+ break;
+ default:
+ break;
+ }
+ }
+ initialize();
+}
+
+void
+LocaleDisplayNamesImpl::initialize(void) {
LocaleDisplayNamesImpl *nonConstThis = (LocaleDisplayNamesImpl *)this;
nonConstThis->locale = langData.getLocale() == Locale::getRoot()
? regionData.getLocale()
return dialectHandling;
}
+UDisplayContext
+LocaleDisplayNamesImpl::getContext(UDisplayContextType type) const {
+ switch (type) {
+ case UDISPCTX_TYPE_DIALECT_HANDLING:
+ return (UDisplayContext)dialectHandling;
+ case UDISPCTX_TYPE_CAPITALIZATION:
+ return capitalizationContext;
+ default:
+ break;
+ }
+ return (UDisplayContext)0;
+}
+
+// TODO: Make the following depend on capitalizationContext
UnicodeString&
LocaleDisplayNamesImpl::localeDisplayName(const Locale& locale,
UnicodeString& result) const {
return new LocaleDisplayNamesImpl(locale, dialectHandling);
}
+LocaleDisplayNames*
+LocaleDisplayNames::createInstance(const Locale& locale,
+ UDisplayContext *contexts, int32_t length) {
+ if (contexts == NULL) {
+ length = 0;
+ }
+ return new LocaleDisplayNamesImpl(locale, contexts, length);
+}
+
U_NAMESPACE_END
////////////////////////////////////////////////////////////////////////////////////////////////////
return (ULocaleDisplayNames *)LocaleDisplayNames::createInstance(Locale(locale), dialectHandling);
}
+U_CAPI ULocaleDisplayNames * U_EXPORT2
+uldn_openForContext(const char * locale,
+ UDisplayContext *contexts, int32_t length,
+ UErrorCode *pErrorCode) {
+ if (U_FAILURE(*pErrorCode)) {
+ return 0;
+ }
+ if (locale == NULL) {
+ locale = uloc_getDefault();
+ }
+ return (ULocaleDisplayNames *)LocaleDisplayNames::createInstance(Locale(locale), contexts, length);
+}
+
+
U_CAPI void U_EXPORT2
uldn_close(ULocaleDisplayNames *ldn) {
delete (LocaleDisplayNames *)ldn;
return ULDN_STANDARD_NAMES;
}
+U_CAPI UDisplayContext U_EXPORT2
+uldn_getContext(const ULocaleDisplayNames *ldn,
+ UDisplayContextType type,
+ UErrorCode *pErrorCode) {
+ if (U_FAILURE(*pErrorCode)) {
+ return (UDisplayContext)0;
+ }
+ return ((const LocaleDisplayNames *)ldn)->getContext(type);
+}
+
U_CAPI int32_t U_EXPORT2
uldn_localeDisplayName(const ULocaleDisplayNames *ldn,
const char *locale,
/*
******************************************************************************
-* Copyright (C) 2010-2011, International Business Machines Corporation and
+* Copyright (C) 2010-2012, International Business Machines Corporation and
* others. All Rights Reserved.
******************************************************************************
*/
#include "unicode/locid.h"
#include "unicode/uscript.h"
#include "unicode/uldnames.h"
+#include "unicode/udisplaycontext.h"
U_NAMESPACE_BEGIN
* @stable ICU 4.4
*/
static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale,
- UDialectHandling dialectHandling);
+ UDialectHandling dialectHandling);
+
+ /**
+ * Returns an instance of LocaleDisplayNames that returns names formatted
+ * for the provided locale, using the provided UDisplayContext settings.
+ *
+ * @param locale the display locale
+ * @param contexts List of one or more context settings (e.g. for dialect
+ * handling, capitalization, etc.
+ * @param length Number of items in the contexts list
+ * @return a LocaleDisplayNames instance
+ * @internal ICU 50 technology preview
+ */
+ static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale,
+ UDisplayContext *contexts, int32_t length);
// getters for state
/**
*/
virtual UDialectHandling getDialectHandling() const = 0;
+ /**
+ * Returns the UDisplayContext value for the specified UDisplayContextType.
+ * @param type the UDisplayContextType whose value to return
+ * @return the UDisplayContext for the specified type.
+ * @internal ICU 50 technology preview
+ */
+ virtual UDisplayContext getContext(UDisplayContextType type) const = 0;
+
// names for entire locales
/**
* Returns the display name of the provided locale.
* @stable ICU 4.4
*/
virtual UnicodeString& localeDisplayName(const Locale& locale,
- UnicodeString& result) const = 0;
+ UnicodeString& result) const = 0;
/**
* Returns the display name of the provided locale id.
* @stable ICU 4.4
*/
virtual UnicodeString& localeDisplayName(const char* localeId,
- UnicodeString& result) const = 0;
+ UnicodeString& result) const = 0;
// names for components of a locale id
/**
* @stable ICU 4.4
*/
virtual UnicodeString& languageDisplayName(const char* lang,
- UnicodeString& result) const = 0;
+ UnicodeString& result) const = 0;
/**
* Returns the display name of the provided script code.
* @stable ICU 4.4
*/
virtual UnicodeString& scriptDisplayName(const char* script,
- UnicodeString& result) const = 0;
+ UnicodeString& result) const = 0;
/**
* Returns the display name of the provided script code.
* @stable ICU 4.4
*/
virtual UnicodeString& scriptDisplayName(UScriptCode scriptCode,
- UnicodeString& result) const = 0;
+ UnicodeString& result) const = 0;
/**
* Returns the display name of the provided region code.
* @stable ICU 4.4
*/
virtual UnicodeString& regionDisplayName(const char* region,
- UnicodeString& result) const = 0;
+ UnicodeString& result) const = 0;
/**
* Returns the display name of the provided variant.
* @stable ICU 4.4
*/
virtual UnicodeString& variantDisplayName(const char* variant,
- UnicodeString& result) const = 0;
+ UnicodeString& result) const = 0;
/**
* Returns the display name of the provided locale key.
* @stable ICU 4.4
*/
virtual UnicodeString& keyDisplayName(const char* key,
- UnicodeString& result) const = 0;
+ UnicodeString& result) const = 0;
/**
* Returns the display name of the provided value (used with the provided key).
* @stable ICU 4.4
*/
virtual UnicodeString& keyValueDisplayName(const char* key, const char* value,
- UnicodeString& result) const = 0;
+ UnicodeString& result) const = 0;
private:
// No ICU "poor man's RTTI" for this class nor its subclasses.
--- /dev/null
+/*
+*****************************************************************************************
+* Copyright (C) 2012, International Business Machines
+* Corporation and others. All Rights Reserved.
+*****************************************************************************************
+*/
+
+#ifndef UDISPLAYCONTEXT_H
+#define UDISPLAYCONTEXT_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+/* Dont hide with #ifndef U_HIDE_INTERNAL_API, needed by virtual methods */
+/**
+ * Display context settings.
+ * Note, the specific numeric values are internal and may change.
+ * @internal ICU 50 technology preview
+ */
+enum UDisplayContext {
+ /**
+ * ================================
+ * DIALECT_HANDLING can be set to one of UDISPCTX_STANDARD_NAMES or
+ * UDISPCTX_DIALECT_NAMES. Use UDisplayContextType UDISPCTX_TYPE_DIALECT_HANDLING
+ * to get the value.
+ */
+ /**
+ * A possible setting for DIALECT_HANDLING:
+ * use standard names when generating a locale name,
+ * e.g. en_GB displays as 'English (United Kingdom)'.
+ * @internal ICU 50 technology preview
+ */
+ UDISPCTX_STANDARD_NAMES = 0,
+ /**
+ * A possible setting for DIALECT_HANDLING:
+ * use dialect names, when generating a locale name,
+ * e.g. en_GB displays as 'British English'.
+ * @internal ICU 50 technology preview
+ */
+ UDISPCTX_DIALECT_NAMES = 1,
+ /**
+ * ================================
+ * CAPITALIZATION can be set to one of UDISPCTX_CAPITALIZATION_NONE,
+ * UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE,
+ * UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE,
+ * UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, or
+ * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
+ * Use UDisplayContextType UDISPCTX_TYPE_CAPITALIZATION to get the value.
+ */
+ /**
+ * The capitalization context to be used is unknown (this is the default value).
+ * @internal ICU 50 technology preview
+ */
+ UDISPCTX_CAPITALIZATION_NONE = 0x100,
+ /**
+ * The capitalization context if a date, date symbol or display name is to be
+ * formatted with capitalization appropriate for the middle of a sentence.
+ * @internal ICU 50 technology preview
+ */
+ UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE = 0x101,
+ /**
+ * The capitalization context if a date, date symbol or display name is to be
+ * formatted with capitalization appropriate for the beginning of a sentence.
+ * @internal ICU 50 technology preview
+ */
+ UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE = 0x102,
+ /**
+ * The capitalization context if a date, date symbol or display name is to be
+ * formatted with capitalization appropriate for a user-interface list or menu item.
+ * @internal ICU 50 technology preview
+ */
+ UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU = 0x103,
+ /**
+ * The capitalization context if a date, date symbol or display name is to be
+ * formatted with capitalization appropriate for stand-alone usage such as an
+ * isolated name on a calendar page.
+ * @internal ICU 50 technology preview
+ */
+ UDISPCTX_CAPITALIZATION_FOR_STANDALONE = 0x104
+};
+/**
+* @internal ICU 50 technology preview
+*/
+typedef enum UDisplayContext UDisplayContext;
+
+/* Dont hide with #ifndef U_HIDE_INTERNAL_API, needed by virtual methods */
+/**
+ * Display context types, for getting values of a particular setting.
+ * Note, the specific numeric values are internal and may change.
+ * @internal ICU 50 technology preview
+ */
+enum UDisplayContextType {
+ /**
+ * Type to retrieve the dialect handling setting, e.g.
+ * UDISPCTX_STANDARD_NAMES or UDISPCTX_DIALECT_NAMES.
+ * @internal ICU 50 technology preview
+ */
+ UDISPCTX_TYPE_DIALECT_HANDLING = 0,
+ /**
+ * Type to retrieve the capitalization context setting, e.g.
+ * UDISPCTX_CAPITALIZATION_NONE, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE,
+ * UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, etc.
+ * @internal ICU 50 technology preview
+ */
+ UDISPCTX_TYPE_CAPITALIZATION = 0x100
+};
+/**
+* @internal ICU 50 technology preview
+*/
+typedef enum UDisplayContextType UDisplayContextType;
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif
#include "unicode/utypes.h"
#include "unicode/localpointer.h"
#include "unicode/uscript.h"
+#include "unicode/udisplaycontext.h"
/**
* Enum used in LocaleDisplayNames::createInstance.
int32_t maxResultSize,
UErrorCode *pErrorCode);
+#ifndef U_HIDE_INTERNAL_API
+/**
+* Returns an instance of LocaleDisplayNames that returns names formatted
+* for the provided locale, using the provided UDisplayContext settings.
+*
+* @param locale The display locale
+* @param contexts List of one or more context settings (e.g. for dialect
+* handling, capitalization, etc.
+* @param length Number of items in the contexts list
+* @param pErrorCode Pointer to UErrorCode input/output status. If at entry this indicates
+* a failure status, the function will do nothing; otherwise this will be
+* updated with any new status from the function.
+* @return a ULocaleDisplayNames instance
+* @internal ICU 50 technology preview
+*/
+U_INTERNAL ULocaleDisplayNames * U_EXPORT2
+uldn_openForContext(const char * locale,
+ UDisplayContext *contexts, int32_t length,
+ UErrorCode *pErrorCode);
+
+/**
+* Returns the UDisplayContext value for the specified UDisplayContextType.
+* @param ldn the ULocaleDisplayNames instance
+* @param type the UDisplayContextType whose value to return
+* @param pErrorCode Pointer to UErrorCode input/output status. If at entry this indicates
+* a failure status, the function will do nothing; otherwise this will be
+* updated with any new status from the function.
+* @return the UDisplayContextValue for the specified type.
+* @internal ICU 50 technology preview
+*/
+U_INTERNAL UDisplayContext U_EXPORT2
+uldn_getContext(const ULocaleDisplayNames *ldn,
+ UDisplayContextType type,
+ UErrorCode *pErrorCode);
+
+#endif /* U_HIDE_INTERNAL_API */
#endif /* !UCONFIG_NO_FORMATTING */
#endif /* __ULDNAMES_H__ */