@@ -8,6 +8,23 @@ use intl_pluralrules::operands::PluralOperands;
88use crate :: args:: FluentArgs ;
99use crate :: types:: FluentValue ;
1010
11+ #[ derive( Debug , Default , Copy , Clone , Hash , PartialEq , Eq ) ]
12+ pub enum FluentNumberType {
13+ #[ default]
14+ Cardinal ,
15+ Ordinal ,
16+ }
17+
18+ impl From < & str > for FluentNumberType {
19+ fn from ( input : & str ) -> Self {
20+ match input {
21+ "cardinal" => Self :: Cardinal ,
22+ "ordinal" => Self :: Ordinal ,
23+ _ => Self :: default ( ) ,
24+ }
25+ }
26+ }
27+
1128#[ derive( Debug , Copy , Clone , Default , Hash , PartialEq , Eq ) ]
1229pub enum FluentNumberStyle {
1330 #[ default]
@@ -48,6 +65,7 @@ impl From<&str> for FluentNumberCurrencyDisplayStyle {
4865
4966#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
5067pub struct FluentNumberOptions {
68+ pub r#type : FluentNumberType ,
5169 pub style : FluentNumberStyle ,
5270 pub currency : Option < String > ,
5371 pub currency_display : FluentNumberCurrencyDisplayStyle ,
@@ -62,6 +80,7 @@ pub struct FluentNumberOptions {
6280impl Default for FluentNumberOptions {
6381 fn default ( ) -> Self {
6482 Self {
83+ r#type : Default :: default ( ) ,
6584 style : Default :: default ( ) ,
6685 currency : None ,
6786 currency_display : Default :: default ( ) ,
@@ -79,6 +98,9 @@ impl FluentNumberOptions {
7998 pub fn merge ( & mut self , opts : & FluentArgs ) {
8099 for ( key, value) in opts. iter ( ) {
81100 match ( key, value) {
101+ ( "type" , FluentValue :: String ( n) ) => {
102+ self . r#type = n. as_ref ( ) . into ( ) ;
103+ }
82104 ( "style" , FluentValue :: String ( n) ) => {
83105 self . style = n. as_ref ( ) . into ( ) ;
84106 }
0 commit comments