@@ -8,6 +8,28 @@ use intl_pluralrules::operands::PluralOperands;
88use crate :: args:: FluentArgs ;
99use crate :: types:: FluentValue ;
1010
11+ #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
12+ pub enum FluentNumberType {
13+ Cardinal ,
14+ Ordinal ,
15+ }
16+
17+ impl std:: default:: Default for FluentNumberType {
18+ fn default ( ) -> Self {
19+ Self :: Cardinal
20+ }
21+ }
22+
23+ impl From < & str > for FluentNumberType {
24+ fn from ( input : & str ) -> Self {
25+ match input {
26+ "cardinal" => Self :: Cardinal ,
27+ "ordinal" => Self :: Ordinal ,
28+ _ => Self :: default ( ) ,
29+ }
30+ }
31+ }
32+
1133#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
1234pub enum FluentNumberStyle {
1335 Decimal ,
@@ -58,6 +80,7 @@ impl From<&str> for FluentNumberCurrencyDisplayStyle {
5880
5981#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
6082pub struct FluentNumberOptions {
83+ pub r#type : FluentNumberType ,
6184 pub style : FluentNumberStyle ,
6285 pub currency : Option < String > ,
6386 pub currency_display : FluentNumberCurrencyDisplayStyle ,
@@ -72,6 +95,7 @@ pub struct FluentNumberOptions {
7295impl Default for FluentNumberOptions {
7396 fn default ( ) -> Self {
7497 Self {
98+ r#type : Default :: default ( ) ,
7599 style : Default :: default ( ) ,
76100 currency : None ,
77101 currency_display : Default :: default ( ) ,
@@ -89,6 +113,9 @@ impl FluentNumberOptions {
89113 pub fn merge ( & mut self , opts : & FluentArgs ) {
90114 for ( key, value) in opts. iter ( ) {
91115 match ( key, value) {
116+ ( "type" , FluentValue :: String ( n) ) => {
117+ self . r#type = n. as_ref ( ) . into ( ) ;
118+ }
92119 ( "style" , FluentValue :: String ( n) ) => {
93120 self . style = n. as_ref ( ) . into ( ) ;
94121 }
0 commit comments