Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Integration: column counts and list numbers have their own captions; pt-BR and Arabic Pages menu rows

aiongg01325233963d
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index 935d88d26..1a2b00f76 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -542,7 +542,7 @@ fn general(lang: &str, ui: &mut egui::Ui, d: &mut Dialog) {
crate::rtl::label(ui, tr("Columns:"));
translated_combo(lang, ui, d, "columnsKind", &[("fixedNumber", "Fixed Number"), ("fixedWidth", "Fixed Width")]);
ui.end_row();
- crate::rtl::label(ui, tr("Number:"));
+ crate::rtl::label(ui, crate::i18n::tr_context(lang, "Number:", "count"));
text_field(ui, d, "columns", 70.0);
// Fixed Number: the width follows from the frame; Fixed Width: it's set here.
crate::rtl::label(ui, tr("Width:"));
@@ -943,7 +943,7 @@ fn margins_and_columns_dialog(app: &mut DesignApp, ui: &mut egui::Ui, d: &mut Di
ui.add_space(8.0);
group_box(ui, &tr("Columns"), |ui| {
ui.horizontal(|ui| {
- caption_right(ui, &tr("Number:"), 72.0);
+ caption_right(ui, crate::i18n::tr_context(&lang, "Number:", "count"), 72.0);
text_field(ui, d, "columns", 76.0);
ui.add_space(28.0);
caption_right(ui, &tr("Gutter:"), 72.0);
@@ -995,7 +995,7 @@ fn create_guides_dialog(app: &mut DesignApp, ui: &mut egui::Ui, d: &mut Dialog)
for (title, n, g, id) in [("Rows", "rows", "rowGutter", "cg_rows"), ("Columns", "columns", "columnGutter", "cg_cols")] {
group_box(ui, &tr(title), |ui| {
egui::Grid::new(id).num_columns(2).spacing([6.0, 6.0]).show(ui, |ui| {
- caption_right(ui, &tr("Number:"), 72.0);
+ caption_right(ui, crate::i18n::tr_context(&lang, "Number:", "count"), 72.0);
text_field(ui, d, n, 70.0);
ui.end_row();
caption_right(ui, &tr("Gutter:"), 72.0);
diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs
index 6d4913c77..c4127be6e 100644
--- a/crates/ui-egui/src/i18n.rs
+++ b/crates/ui-egui/src/i18n.rs
@@ -179,7 +179,7 @@ const TABLE: &[(&str, [&str; 5])] = &[
("Auto", ["Automatisch", "Automatique", "Automático", "自動", "自动"]),
("W:", ["B:", "L :", "An.:", "幅:", "宽:"]),
("H:", ["H:", "H :", "Al.:", "高さ:", "高:"]),
- ("Number:", ["Anzahl:", "Nombre :", "Número:", "数:", "数量:"]),
+ ("Number:", ["Zahl:", "Numéro:", "Número:", "番号:", "编号:"]),
("Gutter:", ["Steg:", "Gouttière :", "Medianil:", "間隔:", "栏间距:"]),
("Fit Guides to:", ["Hilfslinien einpassen in:", "Ajuster les repères à :", "Ajustar guías a:", "ガイドの適用先:", "参考线适合:"]),
("Top:", ["Oben:", "Haut :", "Superior:", "天:", "上:"]),
@@ -4400,6 +4400,12 @@ pub fn tr<'a>(lang: &str, s: &'a str) -> &'a str {
TRANSLATIONS.get_or_init(|| TABLE.iter().copied().collect()).get(s).and_then(|row| row.get(c)).copied().unwrap_or(s)
}
+/// Context-sensitive captions in the shared table's languages (columns as in [`TABLE`]).
+const CONTEXT: &[(&str, &str, [&str; 5])] = &[
+ // A count of columns or rows, unlike the numbering field's "Number:".
+ ("Number:", "count", ["Anzahl:", "Nombre :", "Número:", "数:", "数量:"]),
+];
+
/// Context-sensitive UI captions; unsupported contexts keep the shared translation.
pub fn tr_context<'a>(lang: &str, s: &'a str, context: &str) -> &'a str {
let contexts = match lang {
@@ -4408,9 +4414,18 @@ pub fn tr_context<'a>(lang: &str, s: &'a str, context: &str) -> &'a str {
"cs" => cs::CONTEXT,
"pl" => pl::CONTEXT,
"ja" => ja::CONTEXT,
- _ => return tr(lang, s),
+ "ar" => ar::CONTEXT,
+ _ => &[],
};
- contexts.iter().find(|(key, scope, _)| *key == s && *scope == context).map_or_else(|| tr(lang, s), |(_, _, text)| text)
+ if let Some((_, _, text)) = contexts.iter().find(|(key, scope, _)| *key == s && *scope == context) {
+ return text;
+ }
+ if let Some(c) = column(lang)
+ && let Some(text) = CONTEXT.iter().find(|(key, scope, _)| *key == s && *scope == context).and_then(|(_, _, row)| row.get(c))
+ {
+ return text;
+ }
+ tr(lang, s)
}
#[cfg(test)]
@@ -4563,6 +4578,36 @@ mod tests {
}
}
+ #[test]
+ fn a_column_count_and_a_list_number_read_differently() {
+ for (lang, count, numeral) in [
+ ("de", "Anzahl:", "Zahl:"),
+ ("ja", "数:", "番号:"),
+ ("uk", "Кількість:", "Номер:"),
+ ("ar", "العدد:", "الرقم:"),
+ ("fr", "Nombre :", "Numéro:"),
+ ("zh", "数量:", "编号:"),
+ ] {
+ assert_eq!((tr_context(lang, "Number:", "count"), tr(lang, "Number:")), (count, numeral), "{lang}");
+ }
+ assert_eq!(tr_context("en", "Number:", "count"), "Number:");
+ assert_eq!(tr("de", "Gutter:"), "Spaltenabstand:");
+ // The Pages panel menu.
+ for key in [
+ "Insert Pages…",
+ "Move Pages…",
+ "New Parent…",
+ "Override All Parent Page Items",
+ "Remove All Local Overrides",
+ "Detach All Objects from Parent",
+ "Create Alternate Layout…",
+ "Allow Selected Spread to Shuffle",
+ ] {
+ assert_ne!(tr("pt-br", key), key);
+ }
+ assert_ne!(tr("ar", "Apply Parent to Pages"), "Apply Parent to Pages");
+ }
+
#[test]
fn french_catalog_has_no_duplicate_or_stale_keys_and_keeps_placeholders() {
let catalog: HashMap<_, _> = fr::TABLE.iter().copied().collect();
diff --git a/crates/ui-egui/src/i18n/ar.rs b/crates/ui-egui/src/i18n/ar.rs
index ae57fbd4a..386db9467 100644
--- a/crates/ui-egui/src/i18n/ar.rs
+++ b/crates/ui-egui/src/i18n/ar.rs
@@ -1273,6 +1273,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Apply Attributes (Eyedropper)", "تطبيق السمات (القطارة)"),
("Apply Cell Style", "تطبيق نمط الخلية"),
("Apply Condition", "تطبيق شرط"),
+ ("Apply Parent to Pages", "تطبيق الأصل على الصفحات"),
("Apply Parent to Pages…", "تطبيق الصفحة الأصلية على الصفحات…"),
("ArtCraft App Page…", "صفحة تطبيق ArtCraft…"),
("ArtCraft Website…", "موقع ArtCraft…"),
@@ -1987,3 +1988,6 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("i, ii, iii, iv...", "أ، ب، ج، د..."),
("lowercase", "صغير"),
];
+
+/// Contexts whose Arabic caption differs from the shared label.
+pub(super) const CONTEXT: &[(&str, &str, &str)] = &[("Number:", "count", "العدد:")];
diff --git a/crates/ui-egui/src/i18n/de.rs b/crates/ui-egui/src/i18n/de.rs
index 92ca341c1..a518cc627 100644
--- a/crates/ui-egui/src/i18n/de.rs
+++ b/crates/ui-egui/src/i18n/de.rs
@@ -1800,6 +1800,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("List Type:", "Listentyp:"),
("List:", "Liste:"),
("Mode:", "Modus:"),
+ ("Gutter:", "Spaltenabstand:"),
("Number:", "Zahl:"),
("Numbers", "Nummerierung"),
("On Next Even Page", "Auf nächster gerader Seite"),
diff --git a/crates/ui-egui/src/i18n/pt_br.rs b/crates/ui-egui/src/i18n/pt_br.rs
index 563a3cd38..16b12808b 100644
--- a/crates/ui-egui/src/i18n/pt_br.rs
+++ b/crates/ui-egui/src/i18n/pt_br.rs
@@ -996,6 +996,14 @@ pub(super) const TABLE: &[(&str, &str)] = &[
("Delete Spread", "Excluir página espelhada"),
("Parent Pages", "Páginas principais"),
("Apply Parent to Pages", "Aplicar página principal às páginas"),
+ ("Insert Pages…", "Inserir páginas…"),
+ ("Move Pages…", "Mover páginas…"),
+ ("New Parent…", "Nova página principal…"),
+ ("Override All Parent Page Items", "Substituir todos os itens da página principal"),
+ ("Remove All Local Overrides", "Remover todas as substituições locais"),
+ ("Detach All Objects from Parent", "Desanexar todos os objetos da página principal"),
+ ("Create Alternate Layout…", "Criar layout alternativo…"),
+ ("Allow Selected Spread to Shuffle", "Permitir que a página espelhada selecionada seja reorganizada"),
("Email", "E-mail"),
("Embed", "Embutir"),
("Fast", "Rápido"),
diff --git a/crates/ui-egui/src/i18n/uk.rs b/crates/ui-egui/src/i18n/uk.rs
index 705cebfb3..c96e24064 100644
--- a/crates/ui-egui/src/i18n/uk.rs
+++ b/crates/ui-egui/src/i18n/uk.rs
@@ -1784,4 +1784,4 @@ pub(super) const TABLE: &[(&str, &str)] = &[
/// Contexts whose Ukrainian noun differs from the shared action/text-layout label.
pub(super) const CONTEXT: &[(&str, &str, &str)] =
- &[("Columns", "table", "Стовпці"), ("Columns:", "grid", "Стовпці:"), ("Group", "selection", "Група")];
+ &[("Columns", "table", "Стовпці"), ("Columns:", "grid", "Стовпці:"), ("Group", "selection", "Група"), ("Number:", "count", "Кількість:")];