mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-17 21:27:00 +00:00
i18n: printer names keep their parentheses in the print messages
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.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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"],
|
||||
|
||||
Reference in New Issue
Block a user