@@ -30,7 +30,7 @@ function printICUMessage(ast) {
30
30
return `{${ node . id } }` ;
31
31
}
32
32
33
- switch ( getArgumentType ( node . format . type ) ) {
33
+ switch ( getArgumentType ( node . format ) ) {
34
34
case 'number' :
35
35
case 'date' :
36
36
case 'time' :
@@ -46,23 +46,30 @@ function printICUMessage(ast) {
46
46
return printedNodes . join ( '' ) ;
47
47
}
48
48
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 ( ) ;
51
58
}
52
59
53
60
function printMessageTextASTNode ( { value} ) {
54
61
return value . replace ( ESAPE_CHARS_REGEXP , ( char ) => ESCAPED_CHARS [ char ] ) ;
55
62
}
56
63
57
64
function printSimpleFormatASTNode ( { id, format} ) {
58
- let argumentType = getArgumentType ( format . type ) ;
65
+ let argumentType = getArgumentType ( format ) ;
59
66
let style = format . style ? `, ${ format . style } ` : '' ;
60
67
61
68
return `{${ id } , ${ argumentType } ${ style } }` ;
62
69
}
63
70
64
71
function printOptionalFormatASTNode ( { id, format} ) {
65
- let argumentType = getArgumentType ( format . type ) ;
72
+ let argumentType = getArgumentType ( format ) ;
66
73
let offset = format . offset ? `, offset:${ format . offset } ` : '' ;
67
74
68
75
let options = format . options . map ( ( option ) => {
0 commit comments