Skip to content

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

Merge #236: Add Ukrainian interface translation

aiongg9b2304e99667
diff --cc ASSETS.md
index 6710e5395,66479bd7b..76052b5d1
--- a/ASSETS.md
+++ b/ASSETS.md
@@@ -8,9 -8,12 +8,13 @@@ Generated-in-code art is original and h
| Asset | Author | Source | Licence | Notes |
|---|---|---|---|---|
+ | `crates/ui-egui/src/i18n/uk.rs` (332 common phrases) | VectorCraft contributors | https://github.com/storytold/vectorcraft/blob/01f329aa99fa0c9517311c7b6cf7233ffc207742/crates/ui-egui/src/i18n/uk.tsv | MIT OR Apache-2.0 | Adapted for DesignCraft context; remaining Ukrainian phrases are original or credited below |
+ | `crates/ui-egui/src/i18n/uk.rs` (68 common phrases) | PhotoCraft contributors | https://github.com/storytold/photocraft/blob/ed057bdc6fd89a858c5e0ea4eab158a2a7052dde/crates/ui-egui/src/i18n/uk.tsv | MIT OR Apache-2.0 | Adapted interface vocabulary |
+ | `crates/ui-egui/src/i18n/uk.rs` (37 common phrases) | WordCraft contributors | https://github.com/storytold/wordcraft/blob/7fb7b013591e2593fbd038f90bbc535be318e5a3/crates/ui-egui/src/i18n/uk.tsv | MIT OR Apache-2.0 | Adapted interface vocabulary |
+ | `crates/ui-egui/src/i18n/uk.rs` (15 common phrases) | DeckCraft contributors | https://github.com/storytold/deckcraft/blob/3a45c614a409349fc13d449f35bd98f3321f0df5/crates/ui-egui/src/i18n/uk.tsv | MIT OR Apache-2.0 | Adapted interface vocabulary; validation dictionaries are external and are not bundled |
| `assets/hyphenation/en-us.dic` | Grady Ward (Moby Hyphenator II word list); converted by DesignCraft contributors | https://www.gutenberg.org/ebooks/3204 (file `https://www.gutenberg.org/files/3204/files/mhyph.txt`, SHA-256 `eeb30474c86b8af3469035ec1a0913e35905325ca885290db9dfed9881e230ac`) | Public Domain ("Public Domain material by grant from the author, January, 2001"; Project Gutenberg: "Public domain in the USA") | ~165k words with break points, front-coded + deflate; regenerate with `cargo run --release -p designcraft-compose --example hyphgen -- mhyph.txt assets/hyphenation` |
| `assets/hyphenation/en-us.pat` | DesignCraft contributors (generated) | trained from `en-us.dic`'s source list by `crates/compose/src/hyphen/patgen.rs` (`examples/hyphgen.rs`) | Public Domain (CC0-1.0) | Our own Liang hyphenation patterns (no TeX/hyph-utf8 patterns used) |
+| `assets/icc/sRGB-v2-magic.icc` | Clinton Ingram (Compact ICC Profiles) | https://github.com/saucecontrol/Compact-ICC-Profiles, `profiles/sRGB-v2-magic.icc` at `abb1b6f48570b4eb0fabd8566e517dca07e617d4`, SHA-256 `af4efe28f6d311799865f325ba39184a2e978b113ca74124d60af7de22b105f4` | Public Domain (CC0-1.0) | ICC v2.1 sRGB profile, 736 bytes. PDF/X-4 export tags RGB images that have no profile of their own with it |
| `assets/fonts/Inter-Medium.ttf` | Rasmus Andersson / The Inter Project Authors | https://github.com/rsms/inter | OFL-1.1 (`assets/fonts/OFL-Inter.txt`) | Open-source typeface |
| `assets/fonts/Inter-Regular.ttf` | Rasmus Andersson / The Inter Project Authors | https://github.com/rsms/inter | OFL-1.1 (`assets/fonts/OFL-Inter.txt`) | Open-source typeface |
| `assets/fonts/Inter-SemiBold.ttf` | Rasmus Andersson / The Inter Project Authors | https://github.com/rsms/inter | OFL-1.1 (`assets/fonts/OFL-Inter.txt`) | Open-source typeface |
diff --cc ROADMAP.md
index f25876432,52da71203..4ef32cea8
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -131,10 -102,10 +131,10 @@@ DesignCraft aims at full Adobe InDesig
- Split Window / New Window (`window.split`, `window.newWindow`, Window ▸ Arrange): two side-by-side views of the document with their own zoom, scroll and render cache. New Window puts the second view in its own OS window (an egui viewport; a floating window on the web).
- Transparency flattener (`file.exportPdf {flatten: high|medium|low|ppi}`, Edit ▸ Transparency Flattener Presets): each object involving transparency becomes an opaque image of its area over what's beneath it, so everything else stays vector (spreads with transparent parent items are rasterised whole).
- Video and sound (place .mp4/.mov/.webm/.mp3/.wav…, `media.options/get`, Media panel): media frames show a poster or placeholder on screen, in print and in PDF, and export as HTML5 `<video>`/`<audio>` in EPUB. Interactive PDF export (`file.exportPdf {media: true}`, File ▸ Export PDF (Interactive)) embeds each file and plays it in a Screen annotation through a rendition action (controls, loop, play on page load). No in-app playback.
-- Right-to-left text (World-Ready basics): right-to-left runs are shaped right to left, lines are reordered by the Unicode Bidirectional Algorithm (matched against the reference implementation), Paragraph Direction (`type.para {direction}`, Paragraph panel, IDML ParagraphDirection, EPUB `dir`). Digits (`digits`: Default, Arabic, Hindi, Farsi, Native by language; Character panel for right-to-left text; IDML DigitsType) draw 0–9 in another script. Kashidas (`kashidas` paragraph attribute, on by default): justified Arabic lines stretch at one join per word (after seen/sad when possible, never inside lam–alef) with a drawn tatweel before word spaces widen. Carets follow the drawing: the caret before a right-to-left glyph sits at its right edge, arrow keys move as drawn (by words in the line's direction), clicks find the nearest drawn caret position and selections highlight the selected glyphs. Binding: Right to Left (Document Setup, `layout.documentSetup {binding}`, IDML PageBinding) makes page 1 a left page and lays spreads out right to left.
-- Interface language (Edit ▸ Interface Language, `app.language`): German, French, Spanish, Japanese, Simplified Chinese and Arabic menu titles, common menu items and panel names (our own translations). Common dialog, panel and tooltip labels are also localized, with English fallback for untranslated strings. Arabic translations cover every key in the shared interface translation table, including menu commands and utility labels. The Type menu's Story Direction, Horizontal/Vertical, Tate-Chu-Yoko, Ruby… and Kenten are translated too. Arabic labels use Unicode bidi run ordering and contextual shaping; welcome and new-document form layouts follow RTL direction independently of document binding. CJK and Arabic glyphs come from [craft-fonts](https://github.com/storytold/craft-fonts) when built with `CRAFT_FONTS_DIR` (all releases): BIZ UDPGothic and Noto Sans CJK SC for the UI (Chinese forms first in the Chinese interface), Noto Sans Arabic, and Mincho for Japanese documents (the web build embeds BIZ UDPGothic only); otherwise from system fonts. Ukrainian covers all 1,430 existing catalog keys, including publishing dialogs and built-in names, with persisted selection, grammatical count captions, English fallback and bundled Cyrillic UI glyph coverage.
+- Right-to-left text (World-Ready basics): right-to-left runs are shaped right to left, lines are reordered by the Unicode Bidirectional Algorithm (matched against the reference implementation), Paragraph Direction (`type.para {direction}`, Paragraph panel, IDML ParagraphDirection, EPUB `dir`). Digits (`digits`: Default, Arabic, Hindi, Farsi, Native by language; Character panel for right-to-left text; IDML DigitsType) draw 0–9 in another script. Kashidas (`kashidas` paragraph attribute, on by default; IDML Kashidas): justified Arabic lines stretch at one join per word (after seen/sad when possible, never inside lam–alef) with a drawn tatweel before word spaces widen. Carets follow the drawing: the caret before a right-to-left glyph sits at its right edge, arrow keys move as drawn (by words in the line's direction), clicks find the nearest drawn caret position and selections highlight the selected glyphs. Binding: Right to Left (Document Setup, `layout.documentSetup {binding}`, IDML PageBinding) makes page 1 a left page and lays spreads out right to left.
- - Interface language (Edit ▸ Interface Language, `app.language`): German, French, Spanish, Italian, Japanese, Simplified Chinese and Arabic menu titles, common menu items and panel names (our own translations). Common dialog, panel and tooltip labels are also localized, with English fallback for untranslated strings. Arabic translations cover every key in the shared interface translation table, including menu commands and utility labels. The Type menu's Story Direction, Horizontal/Vertical, Tate-Chu-Yoko, Ruby… and Kenten are translated too. Arabic labels use Unicode bidi run ordering and contextual shaping; welcome and new-document form layouts follow RTL direction independently of document binding. CJK and Arabic glyphs come from [craft-fonts](https://github.com/storytold/craft-fonts) when built with `CRAFT_FONTS_DIR` (all releases): BIZ UDPGothic and Noto Sans CJK SC for the UI (Chinese forms first in the Chinese interface), Noto Sans Arabic, and Mincho for Japanese documents (the web build embeds BIZ UDPGothic only); otherwise from system fonts.
++- Interface language (Edit ▸ Interface Language, `app.language`): German, French, Spanish, Italian, Japanese, Simplified Chinese and Arabic menu titles, common menu items and panel names (our own translations). Common dialog, panel and tooltip labels are also localized, with English fallback for untranslated strings. Arabic translations cover every key in the shared interface translation table, including menu commands and utility labels. The Type menu's Story Direction, Horizontal/Vertical, Tate-Chu-Yoko, Ruby… and Kenten are translated too. Arabic labels use Unicode bidi run ordering and contextual shaping; welcome and new-document form layouts follow RTL direction independently of document binding. CJK and Arabic glyphs come from [craft-fonts](https://github.com/storytold/craft-fonts) when built with `CRAFT_FONTS_DIR` (all releases): BIZ UDPGothic and Noto Sans CJK SC for the UI (Chinese forms first in the Chinese interface), Noto Sans Arabic, and Mincho for Japanese documents (the web build embeds BIZ UDPGothic only); otherwise from system fonts. Ukrainian covers all 1,430 existing catalog keys, including publishing dialogs and built-in names, with persisted selection, grammatical count captions, English fallback and bundled Cyrillic UI glyph coverage.
- Page transitions (`page.transition/transitions`, Page Transitions panel): twelve transition types with speed and direction per spread, written into exported PDFs as `/Trans` entries through an incremental update.
-- PDF/X-4 export (`file.exportPdf {standard: "x4"}`): an output intent with our own Generic CMYK ICC profile (lut16 tables generated from the parametric press model), GTS_PDFXVersion in Info and XMP, and built-in PDF/X-4 checks reported as warnings. qpdf finds no errors in the result.
+- PDF/X-4 export (`file.exportPdf {standard: "x4"}`): an output intent with our own Generic CMYK ICC profile (lut16 tables generated from the parametric press model), GTS_PDFXVersion in Info and XMP, `pdf:Trapped` in XMP as in Info, RGB images without a profile tagged sRGB, no image interpolation (none in PDF/A either), and built-in PDF/X-4 checks reported as warnings. qpdf finds no errors in the result.
- EPS place: placed at its (high-resolution) bounding box and shown, printed and exported through its TIFF preview, or a placeholder when it has none. PostScript itself isn't interpreted.
- Preferences: Dictionary (user dictionary; `spelling.setWords/words`), Spelling (Dynamic Spelling: red squiggles on the canvas, also Edit ▸ Spelling), Autocorrect (word list, applied as you type), Notes, Track Changes, Story Editor Display and File Handling (recovery interval) sections.
- Colour management exposed: Edit ▸ Color Settings (`color.settings`: RGB/CMYK working spaces, intent, black-point compensation; `color.loadProfile` for ICC files; `color.convert` through the working spaces, with gamut checks) and View ▸ Proof Setup / Proof Colors (press, sRGB, legacy Mac RGB, colour-blindness simulations, simulate paper) on the canvas.
diff --cc crates/ui-egui/src/dialogs.rs
index e011da20b,d71b31c4d..7b0e0b17f
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@@ -1988,22 -1823,19 +1993,29 @@@ fn paragraph_style_options(app: &mut De
}
let kind = ns["until"]["kind"].as_str().unwrap_or("words").to_string();
egui::ComboBox::from_id_salt(("ns_until", i))
- .selected_text(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, &kind)))
+ .selected_text(crate::rtl::widget(
+ ui,
+ if app.ui.language == "uk" {
+ format!("{}:", crate::i18n::tr("uk", &kind))
+ } else {
+ crate::i18n::tr(&app.ui.language, &kind).to_owned()
+ },
+ ))
.width(100.0)
.show_ui(ui, |ui| {
- for k in
- ["sentences", "words", "characters", "letters", "digits", "tab", "forcedLineBreak", "emSpace", "enSpace", "chars"]
- {
+ for k in [
+ "sentences",
+ "words",
+ "characters",
+ "letters",
+ "digits",
+ "tab",
+ "forcedLineBreak",
+ "emSpace",
+ "enSpace",
+ "dropcap",
+ "chars",
+ ] {
if ui.selectable_label(k == kind, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, k))).clicked() {
ns["until"] = if k == "chars" { json!({"kind": "chars", "chars": ":"}) } else { json!({"kind": k}) };
changed = true;
diff --cc crates/ui-egui/src/i18n.rs
index 42b498f27,875046131..532a39893
--- a/crates/ui-egui/src/i18n.rs
+++ b/crates/ui-egui/src/i18n.rs
@@@ -4,8 -4,8 +4,9 @@@
use std::{collections::HashMap, sync::OnceLock};
mod ar;
+mod it;
mod pt_br;
+ mod uk;
/// Supported interface languages: (code, name in that language).
pub const LANGUAGES: &[(&str, &str)] = &[
@@@ -17,7 -17,7 +18,8 @@@
("zh", "简体中文"),
("ar", "العربية"),
("pt-br", "Português (Brasil)"),
+ ("it", "Italiano"),
+ ("uk", "Українська"),
];
/// English → [German, French, Spanish, Japanese, Simplified Chinese].
@@@ -2803,17 -2734,17 +2805,21 @@@ fn column(lang: &str) -> Option<usize>
pub fn tr<'a>(lang: &str, s: &'a str) -> &'a str {
static TRANSLATIONS: OnceLock<HashMap<&'static str, [&'static str; 5]>> = OnceLock::new();
static ARABIC: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
+ static UKRAINIAN: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
static PORTUGUESE_BR: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
+ static ITALIAN: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
if lang == "ar" {
return ARABIC.get_or_init(|| ar::TABLE.iter().copied().collect()).get(s).copied().unwrap_or(s);
}
if lang == "pt-br" {
return PORTUGUESE_BR.get_or_init(|| pt_br::TABLE.iter().copied().collect()).get(s).copied().unwrap_or(s);
}
+ if lang == "it" {
+ return ITALIAN.get_or_init(|| it::TABLE.iter().copied().collect()).get(s).copied().unwrap_or(s);
+ }
+ if lang == "uk" {
+ return UKRAINIAN.get_or_init(|| uk::TABLE.iter().copied().collect()).get(s).copied().unwrap_or(s);
+ }
let Some(c) = column(lang) else { return s };
TRANSLATIONS.get_or_init(|| TABLE.iter().copied().collect()).get(s).and_then(|row| row.get(c)).copied().unwrap_or(s)
}
@@@ -2852,11 -2802,11 +2877,14 @@@ mod tests
for (key, expected) in pt_br::TABLE {
assert_eq!(tr("pt-br", key), *expected, "pt-br: {key}");
}
+ for (key, expected) in it::TABLE {
+ assert_eq!(tr("it", key), *expected, "it: {key}");
+ }
+ for (key, expected) in uk::TABLE {
+ assert_eq!(tr("uk", key), *expected, "uk: {key}");
+ }
let unknown = String::from("A user-defined untranslated label");
- for lang in ["ar", "pt-br", "it", "zh", "ja", "de", "fr", "es", "", "unknown"] {
- for lang in ["uk", "ar", "pt-br", "zh", "ja", "de", "fr", "es", "", "unknown"] {
++ for lang in ["uk", "ar", "pt-br", "it", "zh", "ja", "de", "fr", "es", "", "unknown"] {
assert!(std::ptr::eq(tr(lang, &unknown), unknown.as_str()));
}
}
diff --cc crates/ui-egui/src/menus.rs
index f40d20044,93805ad9c..ef4465209
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@@ -38,7 -38,7 +38,7 @@@ pub const UI_COMMANDS: &[(&str, &str, O
"app.language",
"Interface Language",
None,
- "{lang: \"\"|de|fr|es|ja|zh|ar|pt-br|it} — menus and panel names (the macOS menu bar follows on the next launch)",
- "{lang: \"\"|de|fr|es|ja|zh|ar|pt-br|uk} — menus and panel names (the macOS menu bar follows on the next launch)",
++ "{lang: \"\"|de|fr|es|ja|zh|ar|pt-br|it|uk} — menus and panel names (the macOS menu bar follows on the next launch)",
),
(
"app.flattener",
@@@ -247,7 -234,7 +247,8 @@@ pub const MENUS: &[(&str, &[&str])] = &
"ui:app.language|简体中文|{\"lang\": \"zh\"}",
"ui:app.language|العربية|{\"lang\": \"ar\"}",
"ui:app.language|Português (Brasil)|{\"lang\": \"pt-br\"}",
+ "ui:app.language|Italiano|{\"lang\": \"it\"}",
+ "ui:app.language|Українська|{\"lang\": \"uk\"}",
"<",
">Transparency Flattener Presets",
"ui:app.flattener|None (keep transparency)|{\"preset\": \"\"}",
@@@ -2294,19 -2140,32 +2295,43 @@@ mod tests
assert_ne!(crate::i18n::tr("pt-br", title), title, "{title}");
}
}
+
+ run_ui(&mut app, "app.language", &json!({"lang": "it"})).unwrap().unwrap();
+ assert_eq!(app.ui.language, "it");
+ assert_eq!(checked(&app, "app.language", &json!({"lang": "it"})), Some(true));
+ for (title, _) in menu_tree() {
+ // "File" and "Layout" are the usual Italian menu names, so they stay identical
+ // to English; every other title must be translated.
+ if title != "File" && title != "Layout" {
+ assert_ne!(crate::i18n::tr("it", title), title, "{title}");
+ }
+ }
}
+ #[test]
+ fn ukrainian_language_is_selectable_persisted_and_keeps_document_data() {
+ let mut app = crate::DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({"pages": 4, "facingPages": true})).unwrap();
+ app.run("frame.create", json!({"rect": [36, 36, 200, 200], "content": "text", "text": "My words · Мої слова"})).unwrap();
+ let before = serde_json::to_value(&app.session.doc().unwrap().doc).unwrap();
+ run_ui(&mut app, "app.language", &json!({"lang": "uk"})).unwrap().unwrap();
+ assert_eq!(checked(&app, "app.language", &json!({"lang": "uk"})), Some(true));
+ assert_eq!(before, serde_json::to_value(&app.session.doc().unwrap().doc).unwrap());
+ for (title, _) in menu_tree() {
+ assert_ne!(crate::i18n::tr("uk", title), title, "{title}");
+ }
+ let bytes = serde_json::to_vec(&app.ui).unwrap();
+ let restored: crate::UiState = serde_json::from_slice(&bytes).unwrap();
+ assert_eq!(restored.language, "uk");
+ assert_eq!(crate::i18n::tr(&restored.language, "File"), "Файл");
+ assert_eq!(crate::i18n::tr(&restored.language, "A custom name"), "A custom name");
+ assert!(menu_tree().iter().flat_map(|(_, entries)| entries.iter()).any(|entry| {
+ matches!(entry, Item::Sub(label, children) if label == "Interface Language" && children.iter().any(|child| {
+ matches!(child, Item::Cmd { label, id, params, .. } if label == "Українська" && id == "app.language" && params["lang"] == "uk")
+ }))
+ }));
+ }
+
#[test]
fn arabic_dialog_and_language_switch_keep_finite_widget_geometry() {
let mut app = crate::DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
@@@ -2334,7 -2193,7 +2359,7 @@@
crate::dialogs::confirm(&mut app).unwrap();
frame(&mut app);
assert_eq!(app.session.documents().len(), 1);
- for lang in ["zh", "", "ar", "pt-br", "it"] {
- for lang in ["uk", "zh", "", "ar", "pt-br"] {
++ for lang in ["uk", "zh", "", "ar", "pt-br", "it"] {
app.run("app.language", json!({"lang": lang})).unwrap();
frame(&mut app);
}