fluent-pseudo
is a Rust implementation of the pseudolocalization API for Project Fluent, a localization
framework designed to unleash the entire expressive power of natural language
translations.
```rust use fluentbundle::{FluentBundle, FluentResource}; use uniclangid::langid; use fluent_pseudo::transform;
fn transform_wrapper(s: &str) -> Cow
fn main() { let ftlstring = "hello-world = Hello, world!".toowned(); let res = FluentResource::trynew(ftlstring) .expect("Could not parse an FTL string.");
let langid_en = langid!("en");
let mut bundle = FluentBundle::new(vec![langid_en]);
// Set pseudolocalization
bundle.set_transform(Some(transform_wrapper));
bundle.add_resource(&res)
.expect("Failed to add FTL resources to the bundle.");
let msg = bundle.get_message("hello-world")
.expect("Failed to retrieve a message.");
let val = msg.value.expect("Message has no value.");
let mut errors = vec![];
let value = bundle.format_pattern(val, None, &mut errors);
assert_eq!(&value, "Ħḗḗŀŀǿǿ Ẇǿǿřŀḓ!");
} ```