@@ -30,7 +30,7 @@ function printICUMessage(ast) {
3030 return `{${ node . id } }` ;
3131 }
3232
33- switch ( getArgumentType ( node . format . type ) ) {
33+ switch ( getArgumentType ( node . format ) ) {
3434 case 'number' :
3535 case 'date' :
3636 case 'time' :
@@ -46,23 +46,30 @@ function printICUMessage(ast) {
4646 return printedNodes . join ( '' ) ;
4747}
4848
49- function getArgumentType ( astType ) {
50- return astType . replace ( / F o r m a t $ / , '' ) . toLowerCase ( ) ;
49+ function getArgumentType ( format ) {
50+ const { type, ordinal} = format ;
51+
52+ // Special-case ordinal plurals to use `selectordinal` instead of `plural`.
53+ if ( type === 'pluralFormat' && ordinal ) {
54+ return 'selectordinal' ;
55+ }
56+
57+ return type . replace ( / F o r m a t $ / , '' ) . toLowerCase ( ) ;
5158}
5259
5360function printMessageTextASTNode ( { value} ) {
5461 return value . replace ( ESAPE_CHARS_REGEXP , ( char ) => ESCAPED_CHARS [ char ] ) ;
5562}
5663
5764function printSimpleFormatASTNode ( { id, format} ) {
58- let argumentType = getArgumentType ( format . type ) ;
65+ let argumentType = getArgumentType ( format ) ;
5966 let style = format . style ? `, ${ format . style } ` : '' ;
6067
6168 return `{${ id } , ${ argumentType } ${ style } }` ;
6269}
6370
6471function printOptionalFormatASTNode ( { id, format} ) {
65- let argumentType = getArgumentType ( format . type ) ;
72+ let argumentType = getArgumentType ( format ) ;
6673 let offset = format . offset ? `, offset:${ format . offset } ` : '' ;
6774
6875 let options = format . options . map ( ( option ) => {
0 commit comments