Skip to main content

active_code

Function active_code 

Source
pub fn active_code() -> String
Expand description

The code of the active language of the translator installed by scope, as I18n::active gives it: tr, pt-BR. Outside a scope it is en, the language every key falls back to.

The runtime installs the translator around init, update and the other App methods, so update reads the same code the view sees in ui.env().i18n().active(), also after a Command::set_locale has switched the language.

let mut i18n = qframe::i18n::I18n::builtin();
assert!(i18n.set_active("tr"));
let code = qframe::i18n::scope(std::sync::Arc::new(i18n), qframe::i18n::active_code);
assert_eq!(code, "tr");