VectorCraft: An open-source, vector art tool written by scratch in pure Rust
i18n: one label_or_name for lists mixing labels and names; normal style rows
bflatastic0e5e093dd9b8
diff --git a/crates/ui-egui/src/dialogs/mod.rs b/crates/ui-egui/src/dialogs/mod.rsindex 593205c3b..66ef51136 100644--- a/crates/ui-egui/src/dialogs/mod.rs+++ b/crates/ui-egui/src/dialogs/mod.rs@@ -383,7 +383,7 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) {/// What a dropdown shows for `names`, a list mixing built-in labels (`builtin(index)`: translated/// into `lang`) with names the user saved or a file or the system supplied (shown as they are).pub(crate) fn shown_names<'a>(lang: crate::i18n::Lang, names: &[&'a str], builtin: impl Fn(usize) -> bool) -> Vec<&'a str> {- names.iter().enumerate().map(|(k, n)| if builtin(k) { crate::i18n::tr(lang, n) } else { *n }).collect()+ names.iter().enumerate().map(|(k, n)| crate::i18n::label_or_name(lang, n, builtin(k))).collect()}/// [`widgets::dropdown_names`] over such a mixed list ([`shown_names`] in the UI language), showingdiff --git a/crates/ui-egui/src/i18n/mod.rs b/crates/ui-egui/src/i18n/mod.rsindex 5e7add93b..6a74ca8a3 100644--- a/crates/ui-egui/src/i18n/mod.rs+++ b/crates/ui-egui/src/i18n/mod.rs@@ -312,6 +312,14 @@ pub fn trn(lang: Lang, n: u64, one: &str, other: &str) -> String {fmt(text, &[("n", &n.to_string())])}+/// An entry of a list that mixes interface labels with names (user, file or system data) as+/// shown: a built-in entry in `lang`, a name exactly as it is (a library the user calls "Layers"+/// stays "Layers"). Show the result with the non-translating widgets (`dropdown_names`,+/// `menu_item_name`, `dim_name`).+pub fn label_or_name(lang: Lang, s: &str, built_in: bool) -> &str {+ if built_in { tr(lang, s) } else { s }+}+/// [`trn`] in the current language.pub fn tn(n: u64, one: &str, other: &str) -> String {trn(current(), n, one, other)diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsvindex 4a0642b6a..f34400d1d 100644--- a/crates/ui-egui/src/i18n/zh-hant.tsv+++ b/crates/ui-egui/src/i18n/zh-hant.tsv@@ -2898,3 +2898,5 @@Release Compound Path 釋放複合路徑— substituted by {style} — 以 {style} 取代— {n} characters from another font — {n} 個字符來自其他字體+ [Normal Character Style] [正常字元樣式]+ [Normal Paragraph Style] [正常段落樣式]diff --git a/crates/ui-egui/src/panels/mod.rs b/crates/ui-egui/src/panels/mod.rsindex cc0c909b6..945b9f1a5 100644--- a/crates/ui-egui/src/panels/mod.rs+++ b/crates/ui-egui/src/panels/mod.rs@@ -372,12 +372,9 @@ pub(crate) fn set_pstate<T: Clone + Send + Sync + 'static>(ctx: &egui::Context,ctx.data_mut(|d| d.insert_temp(egui::Id::new(("panel-state", key)), v));}-/// An entry of a list that mixes interface labels with names (user, file or system data) as-/// shown: a built-in entry in the UI language, a name exactly as it is (a profile or library the-/// user calls "Layers" stays "Layers"). Pass the result to the non-translating widgets-/// (`dropdown_names`, `menu_item_name`, `dim_name`).+/// [`crate::i18n::label_or_name`] in the UI language.pub(crate) fn label_or_name(s: &str, built_in: bool) -> &str {- if built_in { tl!(s) } else { s }+ crate::i18n::label_or_name(crate::i18n::current(), s, built_in)}/// "Recent Colors" header + a row of chips (the Session's recent colours, which every paint