Yamlization (y10n) is a simple translations management library in Rust.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
R Tyler Croy 877a3c95dd
Prepare Y10n for actual use
2 years ago
l10n Implement the basics of the Y10n structure and the merging of values 2 years ago
src Prepare Y10n for actual use 2 years ago
.gitignore initial commit 2 years ago
Cargo.toml Bring in some of the code from another project 2 years ago
LICENSE.txt Bring in some of the code from another project 2 years ago
README.adoc Prepare Y10n for actual use 2 years ago

README.adoc

<html lang="en"> <head> </head>

Yamlization

Yamlization (y10n) is a simple Rust-based localization (l10n) library. Strings can be defined in .yml files which are then merged together.

Typically y10n should be used with multiple translation files written in Yaml. The yaml files can be merged together to provide base translations (e.g. the English strings) underneath the users preferred language (such as German).

Example

en.yml
greeting: 'hello world'
de.yml
greeting: 'hallöchen kleiner Mann'
main.rs
use y10n::*;

fn main() {
    let y10n = Y10n::from_glob("l10n/**/*.yml");
    // Create Language entities based on an `Accept-Languages` header
    let langs = parse_accept_languages("en,de;q=0.5");
    let translations = y10n.localize(&langs);

    // Translations is a serde_yaml::Value which can easily be brought into
    // handlebars or other structures for interpolation
}
</html>