i18n: the SVG variable-data warning names variable kinds in the interface language

Opening an SVG whose variable data holds variables that aren't text
warns about them with a list of kinds and counts. The sentence was
translated, but the list stayed in English and used the file's raw
`trait` values (`visibility (2), fileref (1)`), and a missing `trait`
and a `trait` written as `unknown` were counted together.

- The engine's English warning now names the kinds Visibility, Linked
  File, Graph Data and Unknown (a variable without a `trait`). Any
  other `trait` is written as the file writes it, in backticks, with
  each backtick in it doubled, so a `trait` such as `Visibility` or
  one holding a comma stays a single entry.
- The status bar shows those kinds through new `variable-kind` rows
  and joins the entries with `variable-list-two`, `variable-list-middle`
  and `variable-list-end` rows, in every complete-message catalog.
  A list in any other form is shown as before.
- The French row puts the list after a colon instead of inside
  parentheses, and the Hindi row is reworded so it says that the
  variables that aren't text were left out.
This commit is contained in:
dotCooCoo
2026-11-15 14:06:40 -08:00
parent bb218101c9
commit f260510ced
31 changed files with 372 additions and 13 deletions
+20 -5
View File
@@ -619,7 +619,21 @@ pub(crate) fn give_svg_library(doc: &mut Document, lib: Library, found: &HashMap
}
}
doc.variables = vars.into();
left_out_warning(other.iter().map(|v| v.trait_name.as_deref().unwrap_or_else(|| v.kind.label())))
left_out_warning(other.iter().map(|v| left_out_kind(v.kind, v.trait_name.as_deref())))
}
/// How the warning about variables that aren't text names the kind of one: Visibility, Linked File
/// or Graph Data for a `trait` VectorCraft reads, Unknown for a variable without a `trait`, and any
/// other `trait` as the file writes it, in backticks, each backtick in it doubled, so that a `trait`
/// such as `Unknown` or `a (1), b` reads as one kind the file names.
fn left_out_kind(kind: VariableKind, trait_name: Option<&str>) -> String {
match (kind, trait_name) {
(VariableKind::Visibility, _) => "Visibility".into(),
(VariableKind::Image, _) => "Linked File".into(),
(VariableKind::Graph, _) => "Graph Data".into(),
(_, None) => "Unknown".into(),
(_, Some(t)) => format!("`{}`", t.replace('`', "``")),
}
}
/// Load Variable Library: replace the document's variables and data sets with a variable library's
@@ -668,10 +682,11 @@ pub(super) fn load_library(s: &mut Session, p: &Value) -> Result<Value> {
Ok(json!({"variables": declared, "deleted": deleted, "deletedDataSets": deleted_sets, "names": names}))
}
/// The warning about variables that aren't text and were left out, given the kind of each: every
/// kind once, in the order it first comes, with how many variables have it. `None` without any.
fn left_out_warning<'a>(kinds: impl Iterator<Item = &'a str>) -> Option<String> {
let mut counted: Vec<(&str, usize)> = Vec::new();
/// The warning about variables that aren't text and were left out, given the kind of each
/// ([`left_out_kind`]): every kind once, in the order it first comes, with how many variables have
/// it. `None` without any.
fn left_out_warning(kinds: impl Iterator<Item = String>) -> Option<String> {
let mut counted: Vec<(String, usize)> = Vec::new();
for t in kinds {
match counted.iter_mut().find(|(k, _)| *k == t) {
Some((_, n)) => *n += 1,