Crate l20n [] [src]

L20n implementation for localization

This crate provides an interface to use l20n files to localize your application.

Example usage

extern crate l20n;

use std::collections::HashMap;

fn main() {
    let mut locale = l20n::Locale::new();
    locale.add_resource(r#"
    <hi "Hello {{ $name }}!">
    "#).unwrap();

    let mut env = HashMap::new();
    env.insert("name", "Rust");
    let strs: HashMap<String, String> = locale.localize_data(env).unwrap();
    assert_eq!(strs["hi"], "Hello Rust!");
}

Structs

Locale

A Locale contains all the resources for a specific language.

ParseError

An error occurred trying to parse an L20n resource. The L20n file is invalid.

Enums

EncodeError

Errors that occur encoding environment data into something the L20n resources can use.

LocalizeError

An enum of the various errors that can occur during localization.

ParseErrorKind

The description of the ParseError that occurred.

ResolveError

Errors that can occur when resolving a set of l20n resources into strings. These errors are cause by problems in the l20n file, or incorrect Data provided when localizing.

Type Definitions

LocalizeResult

A Result of trying to localize.