mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-31 05:36:46 -06:00
i18n: add Polish interface language
Adds a Polish catalog (i18n/pl.rs, 1,698 strings), registers Polski in Edit › Interface Language, uses category-first count captions for Polish (as for Ukrainian) and adds catalog and language-switch tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DukHNvUY45rjRnvtz91x33
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e862e0a613
commit
226991cb28
+1
-1
@@ -99,7 +99,7 @@ Interface strings translated, of 1,724 measured. Detail: [docs/localization-pari
|
||||
| Korean | ko | none | 0% |
|
||||
| Vietnamese | vi | none | 0% |
|
||||
|
||||
Also shipped: Italian (85%), Ukrainian (83%).
|
||||
Also shipped: Italian (85%), Ukrainian (83%), Polish (99%).
|
||||
|
||||
## Upcoming
|
||||
|
||||
|
||||
@@ -634,7 +634,7 @@ pub fn status_bar(app: &mut DesignApp, ui: &mut egui::Ui) {
|
||||
"{} ▾",
|
||||
crate::i18n::count_label(
|
||||
&app.ui.language,
|
||||
if errors == 1 && app.ui.language != "uk" { "error" } else { "errors" },
|
||||
if errors == 1 && !matches!(app.ui.language.as_str(), "uk" | "pl") { "error" } else { "errors" },
|
||||
errors
|
||||
)
|
||||
)
|
||||
|
||||
@@ -2352,15 +2352,15 @@ fn paragraph_style_options(app: &mut DesignApp, ui: &mut egui::Ui, d: &mut Dialo
|
||||
*changed = true;
|
||||
}
|
||||
};
|
||||
if app.ui.language != "uk" {
|
||||
if !matches!(app.ui.language.as_str(), "uk" | "pl") {
|
||||
count_value(ui, ns, &mut changed);
|
||||
}
|
||||
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,
|
||||
if app.ui.language == "uk" {
|
||||
format!("{}:", crate::i18n::tr("uk", &kind))
|
||||
if matches!(app.ui.language.as_str(), "uk" | "pl") {
|
||||
format!("{}:", crate::i18n::tr(&app.ui.language, &kind))
|
||||
} else {
|
||||
crate::i18n::tr(&app.ui.language, &kind).to_owned()
|
||||
},
|
||||
@@ -2376,7 +2376,7 @@ fn paragraph_style_options(app: &mut DesignApp, ui: &mut egui::Ui, d: &mut Dialo
|
||||
}
|
||||
}
|
||||
});
|
||||
if app.ui.language == "uk" {
|
||||
if matches!(app.ui.language.as_str(), "uk" | "pl") {
|
||||
count_value(ui, ns, &mut changed);
|
||||
}
|
||||
if kind == "chars" {
|
||||
@@ -2432,8 +2432,8 @@ fn paragraph_style_options(app: &mut DesignApp, ui: &mut egui::Ui, d: &mut Dialo
|
||||
});
|
||||
crate::rtl::label(
|
||||
ui,
|
||||
if app.ui.language == "uk" {
|
||||
format!("{}:", crate::i18n::tr("uk", "lines"))
|
||||
if matches!(app.ui.language.as_str(), "uk" | "pl") {
|
||||
format!("{}:", crate::i18n::tr(&app.ui.language, "lines"))
|
||||
} else {
|
||||
crate::i18n::tr(&app.ui.language, "for").to_owned()
|
||||
},
|
||||
@@ -2443,7 +2443,7 @@ fn paragraph_style_options(app: &mut DesignApp, ui: &mut egui::Ui, d: &mut Dialo
|
||||
l["lines"] = json!(n);
|
||||
changed = true;
|
||||
}
|
||||
if app.ui.language != "uk" {
|
||||
if !matches!(app.ui.language.as_str(), "uk" | "pl") {
|
||||
crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, if n == 1 { "line" } else { "lines" }));
|
||||
}
|
||||
if ui
|
||||
|
||||
@@ -6,6 +6,7 @@ use std::{collections::HashMap, sync::OnceLock};
|
||||
mod ar;
|
||||
mod it;
|
||||
mod ja;
|
||||
mod pl;
|
||||
mod pt_br;
|
||||
mod uk;
|
||||
|
||||
@@ -21,6 +22,7 @@ pub const LANGUAGES: &[(&str, &str)] = &[
|
||||
("pt-br", "Português (Brasil)"),
|
||||
("it", "Italiano"),
|
||||
("uk", "Українська"),
|
||||
("pl", "Polski"),
|
||||
];
|
||||
|
||||
/// English → [German, French, Spanish, Japanese, Simplified Chinese].
|
||||
@@ -2868,6 +2870,7 @@ pub fn tr<'a>(lang: &str, s: &'a str) -> &'a str {
|
||||
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();
|
||||
static POLISH: 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);
|
||||
}
|
||||
@@ -2884,6 +2887,9 @@ pub fn tr<'a>(lang: &str, s: &'a str) -> &'a str {
|
||||
if lang == "it" {
|
||||
return ITALIAN.get_or_init(|| it::TABLE.iter().copied().collect()).get(s).copied().unwrap_or(s);
|
||||
}
|
||||
if lang == "pl" {
|
||||
return POLISH.get_or_init(|| pl::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);
|
||||
}
|
||||
@@ -2904,10 +2910,10 @@ pub(crate) fn ukrainian_catalog() -> Vec<&'static str> {
|
||||
uk::TABLE.iter().map(|(_, text)| *text).chain(uk::CONTEXT.iter().map(|(_, _, text)| *text)).collect()
|
||||
}
|
||||
|
||||
/// Count captions in Ukrainian put the category before the value so every count uses
|
||||
/// Count captions in Ukrainian and Polish put the category before the value so every count uses
|
||||
/// a grammatical form; other languages keep the existing value-first caption.
|
||||
pub fn count_label(lang: &str, noun: &str, count: usize) -> String {
|
||||
if lang == "uk" { format!("{}: {count}", tr(lang, noun)) } else { format!("{count} {}", tr(lang, noun)) }
|
||||
if matches!(lang, "uk" | "pl") { format!("{}: {count}", tr(lang, noun)) } else { format!("{count} {}", tr(lang, noun)) }
|
||||
}
|
||||
|
||||
/// Localize reserved built-in style names only; user-defined names are document data.
|
||||
@@ -2953,8 +2959,11 @@ mod tests {
|
||||
for (key, expected) in uk::TABLE {
|
||||
assert_eq!(tr("uk", key), *expected, "uk: {key}");
|
||||
}
|
||||
for (key, expected) in pl::TABLE {
|
||||
assert_eq!(tr("pl", key), *expected, "pl: {key}");
|
||||
}
|
||||
let unknown = String::from("A user-defined untranslated label");
|
||||
for lang in ["uk", "ar", "pt-br", "it", "zh", "ja", "de", "fr", "es", "", "unknown"] {
|
||||
for lang in ["pl", "uk", "ar", "pt-br", "it", "zh", "ja", "de", "fr", "es", "", "unknown"] {
|
||||
assert!(std::ptr::eq(tr(lang, &unknown), unknown.as_str()));
|
||||
}
|
||||
}
|
||||
@@ -3051,6 +3060,49 @@ mod tests {
|
||||
assert_eq!(count_label("", "objects", 2), "2 objects");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn polish_catalog_covers_existing_keys_and_preserves_placeholders() {
|
||||
let catalog: HashMap<_, _> = pl::TABLE.iter().copied().collect();
|
||||
assert_eq!(catalog.len(), pl::TABLE.len(), "duplicate Polish keys");
|
||||
let mut keys = std::collections::HashSet::new();
|
||||
keys.extend(TABLE.iter().map(|(key, _)| *key));
|
||||
for table in [ar::TABLE, pt_br::TABLE, ja::TABLE, it::TABLE, uk::TABLE] {
|
||||
keys.extend(table.iter().map(|(key, _)| *key));
|
||||
}
|
||||
// A new English string falls back to English until it is translated; only stale entries fail.
|
||||
let stale: Vec<_> = catalog.keys().filter(|k| !keys.contains(*k)).collect();
|
||||
assert!(stale.is_empty(), "Polish entries for unknown keys: {stale:?}");
|
||||
let placeholders =
|
||||
|s: &str| s.split('{').skip(1).filter_map(|part| part.split_once('}').map(|(name, _)| name.to_owned())).collect::<Vec<_>>();
|
||||
for (key, translation) in pl::TABLE {
|
||||
assert!(!translation.trim().is_empty(), "empty {key}");
|
||||
let mut source = placeholders(key);
|
||||
let mut translated = placeholders(translation);
|
||||
source.sort();
|
||||
translated.sort();
|
||||
assert_eq!(source, translated, "placeholders: {key}");
|
||||
assert_eq!(key.ends_with('…'), translation.ends_with('…'), "ellipsis: {key}");
|
||||
}
|
||||
assert!(LANGUAGES.contains(&("pl", "Polski")));
|
||||
assert!(!is_rtl("pl"));
|
||||
assert_eq!(tr("pl", "File"), "Plik");
|
||||
assert_eq!(tr("pl", "New Document…"), "Nowy dokument…");
|
||||
assert_eq!(tr("pl", "Spread"), "Rozkładówka");
|
||||
assert_eq!(tr("pl", "Unknown label"), "Unknown label");
|
||||
assert_eq!(style_name("pl", "[Basic Paragraph]"), "[Podstawowy akapit]");
|
||||
assert_eq!(workspace_name("pl", "Essentials"), "Podstawowe");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn polish_counts_use_category_captions_for_every_number() {
|
||||
for n in [0, 1, 2, 5, 12, 22, 25] {
|
||||
assert_eq!(count_label("pl", "pages", n), format!("Strony: {n}"));
|
||||
assert_eq!(count_label("pl", "objects", n), format!("Obiekty: {n}"));
|
||||
assert_eq!(count_label("pl", "errors", n), format!("Błędy: {n}"));
|
||||
}
|
||||
assert_eq!(tr("pl", "{pages} Pages in {spreads} Spreads"), "Strony: {pages}, rozkładówki: {spreads}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn japanese_vertical_type_commands_are_translated() {
|
||||
for (en, ja) in [
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -280,6 +280,7 @@ pub const MENUS: &[(&str, &[&str])] = &[
|
||||
"ui:app.language|Português (Brasil)|{\"lang\": \"pt-br\"}",
|
||||
"ui:app.language|Italiano|{\"lang\": \"it\"}",
|
||||
"ui:app.language|Українська|{\"lang\": \"uk\"}",
|
||||
"ui:app.language|Polski|{\"lang\": \"pl\"}",
|
||||
"<",
|
||||
">Transparency Flattener Presets",
|
||||
"ui:app.flattener|None (keep transparency)|{\"preset\": \"\"}",
|
||||
@@ -2816,6 +2817,30 @@ mod tests {
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn polish_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": 2, "facingPages": true})).unwrap();
|
||||
app.run("frame.create", json!({"rect": [36, 36, 200, 200], "content": "text", "text": "Zażółć gęślą jaźń"})).unwrap();
|
||||
let before = serde_json::to_value(&app.session.doc().unwrap().doc).unwrap();
|
||||
run_ui(&mut app, "app.language", &json!({"lang": "pl"})).unwrap().unwrap();
|
||||
assert_eq!(app.ui.language, "pl");
|
||||
assert_eq!(checked(&app, "app.language", &json!({"lang": "pl"})), 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("pl", 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, "pl");
|
||||
assert_eq!(crate::i18n::tr(&restored.language, "File"), "Plik");
|
||||
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 == "Polski" && id == "app.language" && params["lang"] == "pl")
|
||||
}))
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn arabic_dialog_and_language_switch_keep_finite_widget_geometry() {
|
||||
let mut app = crate::DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
|
||||
@@ -2843,7 +2868,7 @@ mod tests {
|
||||
crate::dialogs::confirm(&mut app).unwrap();
|
||||
frame(&mut app);
|
||||
assert_eq!(app.session.documents().len(), 1);
|
||||
for lang in ["uk", "zh", "", "ar", "pt-br", "it"] {
|
||||
for lang in ["uk", "zh", "", "ar", "pt-br", "it", "pl"] {
|
||||
app.run("app.language", json!({"lang": lang})).unwrap();
|
||||
frame(&mut app);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Localization parity
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-10 · **Change:** major (first version; catalogs measured) · **Target:** Adobe InDesign 2026 (21.6)
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (Polish interface) · **Target:** Adobe InDesign 2026 (21.6)
|
||||
|
||||
Per-language status of the DesignCraft interface and of document typesetting in each script.
|
||||
Script-specific typesetting detail: [cjk.md](cjk.md), [cjk-typography.md](cjk-typography.md),
|
||||
@@ -49,8 +49,9 @@ string is translated and its script renders and edits correctly; none but Englis
|
||||
|---|---|---|---|
|
||||
| Italian | it | 1,464 (85%) | partial |
|
||||
| Ukrainian | uk | 1,432 (83%), plural categories handled | partial |
|
||||
| Polish | pl | 1,717 (99%), count captions category-first; AI-drafted, awaiting native review | partial |
|
||||
|
||||
DesignCraft ships **2** interface languages beyond the twelve; InDesign ships 17 beyond its
|
||||
DesignCraft ships **3** interface languages beyond the twelve; InDesign ships 17 beyond its
|
||||
eight of the twelve (cs, da, el, en_GB, fi, hu, it, nb, nl, pl, ro, ru, sq, sv, tr, uk, zh_TW).
|
||||
|
||||
## Document languages
|
||||
@@ -78,3 +79,4 @@ locale shaping. See [typography-parity.md](typography-parity.md).
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-10 | major | Created: catalogs measured (1,724 strings), the twelve key languages plus Italian and Ukrainian |
|
||||
| 2026-10-13 | minor | Polish interface added (1,717 strings) |
|
||||
|
||||
@@ -366,7 +366,7 @@ It is evidence of breadth: each item exists. It is not a claim of InDesign-level
|
||||
- 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, 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.
|
||||
- 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. Polish covers 1,717 catalog keys with the same category-first count captions and English fallback.
|
||||
- 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, `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.
|
||||
|
||||
Reference in New Issue
Block a user