mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 14:34:34 +00:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user