Expand description
The languages and the words of a RavenRS business application, in one place.
Every text the framework shows has a key, as ui.save or report.show. The texts that come
with it are in English and in Brazilian Portuguese; a language without a key falls back to
English, and a key nobody has shows as itself. An application or a module adds or replaces
texts with a flat JSON of keys, without code of its own for the screens.
use ravenrs_app_i18n::{Catalog, Language, Texts};
let texts = Texts::new(Language::BrazilianPortuguese);
assert_eq!(texts.get("ui.save"), "Salvar");
assert_eq!(texts.format("rules.required", &["Nome"]), "Nome é obrigatório");
let mut catalog = Catalog::builtin();
catalog.merge_json("pt-BR", r#"{ "ui.save": "Gravar", "shop.checkout": "Fechar pedido" }"#)?;
let texts = catalog.texts(Language::BrazilianPortuguese);
assert_eq!(texts.get("ui.save"), "Gravar");
assert_eq!(texts.get("shop.checkout"), "Fechar pedido");Modules§
- model
- Translations of the model that come with the framework, as differences in JSON for
translation: the captions of the entities and navigation its modules add.
Structs§
- Catalog
- Texts by language and by key.
- Text
Error - What is wrong with texts given as JSON.
- Texts
- The texts of a catalog in one language.
Enums§
- Language
- A language the screens can be in.
Constants§
- FALLBACK
- The language everything falls back to.
Functions§
- format
- A template with
{0},{1}… replaced by these. A number with nothing for it stays as it was. - format_
with - A template with each
{0},{1}… written byvalue, straight into what it gives, so nothing else is made for each value.valuesaysfalsefor a number it has nothing for, which then stays as it was.