fluent_content 0.0.5

Fluent extension for easy access to message content.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use fluent::{FluentBundle, FluentResource};
use fluent_content::prelude::*;
use unic_langid::langid;

pub fn main() {
    let source = "hello =\n.world = Hello, { $arg } world!".to_string();
    let resource = FluentResource::try_new(source).expect("Failed to parse an FTL string.");
    let mut bundle = FluentBundle::new(vec![langid!("en")]);
    bundle
        .add_resource(resource)
        .expect("Failed to add FTL resources to the bundle.");
    let hello_world = bundle
        .content("hello.world?arg=brave new")
        .expect("Failed to get FTL content.");
    println!("{hello_world}");
}