Skip to content

Commit 6caa691

Browse files
Xiretzaalerque
authored andcommitted
feat(fluent-bundle): Add NUMBER builtin function
1 parent b9ea1cb commit 6caa691

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

fluent-bundle/src/builtins.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use crate::{FluentArgs, FluentValue};
2+
3+
#[allow(non_snake_case)]
4+
pub fn NUMBER<'a>(positional: &[FluentValue<'a>], named: &FluentArgs) -> FluentValue<'a> {
5+
let Some(FluentValue::Number(n)) = positional.first() else {
6+
return FluentValue::Error;
7+
};
8+
9+
let mut n = n.clone();
10+
n.options.merge(named);
11+
println!("{named:?} => {n:?}");
12+
13+
FluentValue::Number(n)
14+
}

fluent-bundle/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
//! the `fluent-bundle` crate directly, while the ecosystem
100100
//! matures and higher level APIs are being developed.
101101
mod args;
102+
pub mod builtins;
102103
pub mod bundle;
103104
pub mod concurrent;
104105
mod entry;

0 commit comments

Comments
 (0)