Crates.io | rusty18n |
lib.rs | rusty18n |
version | 0.1.8 |
source | src |
created_at | 2023-12-28 03:13:57.273506 |
updated_at | 2024-07-09 20:57:38.074325 |
description | A simply yet efficient i18n solution for Rust. |
homepage | |
repository | https://github.com/o-dasher/rusty18n.git |
max_upload_size | |
id | 1082087 |
size | 15,269 |
A pretty simple yet robust library to deal with i18n on Rust.
Wouldn't it be pretty useful and handy if you could write all your translations directly in your source code? This is what this crate is solving. I was in need of a simple and easy to use i18n solution for my discord bot, and I had the idea to create a simple in-memory i18n handler. It provides all the basis for what you would expect for an in-memory i18n in Rust, covering simple static translations to dynamic ones.
You just need to do add some dependencies to your project:
cargo add rusty18n
cargo add deep_struct_update
deep_struct_update
is used so you can write partial i18n implementations for languages that are
still being working on, like in the example:
// We need to import deep_struct_update before we can use the define_i18n macro
use deep_struct_update;
pub fn i18n_ptbr() -> I18NUsage {
// Using the define_i18n macro we don't need to change all the i18n implementations once
// something in the base fallback implementation structure changes.
define_i18n! {
I18NUsage,
greetings: {
waves: r!("Oi!"),
}
}
}
You can see an example usage here