embedded-lang

Crates.ioembedded-lang
lib.rsembedded-lang
version0.9.0
sourcesrc
created_at2022-09-01 14:22:39.945317
updated_at2023-10-30 14:53:06.730736
descriptionEmbedded language resources for rust applications
homepage
repositoryhttps://github.com/rscarson/embedded_lang
max_upload_size
id656722
size32,471
Richard Carson (rscarson)

documentation

README

embedded_lang: Embedded language resources for rust applications

Crates.io Build Status License

A small library to provide translation strings as an embedded resource Language files are in JSON format and will be embedded into the binary at compile time.

Please see the examples directory for language file samples

Usage example:

use embedded_lang::{ LanguageSet, embedded_language };

fn main() {
    let mut translator = LanguageSet::new("fr", &[
        embedded_language!("../examples/en.lang.json"),
        embedded_language!("../examples/fr.lang.json"),
    ]);
    translator.set_fallback_language("en");

    assert_eq!(translator["tree"], "arbre".to_string());
}

LanguageSets have a current language, and a fallback language from which strings will be fetched if the current language is missing the requested string.

Commit count: 16

cargo fmt