ICU 50.1.2
50.1.2
|
C API: Plural rules, select plural keywords for numeric values. More...
Go to the source code of this file.
Namespaces | |
icu | |
File coll.h. | |
Typedefs | |
typedef enum UPluralType | UPluralType |
typedef struct UPluralRules | UPluralRules |
C typedef for struct UPluralRules. More... | |
Enumerations | |
enum | UPluralType { UPLURAL_TYPE_CARDINAL, UPLURAL_TYPE_ORDINAL, UPLURAL_TYPE_COUNT } |
Type of plurals and PluralRules. More... | |
Functions | |
UPluralRules * | uplrules_open (const char *locale, UErrorCode *status) |
Opens a new UPluralRules object using the predefined cardinal-number plural rules for a given locale. More... | |
UPluralRules * | uplrules_openForType (const char *locale, UPluralType type, UErrorCode *status) |
Opens a new UPluralRules object using the predefined plural rules for a given locale and the plural type. More... | |
void | uplrules_close (UPluralRules *uplrules) |
Closes a UPluralRules object. More... | |
int32_t | uplrules_select (const UPluralRules *uplrules, double number, UChar *keyword, int32_t capacity, UErrorCode *status) |
Given a number, returns the keyword of the first rule that applies to the number, according to the supplied UPluralRules object. More... | |
C API: Plural rules, select plural keywords for numeric values.
A UPluralRules object defines rules for mapping non-negative numeric values onto a small set of keywords. Rules are constructed from a text description, consisting of a series of keywords and conditions. The uplrules_select function examines each condition in order and returns the keyword for the first condition that matches the number. If none match, the default rule(other) is returned.
For more information, see the LDML spec, C.11 Language Plural Rules: http://www.unicode.org/reports/tr35/#Language_Plural_Rules
Keywords: ICU locale data has 6 predefined values - 'zero', 'one', 'two', 'few', 'many' and 'other'. Callers need to check the value of keyword returned by the uplrules_select function.
These are based on CLDR Language Plural Rules. For these predefined rules, see the CLDR page at http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
Definition in file upluralrules.h.
typedef struct UPluralRules UPluralRules |
typedef enum UPluralType UPluralType |
Definition at line 64 of file upluralrules.h.
enum UPluralType |
Type of plurals and PluralRules.
Enumerator | |
---|---|
UPLURAL_TYPE_CARDINAL |
Plural rules for cardinal numbers: 1 file vs. 2 files.
|
UPLURAL_TYPE_ORDINAL |
Plural rules for ordinal numbers: 1st file, 2nd file, 3rd file, 4th file, etc.
|
UPLURAL_TYPE_COUNT |
Number of Plural rules types.
|
Definition at line 44 of file upluralrules.h.
void uplrules_close | ( | UPluralRules * | uplrules | ) |
Closes a UPluralRules object.
Once closed it may no longer be used.
uplrules | The UPluralRules object to close. |
UPluralRules* uplrules_open | ( | const char * | locale, |
UErrorCode * | status | ||
) |
Opens a new UPluralRules object using the predefined cardinal-number plural rules for a given locale.
Same as uplrules_openForType(locale, UPLURAL_TYPE_CARDINAL, status).
locale | The locale for which the rules are desired. |
status | A pointer to a UErrorCode to receive any errors. |
UPluralRules* uplrules_openForType | ( | const char * | locale, |
UPluralType | type, | ||
UErrorCode * | status | ||
) |
Opens a new UPluralRules object using the predefined plural rules for a given locale and the plural type.
locale | The locale for which the rules are desired. |
type | The plural type (e.g., cardinal or ordinal). |
status | A pointer to a UErrorCode to receive any errors. |
int32_t uplrules_select | ( | const UPluralRules * | uplrules, |
double | number, | ||
UChar * | keyword, | ||
int32_t | capacity, | ||
UErrorCode * | status | ||
) |
Given a number, returns the keyword of the first rule that applies to the number, according to the supplied UPluralRules object.
uplrules | The UPluralRules object specifying the rules. |
number | The number for which the rule has to be determined. |
keyword | The keyword of the rule that applies to number. |
capacity | The capacity of keyword. |
status | A pointer to a UErrorCode to receive any errors. |