"rialight::intl" Fluent quickstart module

I've migrated my internationalization module to use Fluent and FTL instead of simple JSON resources. It allows you to load FTLs with a very simple API. It also uses ICU4X.

This is... rialight::intl! I'll also implement Ecma-like Intl things, like DisplayNames and Collator.

Now using FTLs it looks like this:

use rialight::intl::ftl::{Ftl, FtlOptions, FtlOptionsForAssets, FtlLoadMethod};
use rialight::util::{hashmap};

let app_ftl = Ftl::new(
        // specify supported locales.
        // the form in which the locale identifier appears here
        // is a post-component for the assets "src" path. 
        // for example: "path/to/res/lang/en-US"
        .fallbacks(hashmap! {
            "pt" => vec!["en"],
             // for file system load method you can also use the app: scheme.
             // the "app:" scheme works for Rialight applicaitons only.
            // "clean_unused" indicates whether to clean previous unused locale data. 
            // specify FtlLoadMethod::FileSystem or FtlLoadMethod::Http
); // app_ftl

if !app_ftl.load(None).await {
    // failed to load

println!("{}", app_ftl.get_message("hello-world", None, &mut vec![]).unwrap());

Our res/lang/en/_.ftl:

hello-world = Hello, world!

I added a guide in the GitHub organization.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.