Skip to main content

Module localization

Module localization 

Source
Expand description

Host-supplied UI translations, scoped to an egui context.

English text from the crate is the lookup key and the fallback. Install a lookup before drawing the UI; replacing it changes the next frame, including already-open dialogs. Missing entries return None. The host owns language selection, translation resources and fonts for its chosen languages.

let ctx = egui::Context::default();
egui_charts::localization::set_translator(&ctx, |english| {
    match english {
        "Cancel" => Some("Abbrechen".to_owned()),
        _ => None,
    }
});

Functions§

clear_translator
Restore this context’s built-in English UI and request a repaint.
format_text
Translate a message template and substitute its named, already-formatted values.
set_translator
Install or replace this context’s translation lookup and request a repaint.
text
Resolve a UI label through the host lookup, falling back to its English text.