]>
git.saurik.com Git - apple/icu.git/blob - icuSources/samples/msgfmt/main.cpp
1 /********************************************************************
3 * Copyright (c) 1999-2003, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
7 #include "unicode/unistr.h"
8 #include "unicode/msgfmt.h"
9 #include "unicode/calendar.h"
14 // The message format pattern. It takes a single argument, an integer,
15 // and formats it as "no", "one", or a number, using a NumberFormat.
16 static UnicodeString
PATTERN(
17 "Received {0,choice,0#no arguments|1#one argument|2#{0,number,integer} arguments}"
21 int main(int argc
, char **argv
) {
23 UErrorCode status
= U_ZERO_ERROR
;
27 // Create a message format
28 MessageFormat
msg(PATTERN
, status
);
29 check(status
, "MessageFormat::ct");
31 // Create the argument list
32 Formattable msgArgs
[2];
33 msgArgs
[0].setLong(argc
-1);
34 msgArgs
[1].setDate(Calendar::getNow());
36 // Format the arguments
37 msg
.format(msgArgs
, 2, str
, pos
, status
);
38 check(status
, "MessageFormat::format");
44 printf("Exiting successfully\n");