other {sont {GENDER, select, female {allées} other {allés}}}} à {CITY}.",
"{0} {1, plural, one {est {2, select, female {allée} other {allé}}} other {sont {2, select, female {allées} other {allés}}}} à {3}."
};
char formatted[ 1024 ];
for( int j = 0 ; j < LENGTH(testformat) ; ++j )
{
MessageFormat *msgfmt = new MessageFormat( testformat[j] , Locale("fr"), status);
int formatted_len = testformat[j].length();
testformat[j].extract(0,formatted_len,formatted,sizeof( formatted ) - 1 );
printf( "%s\n" , formatted );
if( msgfmt->usesNamedArguments() )
{
StringEnumeration * en = msgfmt->getFormatNames(status);
en->reset(status);
count = en->count(status);
if (U_FAILURE(status)) {
printf("FAIL: Unable to get format name enumeration count.");
} else {
for (int32_t i = 0; i < count; i++) {
UnicodeString*argName = (UnicodeString*) en->snext(status);
memset( buf , 0x00 , sizeof( buf ) );
argName->extract( 0 , argName->length() , buf , sizeof( buf ) );
printf( " argName=%s\n" , buf );
if (U_FAILURE(status)) {
printf("FAIL: Error enumerating through names.");
break;
}
}
}
if( en ) delete en;
en = NULL;
}
int fmt_count;
Formattable::Type * type1 = (Formattable::Type*)MessageFormatAdapter::getArgTypeList(*msgfmt, fmt_count);
for(int32_t i = 0; i < fmt_count; ++i) {
switch(type1[i]) {
case Formattable::kDate:
printf( "Formattable::kDate\n" );
break;
case Formattable::kDouble:
printf( "Formattable::kDouble\n" );
break;
case Formattable::kLong:
printf( "Formattable::kLong\n" );
break;
case Formattable::kInt64:
printf( "Formattable::kInt64\n" );
break;
case Formattable::kString:
printf( "Formattable::kString\n" );
break;
case Formattable::kArray:
printf( "Formattable::kArray\n" );
break;
case Formattable::kObject:
printf( "Formattable::kObject\n" );
break;
}
}
delete msgfmt;
msgfmt = NULL;
printf( "---------------------------------------------------------------------\n\n" );
}
return 0;
}
}}}
The result is below,'GENDER' should be appearing in the list,but it doestn't.
other {sont {GENDER, select, female {all��es} other {all��s}}}} �� {CITY}.
argName=TRAVELLERS
argName=TRAVELLER_COUNT
argName=CITY
Formattable::kString
Formattable::kDouble
Formattable::kString
---------------------------------------------------------------------
{0} {1, plural, one {est {2, select, female {all��e} other {all��}}} other {sont {2, select, female {all��es} other {all��s}}}} �� {3}.
Formattable::kString
Formattable::kDouble
Formattable::kString
Formattable::kString
}}}
This is a misunderstanding. All of the format getters and setters only operate on top-level arguments. (This behavior is inherited from JDK MessageFormat.) The "GENDER" argument only appears as a nested/inner argument, and the pre-ICU 4.8 MessageFormat implementation would have never seen it in pattern parsing.
Starting with ICU 4.8, you can use the new MessagePattern class to analyze MessageFormat pattern strings. For example, you can look for all of the ARG_NUMBER & ARG_NAME "parts" and get their numbers/names.