[][src]Crate loon

localization

A very simple localization/internationalization provider, inspired by ruby-i18n.

Usage:

fn main() {

    use loon::*;
     
    set_config(PathPattern("examples/locales/*.yml")).unwrap();

    assert_eq!(
        t("custom.greeting", Var("name", "Jacob")).unwrap(),
        String::from("Hello, Jacob!!!")
    );

    assert_eq!(
        t("greeting", Opts::default().locale("de")).unwrap(),
        String::from("Hallo Welt!")
    );
}

Features

Translation files can be:

  • JSON
  • YAML (enabled by default, disable with default-features = false), or
  • TOML (enable with features = ["toml"]).

Modules

err

Error management

Structs

Config

Configuration to build a Dictionary

Count

Helper for setting count option

DefaultKey

Helper for setting default_key option

DefaultLocale

Helper for setting default_locale configuration

Dictionary

Container for translation messages

Locale

Helper for setting locale option

LocalizedPath

Helper for setting localized_path configuration

Opts

Options (optional) for the translate call

PathPattern

Helper for setting path_pattern configuration

Var

Helper for setting interpolated variables

Functions

set_config

Sets the Config to use for the global translate call.

t

Shortcut for translate.

translate

Get the translated message, using the global configuration.