Save PDF: the saved Summary writes each option line with the interface language's colon

The Summary section shows option lines with the colon the language uses (a no-break space before it in French, a full-width colon in Japanese and Chinese). The saved Summary file wrote a plain colon. Both now build the line with one helper.
This commit is contained in:
dotCooCoo
2026-11-17 21:52:33 -08:00
parent 79b4f7f240
commit 1387eb70b8
2 changed files with 18 additions and 4 deletions
+4 -4
View File
@@ -1041,8 +1041,7 @@ fn write_summary(app: &mut VectorcraftApp, path: Option<String>, text: &str) ->
pub(super) fn option_rows<'a>(ui: &mut egui::Ui, changed: impl IntoIterator<Item = &'a Value>, label: impl Fn(&str) -> String) {
let t = Tokens::get(ui.ctx());
for c in changed {
let value = option_value(c);
ui.label(egui::RichText::new(format!("{} {value}", crate::i18n::colon(&label(c["option"].as_str().unwrap_or_default())))).color(t.text));
ui.label(egui::RichText::new(option_line(c, &label)).color(t.text));
}
}
@@ -1056,9 +1055,10 @@ fn option_value(c: &Value) -> String {
}
}
/// The Summary's line for the changed option `c` (`{option, value}`), labeled by `label`.
/// The Summary's line for the changed option `c` (`{option, value}`), labeled by `label`, with the
/// colon the interface language writes.
fn option_line(c: &Value, label: impl Fn(&str) -> String) -> String {
format!("{}: {}", label(c["option"].as_str().unwrap_or_default()), option_value(c))
format!("{} {}", crate::i18n::colon(&label(c["option"].as_str().unwrap_or_default())), option_value(c))
}
/// The Summary's warnings ("None." without any).
@@ -389,6 +389,20 @@ fn the_save_summary_button_writes_the_summary() {
assert!(String::from_utf8(d[0].1.clone()).unwrap().starts_with("Options\n"));
}
/// The saved Summary writes each option line with the colon the interface language uses, as the
/// Summary section shows it: French puts a no-break space before the colon, Japanese writes a
/// full-width colon.
#[test]
fn the_summary_text_uses_the_languages_colon() {
let changed = json!({"option": "thumbnails", "value": true});
for (code, colon) in [("en", ":"), ("fr", "\u{a0}:"), ("ja", ":")] {
crate::i18n::set_current(crate::i18n::Lang::from_code(code).expect("registered"));
let line = option_line(&changed, |_| "X".to_string());
crate::i18n::set_current(crate::i18n::Lang::EN);
assert!(line.starts_with(&format!("X{colon} ")), "{code}: {line:?}");
}
}
/// Click the Summary section's Save Summary… button in frames of the dialog layer (the dialog's
/// window draws nothing in its first frame, which sizes it).
fn click_save_summary(app: &mut VectorcraftApp, ctx: &egui::Context) {