JSON Get Text
This is a library for getting text from JSON usually for internationalization.
Example
extern crate json_gettext;
let ctx = static_json_gettext_build!.unwrap;
assert_eq!;
assert_eq!;
Rocket Support
This crate supports the Rocket framework. In order to reload changed json files instead of recompiling the program you have to enable the rocket feature for this crate.
[]
= "*"
= ["rocket"]
Then, use the static_json_gettext_build_for_rocket macro instead of the static_json_gettext_build macro to build a JSONGetText(JSONGetTextManager).
extern crate json_gettext;
extern crate rocket;
use State;
use Redirect;
use JSONGetTextManager;
If you are not using the release profile, JSONGetTextManager can reload the json files automatically if needed.
unic-langid Support
Since string comparison could be slow, the language_region_pair feature, the language feature or the region feature can be enabled to change key's type to (Language, Option<Region>), Language or Region respectively where Language and Region structs are in the unic-langid crate.
In this case, the key! macro would be useful for generating a Key instance from a literal string.
For example,
[]
= "*"
= ["language_region_pair", "rocket"]
extern crate rocket;
extern crate rocket_accept_language;
extern crate json_gettext;
use State;
use Language;
use AcceptLanguage;
use ;
const LANGUAGE_EN: Language = language!;
Crates.io
https://crates.io/crates/json-gettext