i18n: one label_or_name for lists mixing labels and names; normal style rows

panels::label_or_name and dialogs::shown_names applied the same rule; it
now lives once as i18n::label_or_name (explicit language, testable) and
both delegate to it. zh-hant gains the two normal text style names the
Character and Paragraph Styles panels translate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-07 08:37:43 +07:00
co-authored by Claude Opus 5.5
parent 6572636d62
commit 0e5e093dd9
4 changed files with 13 additions and 6 deletions
+1 -1
View File
@@ -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), showing
+8
View File
@@ -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)
+2
View File
@@ -2898,3 +2898,5 @@
Release Compound Path 釋放複合路徑
— substituted by {style} — 以 {style} 取代
— {n} characters from another font — {n} 個字符來自其他字體
[Normal Character Style] [正常字元樣式]
[Normal Paragraph Style] [正常段落樣式]
Can't render this file because it contains an unexpected character in line 6 and column 47.
+2 -5
View File
@@ -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