2010-01-14 02:23:46 +00:00
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
* Copyright (C) 2010, International Business Machines Corporation and *
|
|
|
|
* others. All Rights Reserved. *
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LOCDSPNM_H
|
|
|
|
#define LOCDSPNM_H
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
|
|
|
/**
|
2010-01-21 02:45:53 +00:00
|
|
|
* \file
|
2010-01-14 02:23:46 +00:00
|
|
|
* \brief C++ API: Provides display names of Locale and its components.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !UCONFIG_NO_FORMATTING
|
|
|
|
|
|
|
|
#include "unicode/locid.h"
|
|
|
|
#include "unicode/uscript.h"
|
2010-01-15 02:35:02 +00:00
|
|
|
#include "unicode/uldnames.h"
|
2010-01-14 02:23:46 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns display names of Locales and components of Locales. For
|
|
|
|
* more information on language, script, region, variant, key, and
|
|
|
|
* values, see Locale.
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
2010-02-24 22:29:08 +00:00
|
|
|
class U_I18N_API LocaleDisplayNames : public UObject {
|
2010-01-14 02:23:46 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Destructor.
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
|
|
|
virtual ~LocaleDisplayNames();
|
|
|
|
|
|
|
|
/**
|
2010-01-21 02:45:53 +00:00
|
|
|
* Convenience overload of
|
|
|
|
* {@link #createInstance(const Locale& locale, UDialectHandling dialectHandling)}
|
2010-01-19 23:39:42 +00:00
|
|
|
* that specifies STANDARD dialect handling.
|
2010-01-21 02:45:53 +00:00
|
|
|
* @param locale the display locale
|
|
|
|
* @return a LocaleDisplayNames instance
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
|
|
|
static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an instance of LocaleDisplayNames that returns names
|
|
|
|
* formatted for the provided locale, using the provided
|
2010-01-21 02:45:53 +00:00
|
|
|
* dialectHandling.
|
2010-01-14 02:23:46 +00:00
|
|
|
*
|
2010-01-21 02:45:53 +00:00
|
|
|
* @param locale the display locale
|
|
|
|
* @param dialectHandling how to select names for locales
|
|
|
|
* @return a LocaleDisplayNames instance
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
2010-01-21 02:45:53 +00:00
|
|
|
static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale,
|
2010-01-14 02:23:46 +00:00
|
|
|
UDialectHandling dialectHandling);
|
|
|
|
|
|
|
|
// getters for state
|
|
|
|
/**
|
|
|
|
* Returns the locale used to determine the display names. This is
|
|
|
|
* not necessarily the same locale passed to {@link #getInstance}.
|
2010-01-21 02:45:53 +00:00
|
|
|
* @return the display locale
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
|
|
|
virtual const Locale& getLocale() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the dialect handling used in the display names.
|
|
|
|
* @return the dialect handling enum
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
|
|
|
virtual UDialectHandling getDialectHandling() const = 0;
|
|
|
|
|
|
|
|
// names for entire locales
|
|
|
|
/**
|
|
|
|
* Returns the display name of the provided locale.
|
|
|
|
* @param locale the locale whose display name to return
|
|
|
|
* @param result receives the locale's display name
|
|
|
|
* @return the display name of the provided locale
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
2010-01-21 02:45:53 +00:00
|
|
|
virtual UnicodeString& localeDisplayName(const Locale& locale,
|
2010-01-14 02:23:46 +00:00
|
|
|
UnicodeString& result) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the display name of the provided locale id.
|
|
|
|
* @param localeId the id of the locale whose display name to return
|
|
|
|
* @param result receives the locale's display name
|
|
|
|
* @return the display name of the provided locale
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
2010-01-21 02:45:53 +00:00
|
|
|
virtual UnicodeString& localeDisplayName(const char* localeId,
|
2010-01-14 02:23:46 +00:00
|
|
|
UnicodeString& result) const = 0;
|
|
|
|
|
|
|
|
// names for components of a locale id
|
|
|
|
/**
|
|
|
|
* Returns the display name of the provided language code.
|
|
|
|
* @param lang the language code
|
|
|
|
* @param result receives the language code's display name
|
|
|
|
* @return the display name of the provided language code
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
2010-01-21 02:45:53 +00:00
|
|
|
virtual UnicodeString& languageDisplayName(const char* lang,
|
2010-01-14 02:23:46 +00:00
|
|
|
UnicodeString& result) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the display name of the provided script code.
|
|
|
|
* @param script the script code
|
|
|
|
* @param result receives the script code's display name
|
|
|
|
* @return the display name of the provided script code
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
2010-01-21 02:45:53 +00:00
|
|
|
virtual UnicodeString& scriptDisplayName(const char* script,
|
2010-01-14 02:23:46 +00:00
|
|
|
UnicodeString& result) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the display name of the provided script code.
|
|
|
|
* @param scriptCode the script code number
|
|
|
|
* @param result receives the script code's display name
|
|
|
|
* @return the display name of the provided script code
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
2010-01-21 02:45:53 +00:00
|
|
|
virtual UnicodeString& scriptDisplayName(UScriptCode scriptCode,
|
2010-01-14 02:23:46 +00:00
|
|
|
UnicodeString& result) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the display name of the provided region code.
|
|
|
|
* @param region the region code
|
|
|
|
* @param result receives the region code's display name
|
|
|
|
* @return the display name of the provided region code
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
2010-01-21 02:45:53 +00:00
|
|
|
virtual UnicodeString& regionDisplayName(const char* region,
|
2010-01-14 02:23:46 +00:00
|
|
|
UnicodeString& result) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the display name of the provided variant.
|
|
|
|
* @param variant the variant string
|
|
|
|
* @param result receives the variant's display name
|
|
|
|
* @return the display name of the provided variant
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
2010-01-21 02:45:53 +00:00
|
|
|
virtual UnicodeString& variantDisplayName(const char* variant,
|
2010-01-14 02:23:46 +00:00
|
|
|
UnicodeString& result) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the display name of the provided locale key.
|
|
|
|
* @param key the locale key name
|
|
|
|
* @param result receives the locale key's display name
|
|
|
|
* @return the display name of the provided locale key
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
2010-01-21 02:45:53 +00:00
|
|
|
virtual UnicodeString& keyDisplayName(const char* key,
|
2010-01-14 02:23:46 +00:00
|
|
|
UnicodeString& result) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the display name of the provided value (used with the provided key).
|
|
|
|
* @param key the locale key name
|
|
|
|
* @param value the locale key's value
|
|
|
|
* @param result receives the value's display name
|
|
|
|
* @return the display name of the provided value
|
2010-11-12 06:03:28 +00:00
|
|
|
* @stable ICU 4.4
|
2010-01-14 02:23:46 +00:00
|
|
|
*/
|
2010-01-21 02:45:53 +00:00
|
|
|
virtual UnicodeString& keyValueDisplayName(const char* key, const char* value,
|
2010-01-14 02:23:46 +00:00
|
|
|
UnicodeString& result) const = 0;
|
2010-02-24 22:29:08 +00:00
|
|
|
|
2010-05-19 17:29:33 +00:00
|
|
|
private:
|
|
|
|
// No ICU "poor man's RTTI" for this class nor its subclasses.
|
|
|
|
virtual UClassID getDynamicClassID() const;
|
2010-01-14 02:23:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inline LocaleDisplayNames::~LocaleDisplayNames() {
|
|
|
|
}
|
|
|
|
|
|
|
|
inline LocaleDisplayNames* LocaleDisplayNames::createInstance(const Locale& locale) {
|
|
|
|
return LocaleDisplayNames::createInstance(locale, ULDN_STANDARD_NAMES);
|
|
|
|
}
|
|
|
|
|
|
|
|
U_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|