From 77a509a9c61eb5d9d31872362f1a71b38948a2bf Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 05:09:47 -0800 Subject: [PATCH] i18n: printer names keep their parentheses in the print messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A printer name in "Sent “{title}” to {to}" was translated as a message of its own, so Korean's "{status} ({e})" row turned "Office Laser (Floor 2)" into "Office Laser(Floor 2)". An unquoted `{to}` value is now translated only by an exact row, such as "the default printer"; a quoted one stays as written. The cross-language case uses a printer name with parentheses, and two quoted `{to}` names that match exact rows. --- crates/ui-egui/src/i18n.rs | 7 +++++-- crates/ui-egui/src/i18n/tests.rs | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs index d54ea0178a..24578b18b2 100644 --- a/crates/ui-egui/src/i18n.rs +++ b/crates/ui-egui/src/i18n.rs @@ -683,8 +683,10 @@ const MESSAGE_DEPTH: usize = 5; /// parts of them (file names, numbers, a reason with no entry, a JSON object or array such as /// `{"objects": [...]}`, a value the message quotes in `"…"`, `“…”`, `'…'` or backticks, such as a /// symbol's or a script property's name, and an `{ident}` placeholder's value, a script identifier), -/// stay as they are. A part that starts with `{` is translated only when it is a whole message with -/// an exact entry. A part that starts with `[` is translated when it has an exact entry, such as +/// stay as they are. A `{to}` placeholder's value that is not quoted, a printer's name such as +/// `Office Laser (Floor 2)`, is translated only when it has an exact entry, such as +/// `the default printer`. A part that starts with `{` is translated only when it is a whole message +/// with an exact entry. A part that starts with `[` is translated when it has an exact entry, such as /// `[x, y] (two numbers)`, or when it fits a template that starts with `[` and an index of digits, /// such as an effect's refusal ``[0] `id`: {why}``. pub fn message(lang: Lang, s: &str) -> String { @@ -727,6 +729,7 @@ fn fill_message(lang: Lang, s: &str, found: Option<(&[String], catalog::Captures (Some((tool, _)), "_1") => (k, tool.clone()), (Some((_, kinds)), "_2") => (k, kinds.clone()), (_, "ident") => (k, v.to_string()), + (_, "to") if !quoted(v) => (k, exact_translation(lang.catalog(), v).unwrap_or_else(|| v.to_string())), _ => (k, nested(v)), }) .collect(); diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index 48fdfeccf2..c25b173398 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -2682,10 +2682,12 @@ fn messages_with_joined_values_translate_whole() { ("Sent “Poster” to the default printer".to_string(), vec!["“Poster”"], vec!["Sent", "default"]), ("Sent “Poster” to Office Laser".to_string(), vec!["“Poster”", "Office Laser"], vec!["Sent"]), ( - "Sent “Poster” to Office Laser. The spooler replied: job 12".to_string(), - vec!["“Poster”", "Office Laser", "job 12"], + "Sent “Poster” to Office Laser (Floor 2). The spooler replied: job 12".to_string(), + vec!["“Poster”", "Office Laser (Floor 2)", "job 12"], vec!["Sent", "spooler", "replied"], ), + ("`canceled` is not an available name".to_string(), vec!["`canceled`"], vec![]), + ("a graphic style named `canceled` already exists".to_string(), vec!["`canceled`"], vec![]), ( "raster effects on object 7 (Logo): requested 300.0 ppi, achieved 72.0 ppi due to the 64 million pixel cap".to_string(), vec!["7", "Logo", "300.0", "72.0"],