Crates.io | fluent-static |
lib.rs | fluent-static |
version | 0.5.0 |
source | src |
created_at | 2024-05-24 10:19:46.941382 |
updated_at | 2024-10-23 17:08:45.477378 |
description | Automatically generate Rust functions from Fluent message files for streamlined localization in Rust applications. |
homepage | https://github.com/zaytsev/fluent-static |
repository | https://github.com/zaytsev/fluent-static |
max_upload_size | |
id | 1250902 |
size | 18,153 |
fluent-static provides simple to use, yet efficient way to add localization to Rust projects with Fluent Localization System.
fluent-static is inspired by and partially based on awesome Fluent-rs project.
my_l10n.my_message()
to get l10n message[dependencies]
fluent-static = "*"
# <project root>/l10n/messages.ftl
say-hello = Hello, { $name }
use fluent_static::message_bundle;
#[message_bundle(
resources = [
("l10n/messages.ftl", "en"),
// add more Fluent resources
// ("i10n/errors.ftl", "en")
// ("i10n/messages-fr.ftl", "fr")
],
default_language = "en"
)]
pub struct Messages;
use fluent_static::MessageBundle;
pub fn main() {
let lang = "en";
let messages = Messagess::get(lang).unwrap_or_default();
println!(messages.say_hello("World"));
}
default_language
bundleAccept-Language
header value, see exampleContributions are welcome! Please feel free to submit pull requests, report bugs, and suggest features via the issue tracker.
This project is licensed under MIT license. Feel free to use, modify, and distribute it as per the license conditions.