#include "unicode/utypes.h"
#include "unicode/ures.h"
Go to the source code of this file.
Functions | |
u_nl_catd | u_catopen (const char *name, const char *locale, UErrorCode *ec) |
Open and return an ICU message catalog descriptor. | |
void | u_catclose (u_nl_catd catd) |
Close an ICU message catalog, given its descriptor. | |
const UChar * | u_catgets (u_nl_catd catd, int32_t set_num, int32_t msg_num, const UChar *s, int32_t *len, UErrorCode *ec) |
Retrieve a localized string from an ICU message catalog. | |
Variables | |
U_CDECL_BEGIN typedef UResourceBundle * | u_nl_catd |
An ICU message catalog descriptor, analogous to nl_catd. |
This C API provides look-alike functions that deliberately resemble the POSIX catopen, catclose, and catgets functions. The underlying implementation is in terms of ICU resource bundles, rather than POSIX message catalogs.
The ICU resource bundles obey standard ICU inheritance policies. To facilitate this, sets and messages are flattened into one tier. This is done by creating resource bundle keys of the form <set_num>%<msg_num> where set_num is the set number and msg_num is the message number, formatted as decimal strings.
Example: Consider a message catalog containing two sets:
Set 1: Message 4 = "Good morning." Message 5 = "Good afternoon." Message 7 = "Good evening." Message 8 = "Good night." Set 4: Message 14 = "Please " Message 19 = "Thank you." Message 20 = "Sincerely,"
The ICU resource bundle source file would, assuming it is named "greet.txt", would look like this:
greet { 14 { "Good morning." } 15 { "Good afternoon." } 17 { "Good evening." } 18 { "Good night." }
414 { "Please " } 419 { "Thank you." } 420 { "Sincerely," } }
The catgets function is commonly used in combination with functions like printf and strftime. ICU components like message format can be used instead, although they use a different format syntax. There is an ICU package, icuio, that provides some of the POSIX-style formatting API.
Definition in file ucat.h.
|
Close an ICU message catalog, given its descriptor.
|
|
Retrieve a localized string from an ICU message catalog.
|
|
Open and return an ICU message catalog descriptor. The descriptor may be passed to u_catgets() to retrieve localized strings.
|
|
An ICU message catalog descriptor, analogous to nl_catd.
|