@@ -8,6 +8,23 @@ use intl_pluralrules::operands::PluralOperands;
8
8
use crate :: args:: FluentArgs ;
9
9
use crate :: types:: FluentValue ;
10
10
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
+
11
28
#[ derive( Debug , Copy , Clone , Default , Hash , PartialEq , Eq ) ]
12
29
pub enum FluentNumberStyle {
13
30
#[ default]
@@ -48,6 +65,7 @@ impl From<&str> for FluentNumberCurrencyDisplayStyle {
48
65
49
66
#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
50
67
pub struct FluentNumberOptions {
68
+ pub r#type : FluentNumberType ,
51
69
pub style : FluentNumberStyle ,
52
70
pub currency : Option < String > ,
53
71
pub currency_display : FluentNumberCurrencyDisplayStyle ,
@@ -62,6 +80,7 @@ pub struct FluentNumberOptions {
62
80
impl Default for FluentNumberOptions {
63
81
fn default ( ) -> Self {
64
82
Self {
83
+ r#type : Default :: default ( ) ,
65
84
style : Default :: default ( ) ,
66
85
currency : None ,
67
86
currency_display : Default :: default ( ) ,
@@ -79,6 +98,9 @@ impl FluentNumberOptions {
79
98
pub fn merge ( & mut self , opts : & FluentArgs ) {
80
99
for ( key, value) in opts. iter ( ) {
81
100
match ( key, value) {
101
+ ( "type" , FluentValue :: String ( n) ) => {
102
+ self . r#type = n. as_ref ( ) . into ( ) ;
103
+ }
82
104
( "style" , FluentValue :: String ( n) ) => {
83
105
self . style = n. as_ref ( ) . into ( ) ;
84
106
}
0 commit comments