API addition proposal: getLocale APIs for locale driven services

Vladimir Weinstein <[email protected]> Tue, 11 Nov 2003 15:48:16 -0800
Newsgroups gmane.comp.lib.icu.general
Message-ID <[email protected]>
Expiration 11/18/2003

This proposal seeks to add APIs that will return valid and actual locales for 
instances of locale based services. Valid locale is the most specific locale for 
which we guarantee that the data is valid. Actual locale is the locale from 
which the data actually comes from.

Therefore, if you asked for collation for locale "es_ES_CA", the valid locale 
would be "es_ES" and the actual locale would be "es", since this is where we 
keep the collation data for Spanish.

APIs for locale retrieval will be implemented for all the API frameworks: C, C++ 
and Java. Some services already have the APIs to get the locale. If these APIs 
do not support the locale data type selector, they will be deprecated.

Here are the C/C++ API proposals. Java proposal will follow shortly.

C: All the locale based services will get a *_getLocaleByType API.
The declaration are as following:
Break iterator:
const char*
ubrk_getLocaleByType(const UBreakIterator *bi,
                      ULocDataLocaleType type,
                      UErrorCode* status);
Message format:
const char*
umsg_getLocaleByType(const UMessageFormat *fmt,
                      ULocDataLocaleType type,
                      UErrorCode* status);
Number format:
const char*
unum_getLocaleByType(const UNumberFormat *fmt,
                      ULocDataLocaleType type,
                      UErrorCode* status);

Date format:
const char*
udat_getLocaleByType(const UDateFormat *fmt,
                      ULocDataLocaleType type,
                      UErrorCode* status);
Calendar:
const char*
ucal_getLocaleByType(const UCalendar *cal,
                      ULocDataLocaleType type,
                      UErrorCode* status);

Collation:
const char*
ucol_getLocaleByType(const UCollator *coll,
                      ULocDataLocaleType type,
                      UErrorCode* status);

Resource Bundles:
const char*
ures_getLocaleByType(const *UResourceBundle rb,
                      ULocDataLocaleType type,
                      UErrorCode* status);


C++: The C++ APIs are named just getLocale. If there was a previous getLocale 
API, it will be deprecated and changed by this overload. All the APIs return a 
Locale object.

Break iterator:
Locale
BreakIterator::getLocale(ULocDataLocaleType type, UErrorCode& status) const = 0;

Format:
Locale
Format::getLocale(ULocDataLocaleType type, UErrorCode& status) const = 0;

Calendar:
Locale
Calendar::getLocale(ULocDataLocaleType type, UErrorCode& status) const;

Collation:
Locale
Collator::getLocale(ULocDataLocaleType type, UErrorCode& status) const = 0;

Resource Bundles:
Locale
ResourceBundle::getLocale(ULocDataLocaleType type, UErrorCode& status) const;

Thank you!

Regards,
v.



-- 
Vladimir Weinstein, IBM GCoC-Unicode/ICU  San Jose, CA [email protected]