#fluent-interface #localization

fluent-pseudo

A pseudolocalization and transformation API for Project Fluent, a localization system designed to unleash the entire expressive power of natural language translations

10 releases

0.3.3 May 22, 2025
0.3.2 May 5, 2024
0.3.1 Jul 21, 2021
0.2.3 Nov 12, 2020
0.0.1 Aug 1, 2019

#547 in Internationalization (i18n)

Download history 378/week @ 2025-06-08 340/week @ 2025-06-15 741/week @ 2025-06-22 666/week @ 2025-06-29 770/week @ 2025-07-06 752/week @ 2025-07-13 652/week @ 2025-07-20 573/week @ 2025-07-27 664/week @ 2025-08-03 714/week @ 2025-08-10 716/week @ 2025-08-17 779/week @ 2025-08-24 809/week @ 2025-08-31 611/week @ 2025-09-07 746/week @ 2025-09-14 992/week @ 2025-09-21

3,253 downloads per month
Used in 4 crates

Apache-2.0 OR MIT

9KB
105 lines

Fluent Pseudo

crates.io docs.rs Build Coverage Status

The fluent-rs workspace is a collection of Rust crates implementing Project Fluent, a localization system designed to unleash the entire expressive power of natural language translations.

This crate provides a pseudolocalization and transformation API.

Usage

use fluent_bundle::{FluentBundle, FluentResource};
use unic_langid::langid;
use fluent_pseudo::transform;

fn transform_wrapper(s: &str) -> Cow<str> {
    // Not flipped and elongated pseudolocalization.
    transform(s, false, true, false)
}


fn main() {
    let ftl_string = "hello-world = Hello, world!".to_owned();
    let res = FluentResource::try_new(ftl_string)
        .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, "Ħḗḗŀŀǿǿ Ẇǿǿřŀḓ!");
}

Dependencies

~2–3MB
~53K SLoC