Skip to main content

t

Function t 

Source
pub fn t(key: &str) -> String
Expand description

key translated into the app’s language, or key itself if there’s no translation.

Keys are the English text (t("Save As…")), so an untranslated string shows in English. The app’s tables (App::translations) name the languages it speaks; the language used is the first of the user’s preferred languages (System Settings ▸ General ▸ Language & Region, or the app’s own choice there) that it has. The framework’s own strings (the menus it makes, document alerts, “Untitled”) come translated into German, French and Japanese.

use ferrokit::*;

App::new("Notes")
    .translations(&[("de", "\"Notes\" = \"Notizen\";\n\"{n} note\" = \"{n} Notiz\";\n\"{n} notes\" = \"{n} Notizen\";")])
    .window(Window::new(&t("Notes")).view(text(|| t_plural(3, "{n} note", "{n} notes"))))
    .run();