mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 20:43:36 +00:00
i18n: dialog labels use the language's colon
Dialogs and the toolbar editors added a plain ":" after a translated
label, so French showed "Points isolés:" without the no-break space
before the colon. A new `i18n::colon` helper appends the catalog's ":"
row instead. French writes U+00A0 before the colon, Chinese and Japanese
write a full-width colon, and English and the other languages are
unchanged.
- Field labels: the generic parameter dialogs, Text Flow, Radial Blur's
Horizontal and Vertical, the graph type dialog, and the headings of
the toolbar drawer and the Add Tool menu.
- A label followed by a value: Radial Blur's Blur Center value for
screen readers, the Simplify point count, the Dimension preview, the
Revolve reset tooltip, Smart Punctuation's report, the PDF and print
option summaries, the PSD import layer count, the Recolor color share
tooltip, the Revolve light names and the script check's problems.
- The style dialogs' attribute list showed two colons ("Font Size::
12"). It now shows one.
Part of #7991 (reported by bortekfr).
This commit is contained in:
@@ -1382,7 +1382,7 @@ fn add_menu(button: &egui::Response, t: &Tokens, bar: &CustomToolbar, actions: &
|
||||
let held: Vec<&'static str> = bar.slots.iter().flatten().filter_map(|id| tool_info(id).map(|t| t.id)).collect();
|
||||
let heading = |ui: &mut egui::Ui, text: &str| ui.label(egui::RichText::new(text).size(12.0).color(t.text_strong));
|
||||
if !held.is_empty() {
|
||||
heading(ui, &format!("{}:", tl!("Remove Tool")));
|
||||
heading(ui, &crate::i18n::colon(tl!("Remove Tool")));
|
||||
for tool in held.iter().filter_map(|id| tool_info(id)) {
|
||||
if widgets::menu_item(ui, tool.label, true, false) {
|
||||
actions.push(Action::RemoveTool(bar.name.clone(), tool.id));
|
||||
@@ -1391,7 +1391,7 @@ fn add_menu(button: &egui::Response, t: &Tokens, bar: &CustomToolbar, actions: &
|
||||
ui.separator();
|
||||
}
|
||||
for (cat, tools) in crate::edit_toolbar::sections() {
|
||||
heading(ui, &format!("{}:", tl!(cat)));
|
||||
heading(ui, &crate::i18n::colon(tl!(cat)));
|
||||
for tool in tools {
|
||||
if widgets::menu_item(ui, tool.label, !held.contains(&tool.id), false) {
|
||||
actions.push(Action::AddTool(bar.name.clone(), tool.id));
|
||||
|
||||
@@ -1073,7 +1073,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
|
||||
ui.separator();
|
||||
if let Ok(attrs) = edited_attrs(d) {
|
||||
for (key, value) in attrs {
|
||||
ui.label(format!("{}: {}", super::humanize(&key), value));
|
||||
ui.label(super::form::attribute_line(&key, &value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ pub(super) const SPEC: DialogSpec = DialogSpec {
|
||||
let mut rows = v.as_str() == Some("rows");
|
||||
ui.add_space(4.0);
|
||||
egui::Grid::new("text-flow").num_columns(2).spacing([12.0, 8.0]).show(ui, |ui| {
|
||||
let row = ui.label(egui::RichText::new(format!("{}:", tl!("Text Flow"))).color(Tokens::get(ui.ctx()).text));
|
||||
let row = ui.label(egui::RichText::new(crate::i18n::colon(tl!("Text Flow"))).color(Tokens::get(ui.ctx()).text));
|
||||
ui.label_inputs_by(row.id, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
if widgets::radio(ui, tl!("By Rows"), rows, true) {
|
||||
|
||||
@@ -211,7 +211,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, d: &mut Dialog) -> bool {
|
||||
Ok(o) => {
|
||||
let sample = o.label(72.0, false).unwrap_or_default();
|
||||
let t = Tokens::get(ui.ctx());
|
||||
ui.label(RichText::new(format!("{}: {sample}", tl!("Preview (1 inch on the page)"))).color(t.text));
|
||||
ui.label(RichText::new(format!("{} {sample}", crate::i18n::colon(tl!("Preview (1 inch on the page)")))).color(t.text));
|
||||
}
|
||||
Err(e) => {
|
||||
ui.colored_label(Tokens::get(ui.ctx()).text, e);
|
||||
|
||||
@@ -317,6 +317,13 @@ fn center_round(x: f64) -> f64 {
|
||||
(x * 1e4).round() / 1e4
|
||||
}
|
||||
|
||||
/// The value screen readers give Blur Center at `c` (0 to 1 of the bounds): Horizontal and
|
||||
/// Vertical in percent, each label followed by the UI language's colon.
|
||||
pub(super) fn blur_center_value(c: [f64; 2]) -> String {
|
||||
let percent = |v: f64| (v * 1000.0).round() / 10.0;
|
||||
format!("{} {}%, {} {}%", crate::i18n::colon(tl!("Horizontal")), percent(c[0]), crate::i18n::colon(tl!("Vertical")), percent(c[1]))
|
||||
}
|
||||
|
||||
/// Radial Blur's Blur Center: a box standing for the object's bounds, with the blur's pattern (rays
|
||||
/// for Zoom, rings for Spin) drawn about the center. A press or a drag in the box puts the center
|
||||
/// there; with the keyboard focus the arrow keys move it 1 % of the box (10 % with Shift). The
|
||||
@@ -334,9 +341,8 @@ fn blur_center(ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
let (rect, _) = ui.allocate_exact_size(egui::vec2(CENTER_BOX, CENTER_BOX), Sense::hover());
|
||||
let id = ui.scope_id().with("radial-blur-center");
|
||||
let resp = ui.interact(rect, id, Sense::click_and_drag());
|
||||
let percent = |v: f64| (v * 1000.0).round() / 10.0;
|
||||
let name = tl!("Blur Center").to_string();
|
||||
let value = format!("{}: {}%, {}: {}%", tl!("Horizontal"), percent(c[0]), tl!("Vertical"), percent(c[1]));
|
||||
let value = blur_center_value(c);
|
||||
let enabled = ui.is_enabled();
|
||||
resp.widget_info(|| egui::WidgetInfo {
|
||||
current_text_value: Some(value.clone()),
|
||||
@@ -391,7 +397,7 @@ fn blur_center(ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
ui.vertical(|ui| {
|
||||
egui::Grid::new("blur-center-fields").num_columns(2).spacing([8.0, 8.0]).show(ui, |ui| {
|
||||
for (i, label) in ["Horizontal", "Vertical"].into_iter().enumerate() {
|
||||
let row = ui.label(egui::RichText::new(format!("{}:", tl!(label))).color(t.text));
|
||||
let row = ui.label(egui::RichText::new(crate::i18n::colon(tl!(label))).color(t.text));
|
||||
ui.label_inputs_by(row.id, |ui| {
|
||||
if let Some(x) =
|
||||
widgets::range_field_named(ui, ("blur-center", i), None, c[i] * 100.0, 0.0..=100.0, &form::unit_suffix("%"), 1, 72.0)
|
||||
|
||||
@@ -832,11 +832,17 @@ pub(crate) fn humanize(k: &str) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// [`humanize`] translated where it is painted: the ":" stays outside the translated text.
|
||||
/// A style attribute as the style dialogs list it: the [`humanized`] key, then its value.
|
||||
pub(super) fn attribute_line(key: &str, value: &Value) -> String {
|
||||
format!("{} {value}", humanized(key))
|
||||
}
|
||||
|
||||
/// [`humanize`] translated where it is painted: the ":" stays outside the translated text and is
|
||||
/// written as the UI language writes a label's colon ([`crate::i18n::colon`]).
|
||||
pub(super) fn humanized(k: &str) -> String {
|
||||
let h = humanize(k);
|
||||
match h.strip_suffix(':') {
|
||||
Some(base) => format!("{}:", tl!(base)),
|
||||
Some(base) => crate::i18n::colon(tl!(base)),
|
||||
None => tl!(&h).to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,9 +577,9 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// `text` with the colon of a field label.
|
||||
/// `text` with the colon of a field label, as the UI language writes it.
|
||||
fn colon(text: &str) -> String {
|
||||
format!("{text}:")
|
||||
crate::i18n::colon(text)
|
||||
}
|
||||
|
||||
/// A checkbox bound to `d.fields[key]`, dimmed while the type picked has no use for it.
|
||||
@@ -977,6 +977,22 @@ mod tests {
|
||||
assert!(app.ui.dialog.is_none());
|
||||
}
|
||||
|
||||
/// Field labels end in the UI language's colon: in French a no-break space and a colon (#7991).
|
||||
#[test]
|
||||
fn field_labels_use_the_language_colon() {
|
||||
let mut app = app_with_graph("column");
|
||||
crate::menus::invoke(&mut app, COMMAND, json!({}));
|
||||
set(&mut app, PAGE, json!("valueAxis"));
|
||||
let fr = crate::i18n::Lang::from_code("fr").unwrap();
|
||||
crate::i18n::set_current(fr);
|
||||
let mut h = harness(app);
|
||||
h.run_steps(3);
|
||||
let want = format!("{}\u{a0}:", crate::i18n::tr(fr, "Suffix"));
|
||||
let found = h.query_by_role_and_label(Role::TextInput, &want).is_some();
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
assert!(found, "a text field named {want:?}");
|
||||
}
|
||||
|
||||
/// A Type button changes the graph's type and keeps its data.
|
||||
#[test]
|
||||
fn a_type_button_changes_the_graph_type_and_keeps_its_data() {
|
||||
|
||||
@@ -77,7 +77,7 @@ fn body(_: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
|
||||
});
|
||||
if let Ok(attrs) = super::char_style_options::edited_attrs(d) {
|
||||
for (key, value) in attrs {
|
||||
ui.label(format!("{}: {}", super::humanize(&key), value));
|
||||
ui.label(super::form::attribute_line(&key, &value));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -952,7 +952,7 @@ pub(crate) fn general_body(ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
ui.separator();
|
||||
if let Ok(attrs) = edited_attrs(d) {
|
||||
for (key, value) in attrs {
|
||||
ui.label(format!("{}: {}", super::humanize(&key), value));
|
||||
ui.label(super::form::attribute_line(&key, &value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
|
||||
&& let Some(counts) = d.fields.get("__counts")
|
||||
&& let (Some(before), Some(after)) = (counts["before"].as_u64(), counts["after"].as_u64())
|
||||
{
|
||||
ui.label(format!("{}: {before} → {after}", tl!("Anchor Points")));
|
||||
ui.label(format!("{} {before} → {after}", crate::i18n::colon(tl!("Anchor Points"))));
|
||||
}
|
||||
}
|
||||
false
|
||||
|
||||
@@ -167,7 +167,7 @@ fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result<Value, String> {
|
||||
|
||||
fn body(_: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
|
||||
let count = |k: &str| d.fields.get(k).and_then(Value::as_u64).unwrap_or(0);
|
||||
widgets::dim_label(ui, &format!("{} × {} px · {}: {}", count("width"), count("height"), tl!("Layers"), count("layers")));
|
||||
widgets::dim_label(ui, &format!("{} × {} px · {} {}", count("width"), count("height"), crate::i18n::colon(tl!("Layers")), count("layers")));
|
||||
// Offered only for a file with slices, with either conversion.
|
||||
let sliced = count("slices") > 0;
|
||||
ui.add_space(8.0);
|
||||
|
||||
@@ -357,7 +357,8 @@ fn prominent_bar(ui: &mut Ui, d: &mut Dialog, rows: &[Value]) {
|
||||
let c = to_color(&rows[*i]).or_else(|| from_colors(&rows[*i]).first().copied()).unwrap_or_default();
|
||||
chip(ui, r, c, false);
|
||||
let share = (widths[n] * 100.0).round();
|
||||
ui.interact(r, egui::Id::unique((PROMINENT_PART, n)), Sense::hover()).on_hover_text(format!("{} {}: {share}%", tl!("Color"), i + 1));
|
||||
ui.interact(r, egui::Id::unique((PROMINENT_PART, n)), Sense::hover())
|
||||
.on_hover_text(format!("{} {share}%", crate::i18n::colon(&format!("{} {}", tl!("Color"), i + 1))));
|
||||
left = right;
|
||||
}
|
||||
let mut ended = false;
|
||||
|
||||
@@ -733,7 +733,7 @@ pub(super) fn reset_dot(ui: &mut egui::Ui, key: &str, changed: bool, default: &s
|
||||
ui.painter().rect_filled(r, 3.0, Tokens::get(ui.ctx()).hover);
|
||||
}
|
||||
dot(ui, r.center(), changed);
|
||||
response.on_hover_text(format!("{}: {default}", tl!("Reset to default"))).clicked()
|
||||
response.on_hover_text(format!("{} {default}", crate::i18n::colon(tl!("Reset to default")))).clicked()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -75,7 +75,8 @@ impl Light {
|
||||
/// The name screen readers give the light at `index`: its number, Rotation, Height and side.
|
||||
fn name(self, index: usize) -> String {
|
||||
let side = if self.behind { format!(", {}", tl!("Light behind the object")) } else { String::new() };
|
||||
format!("{} {}: {} {:.1}°, {} {:.1}°{side}", c3("Light"), index + 1, tl!("Rotation"), self.rotation, tl!("Height"), self.height)
|
||||
let light = crate::i18n::colon(&format!("{} {}", c3("Light"), index + 1));
|
||||
format!("{light} {} {:.1}°, {} {:.1}°{side}", tl!("Rotation"), self.rotation, tl!("Height"), self.height)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -871,7 +871,7 @@ pub(super) fn option_rows<'a>(ui: &mut egui::Ui, changed: impl IntoIterator<Item
|
||||
Value::String(s) => s.clone(),
|
||||
other => other.to_string(),
|
||||
};
|
||||
ui.label(egui::RichText::new(format!("{}: {value}", label(c["option"].as_str().unwrap_or_default()))).color(t.text));
|
||||
ui.label(egui::RichText::new(format!("{} {value}", crate::i18n::colon(&label(c["option"].as_str().unwrap_or_default())))).color(t.text));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ fn report(ui: &mut egui::Ui, r: &Value, t: &Tokens) {
|
||||
for p in problems {
|
||||
let Some(label) = p["code"].as_str().and_then(problem_label) else { continue };
|
||||
let label = match p["detail"].as_str() {
|
||||
Some(detail) => format!("{label}: {detail}"),
|
||||
Some(detail) => format!("{} {detail}", crate::i18n::colon(label)),
|
||||
None => label.to_string(),
|
||||
};
|
||||
row(ui, t, &label, false, &place(p));
|
||||
|
||||
@@ -98,7 +98,7 @@ fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> DialogResult {
|
||||
let lines: Vec<String> = options()
|
||||
.into_iter()
|
||||
.filter(|(key, ..)| d.bool(key))
|
||||
.map(|(_, count, label)| format!("{label}: {}", r["replaced"][count].as_u64().unwrap_or(0)))
|
||||
.map(|(_, count, label)| format!("{} {}", crate::i18n::colon(label), r["replaced"][count].as_u64().unwrap_or(0)))
|
||||
.collect();
|
||||
super::confirm::tell(app, tl!("Smart Punctuation"), &lines.join("\n"));
|
||||
}
|
||||
|
||||
@@ -178,6 +178,64 @@ fn effect_preview_is_kept_as_one_undo_step() {
|
||||
assert_eq!(app.session.doc().unwrap().doc, before);
|
||||
}
|
||||
|
||||
/// A field label's colon is written as the UI language writes it, in the generic parameter
|
||||
/// dialogs and the effect dialogs alike (#7991): French puts a no-break space before it, Chinese
|
||||
/// writes a full-width colon, and English is unchanged.
|
||||
#[test]
|
||||
fn field_label_colons_follow_the_ui_language() {
|
||||
let mut app = app();
|
||||
app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 50})).unwrap();
|
||||
let text =
|
||||
app.run("text.create", json!({"x": 20, "y": 80, "text": "Hello", "area": {"width": 100, "height": 100}})).unwrap()["id"].as_u64().unwrap();
|
||||
// Each dialog, opened the way its menu item opens it, and the label it shows.
|
||||
let entries = crate::menus::menu_entries(&app);
|
||||
let clean_up = entries.iter().find(|e| e.path == ["Object", "Path"] && e.label == "Clean Up…").expect("listed");
|
||||
let clean_up = crate::menus::click_target(&clean_up.label, clean_up.command.as_deref().unwrap(), &clean_up.params);
|
||||
let dialogs = [
|
||||
(clean_up.0, clean_up.1, "Stray Points"),
|
||||
("effect.dialog".to_string(), json!({"effect": "blur.radial"}), "Horizontal"),
|
||||
("text.areaOptions".to_string(), json!({}), "Text Flow"),
|
||||
];
|
||||
for (command, params, label) in dialogs {
|
||||
app.run("select.set", json!({"ids": [text]})).unwrap();
|
||||
if command != "text.areaOptions" {
|
||||
app.run("select.all", json!({})).unwrap();
|
||||
}
|
||||
crate::menus::invoke(&mut app, &command, params);
|
||||
assert!(app.ui.dialog.is_some(), "{command} opened no dialog");
|
||||
for (code, colon) in [("fr", "\u{a0}:"), ("zh-hans", ":"), ("en", ":")] {
|
||||
let lang = crate::i18n::Lang::from_code(code).unwrap();
|
||||
crate::i18n::set_current(lang);
|
||||
let shown = crate::tests_labels::painted_text(&mut app, |app, ui| show(app, ui.ctx()));
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
let want = format!("{}{colon}", crate::i18n::tr(lang, label));
|
||||
assert!(shown.lines().any(|l| l.trim() == want), "{command}, {code}: {want:?} in {shown}");
|
||||
if code == "fr" {
|
||||
let bare: Vec<_> = shown.lines().map(str::trim).filter(|l| l.ends_with(':') && !l.ends_with("\u{a0}:")).collect();
|
||||
assert!(bare.is_empty(), "{command}: French labels with a bare colon: {bare:?}");
|
||||
}
|
||||
}
|
||||
app.ui.dialog = None;
|
||||
}
|
||||
assert_eq!(super::form::humanized("strayPoints"), "Stray Points:", "English is unchanged");
|
||||
}
|
||||
|
||||
/// A label followed by its value takes the UI language's colon too (#7991): Blur Center's value for
|
||||
/// screen readers, and a style's attribute list, which no longer shows a second colon.
|
||||
#[test]
|
||||
fn label_and_value_colons_follow_the_ui_language() {
|
||||
let fr = crate::i18n::Lang::from_code("fr").unwrap();
|
||||
crate::i18n::set_current(fr);
|
||||
let center = super::effect::blur_center_value([0.5, 0.25]);
|
||||
let attribute = super::form::attribute_line("fontSize", &json!(12));
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
let (h, v) = (crate::i18n::tr(fr, "Horizontal"), crate::i18n::tr(fr, "Vertical"));
|
||||
assert_eq!(center, format!("{h}\u{a0}: 50%, {v}\u{a0}: 25%"));
|
||||
assert_eq!(attribute, format!("{}\u{a0}: 12", crate::i18n::tr(fr, "Font Size")));
|
||||
assert_eq!(super::effect::blur_center_value([0.5, 0.25]), "Horizontal: 50%, Vertical: 25%");
|
||||
assert_eq!(super::form::attribute_line("fontSize", &json!(12)), "Font Size: 12");
|
||||
}
|
||||
|
||||
/// Drop Shadow's Color typed as text the effect can't draw: OK returns the error and keeps the
|
||||
/// dialog open, with Preview on or off, and the document stays as it was.
|
||||
#[test]
|
||||
|
||||
@@ -678,6 +678,14 @@ fn simplify_dialog_preview_counts_and_cancel_restore_the_original() {
|
||||
let texts = frame(&ctx, &mut app, vec![]);
|
||||
let preview = texts.iter().find(|(t, _)| t == "Preview").map(|(_, r)| *r).expect("a Preview checkbox");
|
||||
assert!(texts.iter().any(|(t, _)| t == "Anchor Points: 20 → 2"), "the reduction is visible: {texts:?}");
|
||||
// In French the label ends in a no-break space and a colon (#7991).
|
||||
let fr = crate::i18n::Lang::from_code("fr").unwrap();
|
||||
crate::i18n::set_current(fr);
|
||||
let french = frame(&ctx, &mut app, vec![]);
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
let want = format!("{}\u{a0}: 20 → 2", crate::i18n::tr(fr, "Anchor Points"));
|
||||
assert!(french.iter().any(|(t, _)| *t == want), "{want:?} in {french:?}");
|
||||
frame(&ctx, &mut app, vec![]);
|
||||
assert!(app.session.in_interaction());
|
||||
assert!(app.session.doc().unwrap().selection.anchors.is_empty());
|
||||
assert_eq!(app.session.doc().unwrap().history.undo.len(), undo_len);
|
||||
|
||||
@@ -532,7 +532,7 @@ pub(crate) fn drawer(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
let inner = ui.available_width() - 10.0;
|
||||
for (cat, gs) in groups() {
|
||||
ui.add_space(6.0);
|
||||
ui.label(egui::RichText::new(format!("{}:", tl!(cat))).size(12.0).color(t.text_strong));
|
||||
ui.label(egui::RichText::new(crate::i18n::colon(tl!(cat))).size(12.0).color(t.text_strong));
|
||||
ui.add_space(4.0);
|
||||
for g in gs {
|
||||
// A flyout group: its tools framed together, as one toolbar button holds them.
|
||||
|
||||
@@ -319,6 +319,25 @@ fn tools_in_the_toolbar_are_dimmed_in_the_drawer() {
|
||||
assert_eq!(cell_at(&shown, drawer, "Artboard Tool").1, dim);
|
||||
}
|
||||
|
||||
/// The drawer's headings end in the UI language's colon: in French a no-break space and a colon
|
||||
/// (#7991), in English a plain colon.
|
||||
#[test]
|
||||
fn drawer_headings_use_the_language_colon() {
|
||||
let mut app = app();
|
||||
let ctx = ctx();
|
||||
app.run("window.editToolbar", json!({"open": true})).unwrap();
|
||||
for (code, colon) in [("fr", "\u{a0}:"), ("en", ":")] {
|
||||
let lang = crate::i18n::Lang::from_code(code).unwrap();
|
||||
crate::i18n::set_current(lang);
|
||||
frame(&mut app, &ctx, 0.0, vec![]);
|
||||
let shown = frame(&mut app, &ctx, 0.1, vec![]);
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
let drawer = drawer_rect(&ctx).unwrap();
|
||||
let want = format!("{}{colon}", crate::i18n::tr(lang, "Select"));
|
||||
assert!(shown.iter().any(|(s, p, _)| s.trim() == want && drawer.contains(*p)), "{code}: {want:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// #1018: tools drag from the drawer onto the toolbar (between two tools, or onto one to join
|
||||
/// its group), from the toolbar into the drawer, and within the toolbar, only while the drawer
|
||||
/// is open.
|
||||
@@ -543,6 +562,17 @@ fn the_add_tool_menu_fills_a_new_toolbar_without_a_drag() {
|
||||
click(&mut app, &ctx, 40.0, items(&shown, "Lasso Tool")[0].0);
|
||||
assert_eq!(mine(&app), [["magicWand"]]);
|
||||
assert_eq!(slots(&app), shipped);
|
||||
// In French the menu's headings end in a no-break space and a colon (#7991).
|
||||
open(&mut app, 49.0);
|
||||
let fr = crate::i18n::Lang::from_code("fr").unwrap();
|
||||
crate::i18n::set_current(fr);
|
||||
frame(&mut app, &ctx, 49.7, vec![]);
|
||||
let french = frame(&mut app, &ctx, 49.8, vec![]);
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
for heading in ["Remove Tool", "Select"] {
|
||||
let want = format!("{}\u{a0}:", crate::i18n::tr(fr, heading));
|
||||
assert_eq!(items(&french, &want).len(), 1, "{want:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// New Toolbar… in the drawer's menu opens the New Toolbar dialog, which asks for a name.
|
||||
|
||||
@@ -623,6 +623,13 @@ pub fn t(s: &str) -> &str {
|
||||
tr(current(), s)
|
||||
}
|
||||
|
||||
/// `label`, already in the current language, followed by a field label's colon as the current
|
||||
/// language writes it (its catalog row for ":"): French puts a no-break space before the colon, and
|
||||
/// Chinese and Japanese write a full-width colon.
|
||||
pub fn colon(label: &str) -> String {
|
||||
format!("{label}{}", t(":"))
|
||||
}
|
||||
|
||||
/// Translate an English UI string; unknown strings come back unchanged.
|
||||
pub fn tr(lang: Lang, s: &str) -> &str {
|
||||
lang.catalog().plain(s).unwrap_or(s)
|
||||
|
||||
@@ -2041,6 +2041,17 @@ fn georgian_rows_have_no_mtavruli() {
|
||||
assert!(caps.is_empty(), "Mtavruli in ka.tsv: {caps:?}");
|
||||
}
|
||||
|
||||
/// A field label's colon follows the catalog's ":" row: French puts a no-break space before it,
|
||||
/// Chinese and Japanese write a full-width colon, and English and German write a plain colon.
|
||||
#[test]
|
||||
fn label_colons_follow_the_language() {
|
||||
for (code, want) in [("fr", "X\u{a0}:"), ("zh-hans", "X:"), ("zh-hant", "X:"), ("ja", "X:"), ("de", "X:"), ("en", "X:")] {
|
||||
set_current(Lang::from_code(code).expect("registered"));
|
||||
assert_eq!(colon("X"), want, "{code}");
|
||||
}
|
||||
set_current(Lang::EN);
|
||||
}
|
||||
|
||||
/// French rows follow the typography fr.tsv's header sets: a no-break space before : ; ? ! and inside
|
||||
/// « », and the typographic apostrophe ’ in elisions. Text in backticks is code and is not checked, and
|
||||
/// a straight apostrophe inside double quotes is a literal value.
|
||||
|
||||
Reference in New Issue
Block a user