@@ -8,6 +8,28 @@ use intl_pluralrules::operands::PluralOperands;
8
8
use crate :: args:: FluentArgs ;
9
9
use crate :: types:: FluentValue ;
10
10
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
+
11
33
#[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
12
34
pub enum FluentNumberStyle {
13
35
Decimal ,
@@ -58,6 +80,7 @@ impl From<&str> for FluentNumberCurrencyDisplayStyle {
58
80
59
81
#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
60
82
pub struct FluentNumberOptions {
83
+ pub r#type : FluentNumberType ,
61
84
pub style : FluentNumberStyle ,
62
85
pub currency : Option < String > ,
63
86
pub currency_display : FluentNumberCurrencyDisplayStyle ,
@@ -72,6 +95,7 @@ pub struct FluentNumberOptions {
72
95
impl Default for FluentNumberOptions {
73
96
fn default ( ) -> Self {
74
97
Self {
98
+ r#type : Default :: default ( ) ,
75
99
style : Default :: default ( ) ,
76
100
currency : None ,
77
101
currency_display : Default :: default ( ) ,
@@ -89,6 +113,9 @@ impl FluentNumberOptions {
89
113
pub fn merge ( & mut self , opts : & FluentArgs ) {
90
114
for ( key, value) in opts. iter ( ) {
91
115
match ( key, value) {
116
+ ( "type" , FluentValue :: String ( n) ) => {
117
+ self . r#type = n. as_ref ( ) . into ( ) ;
118
+ }
92
119
( "style" , FluentValue :: String ( n) ) => {
93
120
self . style = n. as_ref ( ) . into ( ) ;
94
121
}
0 commit comments