mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-21 01:44:57 +01:00
Merge pull request #8777 from dotCooCoo/fix/info-status-colon
i18n: panel and status bar labels use the language's colon
This commit is contained in:
9 files changed
+63
-7
No files matched your search
@@ -209,7 +209,8 @@ pub(super) fn info_text(app: &VectorcraftApp) -> (String, Option<u64>) {
|
||||
(text, Some(next))
|
||||
}
|
||||
StatusBarShow::Undos => {
|
||||
let text = st.map(|d| format!("{}: {} {}: {}", tl!("Undos"), d.history.undo.len(), tl!("Redos"), d.history.redo.len()));
|
||||
let (undos, redos) = (crate::i18n::colon(tl!("Undos")), crate::i18n::colon(tl!("Redos")));
|
||||
let text = st.map(|d| format!("{undos} {} {redos} {}", d.history.undo.len(), d.history.redo.len()));
|
||||
(text.unwrap_or_default(), None)
|
||||
}
|
||||
StatusBarShow::ColorProfile => (st.map(|d| color_profile_name(&d.doc)).unwrap_or_default(), None),
|
||||
|
||||
@@ -1127,6 +1127,12 @@ fn the_status_bar_info_field_shows_the_chosen_readout() {
|
||||
app.run("edit.undo", json!({})).unwrap();
|
||||
assert_eq!(counts(&app), format!("Undos: {before} Redos: 1"));
|
||||
assert!(status_after(&mut app, &ctx, 0.1, vec![]).iter().any(|t| t.text == counts(&app)), "the redo step counts");
|
||||
// The labels take the UI language's colon (#7991).
|
||||
let fr = crate::i18n::Lang::from_code("fr").unwrap();
|
||||
crate::i18n::set_current(fr);
|
||||
let (french, _) = super::status_bar::info_text(&app);
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
assert_eq!(french, format!("{}\u{a0}: {before} {}\u{a0}: 1", crate::i18n::tr(fr, "Undos"), crate::i18n::tr(fr, "Redos")));
|
||||
|
||||
app.run("view.statusBarShow", json!({"show": "colorProfile"})).unwrap();
|
||||
let working = vectorcraft_color::cms::working_settings();
|
||||
|
||||
@@ -488,7 +488,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
_ => None,
|
||||
};
|
||||
let label = match style {
|
||||
Some(name) => std::borrow::Cow::Owned(format!("{label}: {name}")),
|
||||
Some(name) => std::borrow::Cow::Owned(format!("{} {name}", crate::i18n::colon(label))),
|
||||
None => std::borrow::Cow::Borrowed(label),
|
||||
};
|
||||
if !hide_thumb {
|
||||
|
||||
@@ -915,6 +915,13 @@ fn with_nothing_selected_it_lists_what_new_art_gets() {
|
||||
for want in ["No Selection: Fancy".to_string(), effect_label("stylize.dropShadow"), "Opacity: 50%".into(), "Dashed".into()] {
|
||||
assert!(shown.contains(&want), "{want} in {shown:?}");
|
||||
}
|
||||
// The style name follows the UI language's colon (#7991).
|
||||
let fr = crate::i18n::Lang::from_code("fr").unwrap();
|
||||
crate::i18n::set_current(fr);
|
||||
let shown = frame(&mut app);
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
let want = format!("{}\u{a0}: Fancy", crate::i18n::tr(fr, "No Selection"));
|
||||
assert!(shown.contains(&want), "{want} in {shown:?}");
|
||||
}
|
||||
|
||||
/// Both stroke rows expose named Weight inputs, and the drop-shadow effect names its Blur input and
|
||||
|
||||
@@ -111,7 +111,9 @@ impl Rows {
|
||||
}
|
||||
Some(Readout::Scale { sx, sy }) => rows.right = vec![format!("W: {:.1}%", sx * 100.0), format!("H: {:.1}%", sy * 100.0)],
|
||||
Some(Readout::Rotate { angle, .. } | Readout::Reflect { angle, .. }) => rows.right = vec![format!("A: {angle:.1}°")],
|
||||
Some(Readout::Shear { axis, angle, .. }) => rows.right = vec![format!("A: {axis:.1}°"), format!("{}: {angle:.1}°", tl!("Shear"))],
|
||||
Some(Readout::Shear { axis, angle, .. }) => {
|
||||
rows.right = vec![format!("A: {axis:.1}°"), format!("{} {angle:.1}°", crate::i18n::colon(tl!("Shear")))]
|
||||
}
|
||||
Some(Readout::Brush { .. }) | None => {
|
||||
let (w, h) = s.size.map(|(w, h, _)| (len(w), len(h))).unwrap_or_default();
|
||||
rows.right = vec![format!("W: {w}"), format!("H: {h}")];
|
||||
@@ -177,7 +179,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
});
|
||||
if app.session.tool_id() == "zoom" {
|
||||
let zoom = app.view().map_or(1.0, |v| v.zoom);
|
||||
mono(ui, format!("{}: {}", tl!("Zoom"), crate::state::zoom_label(zoom, app.session.prefs.display_print_size)));
|
||||
mono(ui, format!("{} {}", crate::i18n::colon(tl!("Zoom")), crate::state::zoom_label(zoom, app.session.prefs.display_print_size)));
|
||||
}
|
||||
if let Some(Readout::Brush { name: Some(name) }) = readout {
|
||||
mono(ui, name);
|
||||
@@ -317,6 +319,22 @@ mod tests {
|
||||
assert!(texts(&mut app).contains(&want), "{want}: {:?}", texts(&mut app));
|
||||
}
|
||||
|
||||
/// The Shear and Zoom readouts write their colon as the UI language does (#7991).
|
||||
#[test]
|
||||
fn readout_labels_use_the_language_colon() {
|
||||
let mut app = app_with_rect();
|
||||
app.session.select_tool("zoom", view()).unwrap();
|
||||
let fr = crate::i18n::Lang::from_code("fr").unwrap();
|
||||
crate::i18n::set_current(fr);
|
||||
let shear = shown(Some(&Readout::Shear { center: Point::new(60.0, 70.0), axis: 90.0, angle: -12.5 }), true);
|
||||
let shown_texts = texts(&mut app);
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
assert_eq!(shear.right[1], format!("{}\u{a0}: -12.5°", crate::i18n::tr(fr, "Shear")));
|
||||
let zoom = app.view().map_or(1.0, |v| v.zoom);
|
||||
let want = format!("{}\u{a0}: {}", crate::i18n::tr(fr, "Zoom"), crate::state::zoom_label(zoom, app.session.prefs.display_print_size));
|
||||
assert!(shown_texts.contains(&want), "{want}: {shown_texts:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_paintbrush_shows_its_brush() {
|
||||
let mut app = app_with_rect();
|
||||
|
||||
@@ -519,11 +519,11 @@ pub(super) fn status_tip(r: &Value, mask: Option<String>) -> String {
|
||||
_ => None,
|
||||
};
|
||||
let tip = match art {
|
||||
Some(kind) => format!("{tip}\n{kind}: {name}"),
|
||||
Some(kind) => format!("{tip}\n{} {name}", crate::i18n::colon(kind)),
|
||||
None => tip,
|
||||
};
|
||||
match owner["maskOf"].as_u64() {
|
||||
Some(id) => format!("{tip}\n{}: {}", tl!("Opacity Mask"), mask.unwrap_or_else(|| id.to_string())),
|
||||
Some(id) => format!("{tip}\n{} {}", crate::i18n::colon(tl!("Opacity Mask")), mask.unwrap_or_else(|| id.to_string())),
|
||||
None => tip,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ fn results(app: &mut VectorcraftApp, ui: &mut Ui, report: &Value) {
|
||||
}
|
||||
if let Some(ppi) = finding["effectivePpi"].as_array() {
|
||||
let values = ppi.iter().filter_map(Value::as_f64).map(|n| format!("{n:.0}")).collect::<Vec<_>>();
|
||||
dim_label(ui, &format!("{}: {} ppi", tl!("Effective PPI"), values.join(" × ")));
|
||||
dim_label(ui, &effective_ppi_line(&values));
|
||||
}
|
||||
let source = finding["sourceId"].as_u64();
|
||||
if code == "missingLink"
|
||||
@@ -220,5 +220,10 @@ fn results(app: &mut VectorcraftApp, ui: &mut Ui, report: &Value) {
|
||||
dim_label(ui, tl!("These checks do not certify an exported file."));
|
||||
}
|
||||
|
||||
/// A low-resolution finding's effective resolution, one value per axis.
|
||||
fn effective_ppi_line(values: &[String]) -> String {
|
||||
format!("{} {} ppi", crate::i18n::colon(tl!("Effective PPI")), values.join(" × "))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -153,6 +153,18 @@ fn preflight_panel_rechecks_missing_files_on_its_timer_and_on_request() {
|
||||
std::fs::remove_file(&path).unwrap();
|
||||
}
|
||||
|
||||
/// The Effective PPI line writes its colon as the UI language does (#7991).
|
||||
#[test]
|
||||
fn effective_ppi_uses_the_language_colon() {
|
||||
let values = ["150".to_string(), "300".to_string()];
|
||||
let fr = crate::i18n::Lang::from_code("fr").unwrap();
|
||||
crate::i18n::set_current(fr);
|
||||
let french = effective_ppi_line(&values);
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
assert_eq!(french, format!("{}\u{a0}: 150 × 300 ppi", crate::i18n::tr(fr, "Effective PPI")));
|
||||
assert_eq!(effective_ppi_line(&values), "Effective PPI: 150 × 300 ppi");
|
||||
}
|
||||
|
||||
/// An optional visual QA artifact, never a checked-in snapshot or an asset shipped by the app.
|
||||
#[test]
|
||||
#[ignore = "set PREFLIGHT_PREVIEW_PATH to write an offscreen GPU render for visual review"]
|
||||
|
||||
@@ -458,6 +458,13 @@ fn a_nested_rows_tooltip_names_what_holds_it() {
|
||||
// A row in the layers says only its file.
|
||||
let row = json!({"id": 9, "name": "a.png", "status": "ok", "path": "/x/a.png"});
|
||||
assert_eq!(super::links::status_tip(&row, None), "/x/a.png");
|
||||
// The labels take the UI language's colon (#7991).
|
||||
let fr = crate::i18n::Lang::from_code("fr").unwrap();
|
||||
crate::i18n::set_current(fr);
|
||||
let french = tip(json!({"kind": "symbol", "name": "Mark", "maskOf": 7}), None);
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
let (symbols, mask) = (crate::i18n::tr(fr, "Symbols"), crate::i18n::tr(fr, "Opacity Mask"));
|
||||
assert_eq!(french, format!("/x/a.png\n{symbols}\u{a0}: Mark\n{mask}\u{a0}: 7"));
|
||||
}
|
||||
|
||||
/// The tooltip of an image in the opacity mask of an object inside a symbol names that object,
|
||||
|
||||
Reference in new issue
Block a user