From 7efebfec0844875bf75fef2fb2ef25296771ae2f Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Tue, 3 Nov 2026 12:54:01 +0000 Subject: [PATCH] =?UTF-8?q?CP4.3:=20Options=20=E2=80=BA=20Language:=20Your?= =?UTF-8?q?=20languages=20with=20proofing=20status,=20Add=20a=20language?= =?UTF-8?q?=E2=80=A6=20picker,=20Set=20as=20default;=20dictionaries=20fold?= =?UTF-8?q?er=20moves=20from=20Proofing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01FypgCYmv6UJmY2QcuhfXco --- GLOSSARY.md | 41 ++ ROADMAP.md | 4 +- crates/engine/src/cmd/packs.rs | 116 ++++- crates/engine/src/packs.rs | 163 +++++++ crates/ui-egui/examples/ui_shot.rs | 11 +- crates/ui-egui/src/language_packs.rs | 609 ++++++++++++++++++++++---- crates/ui-egui/src/options.rs | 80 +--- crates/ui-egui/src/options/tests.rs | 8 +- crates/ui-egui/src/ribbon.rs | 7 +- crates/ui-egui/src/ribbon/language.rs | 2 +- docs/gaps.md | 3 +- docs/localization-parity.md | 17 +- docs/mcp.md | 2 +- docs/spelling-dictionaries.md | 21 +- docs/ui-parity.md | 3 +- 15 files changed, 893 insertions(+), 194 deletions(-) create mode 100644 GLOSSARY.md diff --git a/GLOSSARY.md b/GLOSSARY.md new file mode 100644 index 0000000000..2a61199a42 --- /dev/null +++ b/GLOSSARY.md @@ -0,0 +1,41 @@ +# WordCraft + +A clean-room, Rust-native word processor. These are the words its interface, docs and code use for +the same things. + +## Languages and proofing + +**Interface language**: +The language of WordCraft's own menus, buttons and messages. +_Avoid_: Display language, UI locale + +**Proofing language**: +The language a piece of text is marked as, which decides how its spelling, grammar and hyphenation +are checked. +_Avoid_: Text language, editing language, document language + +**Language pack**: +A downloadable bundle of a language's spelling dictionary and hyphenation patterns. +_Avoid_: Dictionary download, language data (that is the embedded data) + +**Your languages**: +The proofing languages Options › Language lists: each English variant in use (the default proofing +language and any in the open document), every language with an installed +Language pack, and every proofing language used in the open document. +_Avoid_: Authoring languages, preferred languages + +**Default proofing language**: +The proofing language new text gets, set with Set As Default; without one, the interface language. +_Avoid_: Preferred language + +**Proofing status**: +Where a language's proofing comes from: built in, an installed Language pack, your own dictionary, +available to install, or not available. + +**Custom dictionary**: +The words you added with Add to Dictionary, accepted in every language. +_Avoid_: User dictionary (in the interface) + +**Your own dictionaries folder**: +A folder of Hunspell dictionaries you supply, used before Language packs and the system's. +_Avoid_: Dictionaries folder, custom dictionaries diff --git a/ROADMAP.md b/ROADMAP.md index e0b12d9898..45cee00848 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -4,7 +4,7 @@ **Stage: alpha** · next: beta, ~15 points (60% → 75% ready for real work) and ~150–230 h away -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** trivial (progress log: Language pack languages in every language list, CP4.3); previously trivial (progress log: Replace and Remove Table of Contents with Word's title above a section break, #4041); previously trivial (progress log: a password-protected file named on the command line asks for its password after the startup document is replaced, #5299); previously trivial (progress log: language-packs-2 published and pinned, 75 Language packs); previously trivial (progress log: language-packs-1 published and pinned, CP4.4); previously trivial (progress log: Language packs, CP4);; previously trivial (DOCX table rows and cells inside selected alternate-content branches survive open and repeated saves (#5219); broader corpus qualification and readiness estimates unchanged); previously trivial (progress log: a list inside a Markdown block quote stays quoted); previously trivial (progress log: arrowheads keep their kind, width and length and are drawn at Word's sizes); previously trivial (progress log: the line between columns for selected text, #5178); previously trivial (progress log: .doc standard font, #5066); previously trivial (progress log: a table row doesn't split off a picture that doesn't fit, #4272); previously trivial (progress log: a middle or bottom cell of a row split across pages lines up on the first page); previously trivial (progress log: tab leader dots spaced and placed as in Word); previously trivial (progress log: a list level above counts its first number at the first deeper item); previously trivial (progress log: paragraph side borders lie outside the text, #5036); previously trivial (progress log: a paragraph naming an undefined style is formatted as Normal, #5077); previously trivial (progress log: TOC page numbers as PAGEREF fields, #5097); previously trivial (progress log: Backstage keytips, #4960); previously trivial (Progress log: only the printer's PDF leaves out links; Save these pages as PDF keeps them, #4734); previously trivial (progress log: Chinese and Japanese text counts a word per character, #4547; previously trivial: aligned-copy review fixes retain the document axis through scrolling and include secondary selections (#4764)); previously trivial (connector rerouting indexes laid-out object positions once per batch (#3631); previously trivial (progress log: corporate authors in bibliographies, #4848); previously trivial (custom-property bookmark-link preservation, #4767); previously trivial (progress log: Table Properties follows the selection, #4857); previously trivial (Relative font-size commands preserve mixed sizes in the selection (#4903); existing button steps and one-point shortcuts are unchanged; readiness estimates unchanged); previously trivial (Arabic Backspace removes one combining mark and keeps its base letter (#4757); previously trivial (note conversion walks reference offsets and formatting runs together, #4750); previously trivial (DOCX comment-ID save lookups); previously trivial (progress log: RTF pictures stored as Windows or Enhanced Metafiles are imported, #4259); previously trivial (#4658 bounds nested Markdown reference-label work); previously trivial (HTML import keeps preformatted lines with CR or CRLF input newlines, #4810); previously trivial (progress log: Insert › Shapes icon grid, #4349); previously trivial (progress log: AutoCorrect Options with no document open, #4585); previously trivial (progress log: window fallback geometry and equation symbol tooltips); previously trivial (progress log: window titles omit NUL characters, #3634); previously trivial (Recipient labels continue across product-sized sheets instead of stopping after the first sheet (#4880)); previously trivial (progress log: Custom document properties dialog, #2982; previously trivial: progress log: View › New Window; previously trivial: progress log: interface translations come from storytold/craft-i18n through the `craft-i18n` crate; previously trivial: progress log: disabled-control reasons translated in every interface language, #2678; previously trivial: progress log: mail merge record navigation and record ranges for printing, #3028; previously trivial: selection bar for right-to-left paragraphs and table rows; previously trivial: group connector rerouting preserves rotated and flipped free or unresolved endpoints under nonuniform group scaling; readiness estimates unchanged; previously trivial: progress log: a word with no break opportunity in it no longer makes the layout quadratic, #3412; previously trivial: progress log: a relationship the markup names without the prefix is read as it wrote, and an ordinary `id` names no part; previously trivial: progress log: a document with many relationships opens in the time its part takes, and an id the text only mentions is not a reference, #3411; previously trivial: progress log: read only and comments-only protection grey out edits; previously trivial: progress log: an empty paragraph with a hidden mark shows nothing, not even its list number, #3982; previously trivial: progress log: "NaN" in the Font dialog's Size box no longer closes the app, #3663; previously trivial: progress log: a table cell span from a `.json` file no longer overflows, #3637; previously trivial: progress log: a click in the footer while editing the header moves there; previously trivial: explicit documents keep the editor when recovery discovery finishes; readable recovery controls; previously trivial: Slovenian interface catalog, 2,614 entries; previously trivial: Insert Table of Figures dialog for any caption label, #3013; previously trivial: progress log: Home › Underline drop-down, #2738; previously trivial: personal templates in File › New and Save as Word Template, #2852; previously trivial: progress log: the scrollbar page tip stays on one line, #3341; previously trivial: progress log: forms protection greys out the control buttons; previously trivial: progress log: a document with many content controls saves in the time the controls take, #13; previously trivial: progress log: Word signature lines kept on save; previously trivial: a Thai run with Latin finds one installed font covering it all on Linux too, #1549; previously trivial: progress log: closing the header returns to the body selection, #3331; previously trivial: progress log: saving to a NAS share mounted by GVFS, #3003; previously trivial: progress log: a picture dragged near the bottom of a page lands there, #3169; previously trivial: centred list labels after leading page breaks, #2964; previously trivial: progress log: inline pictures drag to an insertion cursor and stay inline, #2233, #2234; previously trivial: progress log: a text file saved over itself closes without asking, #2376; previously trivial: progress log: a text frame in the paragraph defaults frames nothing, #2360; previously trivial: fixed font inputs in four layout controls; previously trivial: typing no longer starts render threads on every repaint, #3027; previously trivial: a right, centre or decimal tab whose text doesn't fit, or a left tab past the right indent, goes to the next line with its text, #1840; previously trivial: progress log: banded rows shade as in Word, #3415; previously trivial: progress log: the table handles show while the caret is in the table, #2428; previously trivial: progress log: a click below a floating table reaches the text after it, #2038; previously trivial: progress log: Delete on selected table cells leaves one empty paragraph in each, #2802; previously trivial: progress log: lam-alef in exported PDFs extracts whole with fonts that draw it as two glyphs, #2310; previously trivial: Bullets and Numbering toggle off style-inherited lists at their effective level, including basedOn chains and numbered ListParagraph styles; other paragraphs and list definitions stay unchanged (related to #3459); previously trivial: Russian sorting keeps ё with е and recognises decomposed ё/й; previously trivial: progress log: a text box that keeps the keyboard no longer resets the input method every frame, #2986; previously trivial: progress log: recovery copies and .json files store pictures as base64, #586 follow-up; previously trivial: progress log: legacy menu keys, #1697; previously trivial: progress log: shape gradients and transparency, #1500; previously trivial: progress log: Focus fills the screen, and Full Screen View shows the pages alone, #1678; previously trivial: progress log: text above a float's anchor wraps around it, #2048; previously trivial: progress log: File › Recover follows the app theme, #3243; previously trivial: progress log: formatting toolbar with the text context menu, #2959; previously trivial: progress log: caret inside ligatures, #1974; previously trivial: text typed into a content control takes the control's formatting; localized placeholder styles recognised; previously trivial: forms protection keeps its content controls: no inserting, Properties or Remove Content Control; previously trivial: long navigation headings wrap onto further lines within the pane, #3015; previously trivial: clearing a no-match font query keeps the recent heading visible, #2068; previously trivial: a word after a slash wraps whole, like Word, #2963; previously trivial: progress log: a header-cell picture watermark sits behind the text, #1775; previously trivial: symbols keep their font when the text font changes, #2036; previously trivial: opening a DOCX no longer copies its pictures; previously trivial: Add Font imports every selected font file, #1789); previously trivial (RTF export writes sections (gap 19); previously trivial: ODT export writes sections (gap 19); previously trivial: Read Aloud speaks each sentence in its own language, #1843; previously trivial: hint-reliant CJK outlines; previously trivial: Ctrl+wheel zoom no longer scrolls the document, #1743; previously trivial: progress log: Turkish case mapping in AutoCorrect, #1923; previously trivial: a mouse drag on a table leaves the view where it is, #1738; previously trivial: progress log: Hebrew field results and smart quotes, #1670; previously trivial: Backspace removes a selected table, rows or columns, #1844; previously trivial: progress log: mixed Hebrew/Latin text keeps its order in Word, #1543; previously trivial: progress log: web typing in non-Latin text no longer repeats, #1480; previously trivial: progress log: font family caches bounded and math font lookups follow font changes, #1354; previously trivial: `-->` AutoCorrect replacement, #2223; previously trivial: numbered headings, #1793; previously trivial: Navigation Find exposes Results, #2096; previously trivial: progress log: Columns on selected text, #2024; previously trivial: progress log: legacy outline, shadow, emboss and imprint text effects drawn, #2534; previously trivial: progress log: Indonesian proofing, #498; previously trivial: progress log: DOCX glossary documents (building blocks); previously trivial: progress log: Read Mode keeps the keyboard and shows whole, unobscured columns, #1772); previously trivial: progress log: font list entries of tall-ascent fonts no longer cut off, #2570); previously trivial: progress log: Split Cells and Convert Text to Table dialogs follow the Word check, #2592; previously trivial: a new source's Tag is made like Word's, three letters of the author and two digits of the year with a number added when taken, and an edit keeps the Tag, #2094; previously trivial: Web Layout fills the window width, #1876; previously trivial: progress log: Different First Page headers reachable from page 1, #2826; previously trivial: Language dialog keeps inherited proofing language and no-proof choices (#2717); previously trivial: progress log: web preferences kept between visits, #2132; previously trivial: progress log: undrawable private-use list bullets show the level's default bullet, #1683; previously trivial: progress log: `w:eastAsianLayout` kept on save; previously trivial: table style editor formats every part, #714); previously trivial: VML freeforms read and kept on save; previously trivial: progress log: consistent preferred cell widths; previously trivial: multi-paragraph field instructions no longer add blank lines; previously trivial: page-break-only list paragraphs hide their labels; previously trivial: progress log: grouped `flowChartOr` shapes draw their circle and crossing spokes; previously trivial: progress log: copies keep their formatting in other programs, #1523; previously trivial: progress log: privacy options on save, #1062; previously trivial: progress log: equation pictures in theme colours on Windows, #1002; previously trivial: symbol fonts, #776; previously trivial: the save prompt answers from the keyboard, #861; previously trivial: table column and row markers on the rulers, #700; previously trivial: table borders and the resize handle drag on the page, #217; previously trivial: formatting revisions landed, #41; previously trivial: Draw tab ink, #307, and Draw Table and Eraser, #303, landed: catalog 402/434; previously minor: readiness table with hours per audience; full number back to the additive weighted sum, 60%; mainstream and essentials numbers added; alpha gate checked; previously major: full re-measure against Word for Mac 16.113.4; progress docs restructured) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-29 · **Change:** trivial (Recipient labels continue across product-sized sheets instead of stopping after the first sheet (#4880)); previously trivial (English dialects in proofing, #1281; previously trivial: triple borders draw three lines, #1740; previously trivial: progress log: double-clicking a later page's footer no longer scrolls up, #2103; previously trivial: long navigation headings wrap onto further lines within the pane, #3015; previously trivial: clearing a no-match font query keeps the recent heading visible, #2068; previously trivial: a word after a slash wraps whole, like Word, #2963; previously trivial: RTF export writes sections (gap 19); previously trivial: ODT export writes sections (gap 19); previously trivial: progress log: pasted blockquotes are indented paragraphs, #1270; previously trivial: progress log: print-area strings translated in every catalog; previously trivial: progress log: comments readable in the dark theme, #2045; previously trivial: progress log: ODT sections, #1379; previously trivial: progress log: table deletes, Change Case and Unlink Fields respect Track Changes and locked content controls, #1329; previously trivial: progress log: rounded rectangle corners, #1476; previously trivial: progress log: Save As type list, #1399; previously trivial: progress log: privacy options on save, #1062; previously trivial: progress log: equation pictures in theme colours on Windows, #1002; previously trivial: symbol fonts, #776; previously trivial: the save prompt answers from the keyboard, #861; previously trivial: table column and row markers on the rulers, #700; previously trivial: table borders and the resize handle drag on the page, #217; previously trivial: formatting revisions landed, #41; previously trivial: Draw tab ink, #307, and Draw Table and Eraser, #303, landed: catalog 402/434; previously minor: readiness table with hours per audience; full number back to the additive weighted sum, 60%; mainstream and essentials numbers added; alpha gate checked; previously major: full re-measure against Word for Mac 16.113.4; progress docs restructured) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** trivial (progress log: Options › Language and Proofing redesign, CP4.3); previously trivial (progress log: Language pack languages in every language list, CP4.3) > **Printing update:** 2026-10-12 · direct desktop printing through craft-print; details below. WordCraft aims for complete parity with Microsoft Word, then goes further on speed, openness and @@ -142,6 +142,7 @@ Ranked, to beta (detail and remaining milestones in [docs/roadmap.md](docs/roadm - 2026-11-03: Security: pasting text boxes charges each copied story for its formatting too (run, mark, paragraph and section properties), not only its text and objects, so a story with huge style or font names can't copy past the paste's 32 MiB text box budget. Readiness unchanged. - 2026-11-03: Security: `.doc` import keeps one width, shading, alignment and merge override per table cell, the last one winning as before, instead of a copy every time a paragraph's properties repeat the sprm, so a shared PAPX can't pile up copies on every paragraph mark. Readiness unchanged. - 2026-11-03: Security: `.doc` import attaches each section to the paragraph that ends it through an index of paragraph ends, instead of scanning every paragraph for every section, so a file with a thousand sections that end nowhere can't multiply the work over its paragraphs. Readiness unchanged. +- 2026-11-03: Options › Language (CP4.3): **Your languages** lists English, every installed Language pack and the languages of the open document, each with where its proofing comes from (Built in, Installed, Your own dictionary, Install, Grammar built in, Not available yet) and Install, Remove and Set as default; **Add a language…** opens a picker with search (dutch, nederlands, nl), sorted by name, and its first click is the consent to download. The folder of your own dictionaries moved here from Options › Proofing. Gap 8. - 2026-11-03: Language lists (CP4.3): a language installed from a Language pack (Bulgarian, say) can now be chosen. Set Proofing Language lists every built-in language and every installed or available pack's, each once and sorted by name; Review › Language and the status bar's menu add the installed packs' languages to the short list, with one way of working out the check mark. A pack's language is stored as a tag that finds the pack again (`sr-Latn-RS` is proofed by the Latin `sr-latn` pack, not the Cyrillic one). Every pack in language-packs-2 has an English name (Belarusian showed as Беларуская). Readiness unchanged. - 2026-11-03: Language packs: language-packs-2 is published and WordCraft pins its index: 75 languages, adding Danish, German (Germany, Austria, Switzerland), Esperanto, Estonian, Persian, Croatian, Hungarian, Norwegian (Bokmål, Nynorsk), Dutch (#4145, #2505) and Swedish (Sweden, Finland), which need craft-proof's flag-based compounding (storytold/craft-libs#497, pinned). English (Australia) is checked against SCOWL's en-AU list as well as en-GB's (storytold/craft-libs#496). Mongolian and Thai stay hidden. Readiness unchanged. - 2026-11-02: Language packs (CP4.4): craft-i18n's first pack release, language-packs-1, is published and WordCraft pins its index (sha256): 61 languages install from File › Options › Language, among them Lithuanian (#4707), Romanian (#3438), Catalan (#2895, #4947), French (#1325), Greek (#2561), Slovak (#3806), Serbian (#4968) and Latvian (#4438). Dutch (#4145, #2505), German and the other compounding languages wait on craft-proof engine support. Readiness unchanged. @@ -706,6 +707,7 @@ Footer page-table height and body wrapping are corrected. Other pagination gaps | Date | Change | Summary | |---|---|---| +| 2026-11-03 | trivial | Progress log: Options › Language and Proofing redesign (CP4.3) | | 2026-11-03 | trivial | Progress log: Language pack languages in every language list (CP4.3) | | 2026-11-03 | trivial | Progress log: Replace and Remove Table of Contents with Word's title above a section break (#4041) | | 2026-11-03 | trivial | Progress log: language-packs-2 published and pinned, 75 Language packs | diff --git a/crates/engine/src/cmd/packs.rs b/crates/engine/src/cmd/packs.rs index 62fbb6660f..3362edad57 100644 --- a/crates/engine/src/cmd/packs.rs +++ b/crates/engine/src/cmd/packs.rs @@ -33,7 +33,7 @@ fn locale_param(v: &Value) -> Result { packs::parse_locale(raw) } -fn list(_: &mut Session, v: &Value) -> CmdResult { +fn list(s: &mut Session, v: &Value) -> CmdResult { if p::bool(v, "refresh") == Some(true) { packs::start_refresh().map_err(CmdError::Failed)?; if let Some(e) = packs::error("") { @@ -55,6 +55,7 @@ fn list(_: &mut Session, v: &Value) -> CmdResult { .collect(); Ok(json!({ "packs": rows, + "languages": packs::your_languages(s), "installed": installed.iter().map(|i| json!({"locale": i.locale, "name": i.name, "licence": i.licence})).collect::>(), "installing": packs::installing(), "refreshing": packs::fetching(), @@ -162,6 +163,119 @@ mod tests { }); } + /// Options › Language › Your languages: fresh, with Dutch installed, a document with Thai, + /// Turkish without a pack, and en-GB as the default. + mod your_languages { + use super::*; + use crate::packs::Proofing; + + fn none(_: &str) -> Option { + None + } + + fn row<'a>(rows: &'a [packs::LanguageRow], tag: &str) -> &'a packs::LanguageRow { + rows.iter().find(|r| r.is_tag(tag) || r.pack.as_deref() == Some(tag)).unwrap_or_else(|| panic!("no row for {tag}: {rows:?}")) + } + + fn mark(s: &mut Session, para: usize, lang: &str) { + s.run("caret.set", &json!({"pos": {"block": para, "off": 0}})).unwrap(); + s.run("select.paragraph", &json!({})).unwrap(); + s.run("review.language", &json!({"lang": lang})).unwrap(); + } + + #[test] + fn a_fresh_install_lists_only_english() { + with_backend(FixedBackend::sample(), |s, _| { + let rows = packs::your_languages_with(s, None, &none); + assert_eq!(rows.len(), 1, "{rows:?}"); + assert_eq!(rows[0].proofing, Proofing::BuiltIn); + assert!(rows[0].default); + assert_eq!(rows[0].pack, None); + }); + } + + #[test] + fn an_installed_pack_is_a_row_with_remove() { + with_backend(FixedBackend::sample(), |s, b| { + b.network.store(true, Ordering::Relaxed); + s.run("proof.installPack", &json!({"locale": "nl"})).unwrap(); + let rows = packs::your_languages_with(s, None, &none); + assert_eq!(rows.len(), 2); + let nl = row(&rows, "nl"); + assert!(nl.installed && nl.tags.is_empty() && !nl.default); + assert_eq!(nl.proofing, Proofing::Installed); + let r = s.run("proof.packs", &json!({})).unwrap(); + assert_eq!(r["languages"].as_array().unwrap().len(), 2, "MCP sees the same rows"); + }); + } + + #[test] + fn document_languages_show_install_grammar_and_not_available() { + with_backend(FixedBackend::sample(), |s, b| { + s.run("document.setText", &json!({"text": "Hallo\nMerhaba\nสวัสดี\nCześć\nBonjour"})).unwrap(); + mark(s, 0, "nl-NL"); + mark(s, 1, "tr-TR"); + mark(s, 2, "th-TH"); + mark(s, 3, "pl-PL"); + mark(s, 4, "fr-FR"); + let rows = packs::your_languages_with(s, None, &none); + let nl = row(&rows, "nl-NL"); + assert_eq!((nl.proofing, nl.size, nl.installed), (Proofing::Install, 1_950_000, false)); + // Turkish has grammar rules built in and no pack in the sample index. + assert_eq!(row(&rows, "tr-TR").proofing, Proofing::NotAvailable); + assert_eq!(row(&rows, "th-TH").proofing, Proofing::NotAvailable); + let pl = row(&rows, "pl-PL"); + assert_eq!((pl.proofing, pl.size), (Proofing::GrammarBuiltIn, 4_620_000)); + // Installing turns Install into Installed; the document keeps the row. + b.network.store(true, Ordering::Relaxed); + s.run("proof.installPack", &json!({"locale": "nl"})).unwrap(); + let rows = packs::your_languages_with(s, None, &none); + assert_eq!(row(&rows, "nl-NL").proofing, Proofing::Installed); + s.run("proof.removePack", &json!({"locale": "nl"})).unwrap(); + let rows = packs::your_languages_with(s, None, &none); + assert_eq!(row(&rows, "nl-NL").proofing, Proofing::Install, "still used by the document"); + }); + } + + #[test] + fn the_own_folder_and_the_default_language() { + with_backend(FixedBackend::sample(), |s, _| { + s.run("document.setText", &json!({"text": "Cześć\nMerhaba"})).unwrap(); + mark(s, 0, "pl-PL"); + mark(s, 1, "tr-TR"); + let dic = |tag: &str| { + if tag.starts_with("pl") { + Some(std::path::PathBuf::from("/mine/dicts/pl_PL.dic")) + } else if tag.starts_with("tr") { + Some(std::path::PathBuf::from("/usr/share/hunspell/tr_TR.dic")) + } else { + None + } + }; + let rows = packs::your_languages_with(s, Some("/mine/dicts"), &dic); + assert_eq!(row(&rows, "pl-PL").proofing, Proofing::OwnDictionary); + assert_eq!(row(&rows, "tr-TR").proofing, Proofing::SystemDictionary); + // en-GB as the default is its own row, the default one; en-US stays if the document uses it. + s.run("review.language", &json!({"lang": "en-GB", "default": true})).unwrap(); + let rows = packs::your_languages_with(s, None, &none); + let gb = row(&rows, "en-GB"); + assert!(gb.default && gb.proofing == Proofing::BuiltIn); + assert_eq!(rows.iter().filter(|r| r.default).count(), 1); + }); + } + + #[test] + fn hostile_tags_never_panic() { + with_backend(FixedBackend::sample(), |s, _| { + s.run("document.setText", &json!({"text": "a b"})).unwrap(); + s.prefs.default_language = Some("x".repeat(10_000)); + let _ = packs::your_languages_with(s, Some(""), &none); + s.prefs.default_language = Some("\u{0}-\u{202e}".into()); + let _ = packs::your_languages_with(s, None, &none); + }); + } + } + #[test] fn unknown_and_hostile_locales_are_errors() { with_backend(FixedBackend::sample(), |s, b| { diff --git a/crates/engine/src/packs.rs b/crates/engine/src/packs.rs index d618049ef9..e37556935c 100644 --- a/crates/engine/src/packs.rs +++ b/crates/engine/src/packs.rs @@ -724,6 +724,169 @@ pub fn missing(s: &Session) -> Vec { out } +/// Where a language's proofing comes from (Options › Language › Your languages). +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)] +#[serde(rename_all = "snake_case")] +pub enum Proofing { + /// English: the embedded dictionaries. + BuiltIn, + /// An installed Language pack. + Installed, + /// A Hunspell dictionary in the person's own dictionaries folder. + OwnDictionary, + /// A Hunspell dictionary the system has. + SystemDictionary, + /// No dictionary yet; a Language pack can be installed. + Install, + /// Grammar and hyphenation rules built in; a Language pack adds spelling. + GrammarBuiltIn, + /// No dictionary and no pack for it. + NotAvailable, +} + +/// A row of Options › Language › Your languages. +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] +pub struct LanguageRow { + /// The tags the default proofing language or the open document use for this language (the + /// first is what Set as default sets); empty for a language listed for its installed pack. + pub tags: Vec, + /// The pack locale: the installed pack, else the one the index offers. + pub pack: Option, + /// Is the pack installed? + pub installed: bool, + /// Bytes of the offered pack (0 when the index has none). + pub size: u64, + pub proofing: Proofing, + /// Is this the default proofing language? + pub default: bool, +} + +impl LanguageRow { + /// Is `tag` (the insertion point's language) one of this row's languages? + pub fn is_tag(&self, tag: &str) -> bool { + self.tags.iter().any(|t| t.eq_ignore_ascii_case(tag)) + } +} + +/// The first locale `has` accepts for `tag`: the whole tag, then each shorter prefix of it (as +/// [`pack_for_tag`]). `None` for English and junk. +fn locale_for_tag(tag: &str, has: &dyn Fn(&str) -> bool) -> Option { + let tag: String = tag.trim().chars().take(64).collect::().replace('_', "-").to_ascii_lowercase(); + let base = tag.split('-').next().unwrap_or(""); + if base.is_empty() || base == "en" { + return None; + } + let mut prefix = tag.as_str(); + loop { + if has(prefix) { + return Some(prefix.to_string()); + } + prefix = prefix.rsplit_once('-')?.0; + } +} + +/// [`your_languages_with`] against the dictionaries on this computer. +pub fn your_languages(s: &Session) -> Vec { + let folder = s.prefs.dictionaries_folder.clone(); + your_languages_with(s, folder.as_deref(), &dictionary_file) +} + +/// The Hunspell `.dic` file proofing reads for `tag`'s language now (a built-in-rules language's +/// own, or a pack language's), if any. +fn dictionary_file(tag: &str) -> Option { + let lang = wordcraft_proof::ProofLang::from_tag(Some(tag)); + if let Some((_, f)) = wordcraft_proof::installed_dictionaries().into_iter().find(|(l, _)| *l == lang) { + return f; + } + wordcraft_proof::pack_dictionary_file(lang) +} + +/// Options › Language › Your languages (unsorted; the window names and sorts them): each English +/// variant in use (the default proofing language, American English and any in the open document), every language +/// with an installed Language pack, and every proofing language of the open document. One row per +/// language: tags one pack proofs share a row. `folder` is the person's own dictionaries folder; +/// `dictionary` finds the `.dic` file proofing reads for a tag. +pub fn your_languages_with(s: &Session, folder: Option<&str>, dictionary: &dyn Fn(&str) -> Option) -> Vec { + let index = available(); + let installed = installed(); + let default_tag = s + .prefs + .default_language + .clone() + .or_else(|| s.editing_lang.clone()) + .or_else(|| s.doc.styles.default_chr.lang.clone()) + .unwrap_or_else(|| "en-US".to_string()); + // American English stays listed whatever the default is, so it can always be set back. + let mut tags = vec![default_tag.clone(), "en-US".to_string()]; + tags.dedup_by(|a, b| a.eq_ignore_ascii_case(b)); + for t in document_languages(s) { + if !tags.iter().any(|x| x.eq_ignore_ascii_case(&t)) { + tags.push(t); + } + } + let mut rows: Vec = Vec::new(); + let mut add = |tag: Option<&str>, locale: Option| { + let english = tag.is_some_and(|t| wordcraft_proof::ProofLang::from_tag(Some(t)).is_english()); + // English variants stay apart (en-GB and en-US are two rows); a pack's tags share one. + let existing = rows.iter().position(|r| match (&locale, &r.pack) { + (Some(l), Some(p)) if !english => l == p, + _ => tag.is_some_and(|t| r.is_tag(t)), + }); + let i = existing.unwrap_or_else(|| { + rows.push(LanguageRow { + tags: Vec::new(), + pack: locale.clone(), + installed: false, + size: 0, + proofing: Proofing::NotAvailable, + default: false, + }); + rows.len() - 1 + }); + if let (Some(t), Some(row)) = (tag, rows.get_mut(i)) + && !row.is_tag(t) + { + row.tags.push(t.to_string()); + } + }; + for t in &tags { + if !proofable(t) { + continue; + } + let locale = + locale_for_tag(t, &|l| installed.iter().any(|i| i.locale == l)).or_else(|| locale_for_tag(t, &|l| index.iter().any(|p| p.locale == l))); + add(Some(t), locale); + } + for i in &installed { + add(None, Some(i.locale.clone())); + } + for row in &mut rows { + let installed_here = row.pack.as_ref().is_some_and(|l| installed.iter().any(|i| &i.locale == l)); + let offered = row.pack.as_ref().and_then(|l| index.iter().find(|p| &p.locale == l)); + row.installed = installed_here; + row.size = offered.map_or(0, |p| p.size); + row.default = row.is_tag(&default_tag); + let tag = row.tags.first().cloned().or_else(|| row.pack.clone()).unwrap_or_default(); + let lang = wordcraft_proof::ProofLang::from_tag(Some(&tag)); + let file = if lang.is_english() { None } else { dictionary(&tag) }; + let own = file.as_ref().is_some_and(|f| folder.is_some_and(|d| !d.trim().is_empty() && f.starts_with(d.trim()))); + row.proofing = if lang.is_english() { + Proofing::BuiltIn + } else if own { + Proofing::OwnDictionary + } else if installed_here { + Proofing::Installed + } else if file.is_some() { + Proofing::SystemDictionary + } else if offered.is_some() { + if matches!(lang, wordcraft_proof::ProofLang::Pack(_)) { Proofing::Install } else { Proofing::GrammarBuiltIn } + } else { + Proofing::NotAvailable + }; + } + rows +} + /// A backend with a fixed list and installs that only record themselves: tests and `ui_shot`. #[derive(Default)] pub struct FixedBackend { diff --git a/crates/ui-egui/examples/ui_shot.rs b/crates/ui-egui/examples/ui_shot.rs index b7e3fb55ba..906b41f4c9 100644 --- a/crates/ui-egui/examples/ui_shot.rs +++ b/crates/ui-egui/examples/ui_shot.rs @@ -10,7 +10,7 @@ //! document unless the first line is `{"empty": true}`; `{"empty": true, "startScreen": true}` //! starts the way the desktop app does with nothing to open (File › Home, #766). A line //! `{"demoPacks": true}` lists a few sample Language packs (installs only record themselves), and -//! `{"demoPacks": "store"}` uses a real font store, as the desktop app does, in a new temporary +//! (with `{"network": true}` on a line, downloading is already on) `{"demoPacks": "store"}` uses a real font store, as the desktop app does, in a new temporary //! folder rather than the person's, or in `"storeDir"` given on the same line (with //! `CRAFT_LANGUAGE_PACK_INDEX` for a local pack index). @@ -40,7 +40,14 @@ fn main() { .unwrap_or_else(|| std::env::temp_dir().join(format!("ui_shot-font-store-{}", std::process::id()))); wordcraft_engine::packs::use_font_store_in(dir, true); } - Some(_) => wordcraft_engine::packs::set_backend(Some(std::sync::Arc::new(wordcraft_engine::packs::FixedBackend::sample()))), + Some(_) => { + // `"network": true` on a line has downloading already on (to show what follows a click on Add a language…). + let backend = wordcraft_engine::packs::FixedBackend::sample(); + if lines.iter().any(|l| l.get("network") == Some(&serde_json::Value::Bool(true))) { + backend.network.store(true, std::sync::atomic::Ordering::Relaxed); + } + wordcraft_engine::packs::set_backend(Some(std::sync::Arc::new(backend))); + } None => {} } let mut app = WordApp::new(Session::new(doc), Services::default()).with_control(rx); diff --git a/crates/ui-egui/src/language_packs.rs b/crates/ui-egui/src/language_packs.rs index 4878d582e2..08f36f0f46 100644 --- a/crates/ui-egui/src/language_packs.rs +++ b/crates/ui-egui/src/language_packs.rs @@ -11,7 +11,7 @@ use std::sync::Arc; use egui::{RichText, Ui, vec2}; use serde_json::json; -use wordcraft_engine::packs::{self, Pack}; +use wordcraft_engine::packs::{self, LanguageRow, Pack, Proofing}; use crate::WordApp; use crate::theme::{Tokens, semibold}; @@ -81,6 +81,14 @@ pub(crate) struct Runtime { missing: Option<(MissingKey, f64, Vec)>, /// [`packs::finished`] when last looked at. finished: u64, + /// The Your languages rows, and what they were worked out from. + rows: Option<(RowsKey, Vec)>, + /// Is the Add a language window open? + picker: bool, + /// Its search text. + search: String, + /// Has its search box been given focus since it opened? + focused: bool, } #[derive(Clone, Copy, PartialEq, Eq)] @@ -106,7 +114,7 @@ pub(crate) fn size_text(bytes: u64) -> String { /// English names of the Language pack languages the Language dialog's list doesn't have, by the /// tag a document stores for them ([`crate::ribbon::tag_for_pack`]): every pack in the published /// index has a name in the interface language (CP4.3: Belarusian showed as Беларуская). -pub(crate) const MORE_LANGUAGES: [(&str, &str); 27] = [ +pub(crate) const MORE_LANGUAGES: [(&str, &str); 28] = [ ("af-ZA", "Afrikaans"), ("be-BY", "Belarusian"), ("bg-BG", "Bulgarian"), @@ -133,6 +141,7 @@ pub(crate) const MORE_LANGUAGES: [(&str, &str); 27] = [ ("sq-AL", "Albanian"), ("sw-KE", "Swahili"), ("ta-IN", "Tamil"), + ("th-TH", "Thai"), ("vi-VN", "Vietnamese"), ]; @@ -327,137 +336,369 @@ fn licence_hover(pack: &Pack) -> String { lines.join("\n") } -/// File › Options › Language › Language packs: every available and installed pack with its -/// name, size, licence and source, and Install or Remove. -pub(crate) fn options_section(app: &mut WordApp, ui: &mut Ui) { - // Pack names include Arabic and other scripts; ask for a system Arabic face when none is embedded. +/// What the Your languages list needs of the engine's rows, worked out again when the document, +/// the packs, the dictionaries, the default language or the folder change. +type RowsKey = (MissingKey, Option, Option); + +fn your_rows(app: &mut WordApp) -> Vec { + let key: RowsKey = ( + MissingKey { + document: app.session.document_id(), + rev: app.session.rev(), + generation: wordcraft_engine::proof::dictionary_generation(), + packs: packs::index_generation(), + }, + app.session.prefs.default_language.clone(), + app.session.prefs.dictionaries_folder.clone(), + ); + if let Some((k, rows)) = &app.packs_rt.rows + && *k == key + { + return rows.clone(); + } + let rows = packs::your_languages(&app.session); + app.packs_rt.rows = Some((key, rows.clone())); + rows +} + +/// The tag Set as default sets for a row: the one the document or default uses, else the one a +/// text in the pack's language is marked with. +fn row_tag(row: &LanguageRow) -> String { + row.tags.first().cloned().or_else(|| row.pack.as_deref().map(crate::ribbon::tag_for_pack)).unwrap_or_default() +} + +/// A row's interface name and, beneath it, its own name and code (`Nederlands · nl`). +fn row_names(row: &LanguageRow, index: &[Pack], installed: &[packs::Installed]) -> (String, String) { + let tag = row_tag(row); + let endonym = row + .pack + .as_deref() + .and_then(|l| { + index.iter().find(|p| p.locale == l).map(|p| p.name.clone()).or_else(|| installed.iter().find(|i| i.locale == l).map(|i| i.name.clone())) + }) + .unwrap_or_default(); + let named = crate::ribbon::language_name(Some(&tag)); + let name = if named.eq_ignore_ascii_case(&tag) && !endonym.trim().is_empty() { shown(&endonym, MAX_BAR_NAME) } else { tl!(&named).to_string() }; + let endonym = shown(&endonym, MAX_BAR_NAME); + let detail = if endonym.is_empty() || endonym == name { tag } else { format!("{endonym} · {tag}") }; + (name, detail) +} + +/// Does `query` find a pack: part of its interface name or own name, or the start of its code +/// (dutch, nederlands, nl). +fn matches(query: &str, name: &str, endonym: &str, locale: &str) -> bool { + let q = query.trim().to_lowercase(); + q.is_empty() || name.to_lowercase().contains(&q) || endonym.to_lowercase().contains(&q) || locale.to_lowercase().starts_with(&q) +} + +/// The packs the picker offers for `query`: not installed, by interface name. +fn picker_packs(index: &[Pack], installed: &[packs::Installed], query: &str) -> Vec<(String, Pack)> { + let mut out: Vec<(String, Pack)> = index + .iter() + .filter(|p| !installed.iter().any(|i| i.locale == p.locale)) + .map(|p| (shown(&language_of(&p.locale, &p.name), MAX_BAR_NAME), p.clone())) + .filter(|(name, p)| matches(query, name, &shown(&p.name, MAX_BAR_NAME), &p.locale)) + .collect(); + out.sort_by_cached_key(|(name, p)| (crate::ribbon::sort_key(name), p.locale.clone())); + out +} + +/// Your languages as listed: interface name, own name and code, and the row, by name. +fn your_view(app: &mut WordApp, index: &[Pack], installed: &[packs::Installed]) -> Vec<(String, String, LanguageRow)> { + let mut view: Vec<(String, String, LanguageRow)> = your_rows(app) + .into_iter() + .map(|r| { + let (name, detail) = row_names(&r, index, installed); + (name, detail, r) + }) + .collect(); + view.sort_by_cached_key(|(name, _, r)| (crate::ribbon::sort_key(name), r.pack.clone())); + view +} + +/// File › Options › Language › Your languages: the languages in use and installed, each with +/// where its proofing comes from and what can be done, and Add a language…. +pub(crate) fn your_languages_section(app: &mut WordApp, ui: &mut Ui) { + // Language names include Arabic and other scripts; ask for a system Arabic face when none is embedded. app.want_system_arabic = true; let t = Tokens::get(ui.ctx()); - ui.label(RichText::new(tl!("Language packs")).font(semibold(15.0))); + ui.label(RichText::new(tl!("Your languages")).font(semibold(15.0))); ui.add_space(2.0); - ui.label(RichText::new(tl!("Spelling dictionaries and hyphenation for more languages. English is built in.")).small().weak()); - let Some(backend) = packs::backend() else { + ui.label( + RichText::new(tl!( + "English, the languages of this document and every installed Language pack. Language packs add spelling dictionaries and hyphenation." + )) + .small() + .weak(), + ); + ui.add_space(4.0); + let backend = packs::backend(); + if backend.is_none() { let why = if cfg!(target_arch = "wasm32") { tl!("Language packs aren't available in the browser.") } else { tl!("Language packs need the font store folder, and there is none on this computer.") }; ui.label(RichText::new(why).small().weak()); - return; - }; + } if let Some(source) = packs::index_override() { let line = crate::i18n::fmt(tl!("Language packs come from a test source: {source}"), &[("source", &shown(&source, 300))]); ui.add(egui::Label::new(RichText::new(line).small().color(t.orange)).wrap()); } let index = packs::available(); let installed = packs::installed(); - let network = backend.network_on(); - if let Some(e) = error_of(app, "") { - ui.add(egui::Label::new(RichText::new(e).small().color(t.red)).wrap()); - } - ui.horizontal(|ui| { - if packs::fetching() { - ui.spinner(); - ui.label(RichText::new(tl!("Getting the list of languages…")).small()); - } else if index.is_empty() && !network { - if ui.button(tl!("Show available languages")).clicked() { - start_fetch(app, &ui.ctx().clone()); - } - } else if ui.button(tl!("Refresh")).on_hover_text(tl!("Get the list of languages again")).clicked() { - start_fetch(app, &ui.ctx().clone()); - } - }); - if !network { - ui.label( - RichText::new(tl!( - "Downloading is off. Clicking Show available languages, Refresh or Install turns it on: WordCraft then downloads language packs and fonts from GitHub." - )) - .small() - .weak(), - ); - } - // Installed packs the list no longer has stay removable. - let mut rows: Vec<(Pack, bool)> = index.iter().map(|p| (p.clone(), installed.iter().any(|i| i.locale == p.locale))).collect(); - for i in &installed { - if !rows.iter().any(|(p, _)| p.locale == i.locale) { - let pack = Pack { - locale: i.locale.clone(), - name: i.name.clone(), - version: String::new(), - url: String::new(), - source: None, - size: 0, - licence: i.licence.clone(), - class: String::new(), - spelling: false, - hyphenation: false, - }; - rows.push((pack, true)); - } - } - if rows.is_empty() { - return; - } - ui.add_space(4.0); + let caret = crate::ribbon::caret_lang_tag(app); + let view = your_view(app, &index, &installed); let mut install = None; let mut removal = None; - egui::ScrollArea::vertical().id_salt("options_language_packs").max_height(260.0).show(ui, |ui| { - crate::rtl::grid(ui, egui::Grid::new("options_language_packs_grid").num_columns(5).spacing(vec2(14.0, 6.0)).striped(true), |ui| { - for h in ["Language", "Size", "Licence", "Source", ""] { - ui.label(RichText::new(if h.is_empty() { "" } else { tl!(h) }).small().color(t.text_dim)); - } - ui.end_row(); - for (pack, is_installed) in &rows { + let mut default = None; + egui::ScrollArea::vertical().id_salt("options_your_languages").max_height(300.0).auto_shrink([false, true]).show(ui, |ui| { + crate::rtl::grid(ui, egui::Grid::new("options_your_languages_grid").num_columns(3).spacing(vec2(16.0, 8.0)).striped(true), |ui| { + for (name, detail, row) in &view { + let here = caret.as_deref().is_some_and(|c| row.is_tag(c)); ui.vertical(|ui| { - ui.set_width(180.0); - let language = shown(&language_of(&pack.locale, &pack.name), MAX_BAR_NAME); - let name = shown(&pack.name, MAX_BAR_NAME); - // The pack's own name when it differs (Nederlands for Dutch), and its locale. - let detail = if language == name { pack.locale.clone() } else { format!("{name} · {}", pack.locale) }; - ui.label(language); - ui.label(RichText::new(detail).small().weak()); + ui.set_width(250.0); + let shown_name = shown(name, MAX_BAR_NAME); + let line = if row.default { crate::i18n::fmt(tl!("{language} (default)"), &[("language", &shown_name)]) } else { shown_name }; + ui.label(if here { RichText::new(line).font(semibold(14.0)) } else { RichText::new(line) }); + ui.label(RichText::new(tl!(detail)).small().weak()); }); - ui.label(if pack.size > 0 { size_text(pack.size) } else { String::new() }); + let pack = row.pack.as_deref().and_then(|l| index.iter().find(|p| p.locale == l)); + let size = size_text(row.size); ui.vertical(|ui| { - ui.set_width(220.0); - ui.add(egui::Label::new(RichText::new(shown(&pack.licence, 300)).small()).wrap()); + ui.set_width(190.0); + match row.proofing { + Proofing::BuiltIn => { + ui.label(tl!("Built in")); + } + Proofing::Installed => { + ui.label(RichText::new(tl!("Installed")).color(t.green)); + } + Proofing::OwnDictionary => { + ui.label(tl!("Your own dictionary")); + } + Proofing::SystemDictionary => { + ui.label(tl!("System dictionary")); + } + Proofing::NotAvailable => { + ui.label(RichText::new(tl!("Not available yet")).weak()); + } + Proofing::GrammarBuiltIn => { + ui.label(tl!("Grammar built in")); + } + Proofing::Install => {} + } + if let Some(pack) = pack + && !row.installed + && matches!(row.proofing, Proofing::Install | Proofing::GrammarBuiltIn) + { + match progress(&pack.locale) { + Some((done, total)) => { + ui.horizontal(|ui| { + ui.add(egui::ProgressBar::new(done.min(total) as f32 / total as f32).desired_width(90.0).show_percentage()); + if ui.small_button(tl!("Cancel")).clicked() { + packs::cancel(&pack.locale); + } + }); + } + None => { + let label = if row.proofing == Proofing::Install { + crate::i18n::fmt(tl!("Install ({size})"), &[("size", &size)]) + } else { + crate::i18n::fmt(tl!("Install spelling ({size})"), &[("size", &size)]) + }; + if ui.button(label).on_hover_text(licence_hover(pack)).clicked() { + install = Some(pack.clone()); + } + } + } + } }); - let source = pack.source_link(); - if source.is_empty() { - ui.label(""); - } else { - ui.hyperlink_to(tl!("Source"), source).on_hover_text(shown(source, 300)); - } - ui.horizontal(|ui| { - if let Some((done, total)) = progress(&pack.locale) { - ui.add(egui::ProgressBar::new(done.min(total) as f32 / total as f32).desired_width(90.0).show_percentage()); - if ui.small_button(tl!("Cancel")).clicked() { - packs::cancel(&pack.locale); - } - } else if *is_installed { - ui.label(RichText::new(tl!("Installed")).small().color(t.green)); - if ui.add_enabled(!busy(), egui::Button::new(tl!("Remove"))).clicked() { - removal = Some(pack.locale.clone()); - } - } else if ui.button(tl!("Install")).clicked() { - install = Some(pack.clone()); + ui.with_layout(egui::Layout::left_to_right(egui::Align::TOP), |ui| { + if !row.default && ui.small_button(tl!("Set as default")).on_hover_text(tl!("New text is written in this language")).clicked() { + default = Some(row_tag(row)); + } + if row.installed + && let Some(locale) = &row.pack + && ui.add_enabled(!busy(), egui::Button::new(tl!("Remove")).small()).clicked() + { + removal = Some(locale.clone()); } }); ui.end_row(); - if let Some(e) = error_of(app, &pack.locale) { + let error = row.pack.as_deref().and_then(|l| error_of(app, l)); + let unreadable = (matches!(row.proofing, Proofing::OwnDictionary | Proofing::SystemDictionary)) + .then(|| wordcraft_engine::proof::dictionary_load_error(wordcraft_engine::proof::ProofLang::from_tag(Some(&row_tag(row))))) + .flatten(); + if error.is_some() || unreadable.is_some() { + ui.label(""); + ui.vertical(|ui| { + if let Some(e) = error { + ui.add(egui::Label::new(RichText::new(e).small().color(t.red)).wrap()); + } + if let Some(reason) = unreadable { + let line = crate::i18n::fmt(tl!("Its dictionary couldn't be read: {reason}"), &[("reason", &shown_error(&reason))]); + ui.add(egui::Label::new(RichText::new(line).small().color(t.red)).wrap()); + } + }); ui.label(""); - ui.add(egui::Label::new(RichText::new(e).small().color(t.red)).wrap()); ui.end_row(); } } }); }); + ui.add_space(4.0); + if let Some(e) = error_of(app, "") { + ui.add(egui::Label::new(RichText::new(e).small().color(t.red)).wrap()); + } + ui.horizontal(|ui| { + if ui.add_enabled(backend.is_some(), egui::Button::new(tl!("Add a language…"))).clicked() { + open_picker(app, &ui.ctx().clone()); + } + if packs::fetching() { + ui.spinner(); + ui.label(RichText::new(tl!("Getting the list of languages…")).small()); + } + }); + if backend.as_ref().is_some_and(|b| !b.network_on()) { + ui.label( + RichText::new(tl!( + "Downloading is off. Clicking Add a language… or Install turns it on: WordCraft then downloads language packs and fonts from GitHub." + )) + .small() + .weak(), + ); + } if let Some(p) = install { start_install(app, &ui.ctx().clone(), &p); } if let Some(l) = removal { remove(app, &l); } + if let Some(tag) = default + && let Err(e) = app.run("review.language", json!({"lang": tag, "default": true})) + { + app.status(e); + } +} + +/// The Add a language… click: the person's own click is their consent to download (an agent's +/// never is: it leaves downloading off and says why); then the picker opens, and the list of +/// languages is fetched when downloading was just turned on or there is none yet. +fn open_picker(app: &mut WordApp, ctx: &egui::Context) { + let Some(backend) = packs::backend() else { return }; + app.packs_rt.errors.remove(""); + let was_on = backend.network_on(); + if !consent(app, ctx, "") { + return; + } + if !was_on || packs::available().is_empty() { + start_fetch(app, ctx); + } + app.packs_rt.search.clear(); + app.packs_rt.picker = true; +} + +/// The Add a language window: search, then the packs not installed, by name, each with its size, +/// licence, source and Install. Stays open while installs run. +pub(crate) fn add_language_window(app: &mut WordApp, ctx: &egui::Context) { + if !app.packs_rt.picker { + return; + } + // Pack names include Arabic and other scripts. + app.want_system_arabic = true; + let t = Tokens::get(ctx); + let mut open = true; + egui::Window::new(tl!("Add a language")) + .open(&mut open) + .collapsible(false) + .resizable(true) + .default_width(620.0) + .anchor(egui::Align2::CENTER_CENTER, vec2(0.0, -80.0)) + .show(ctx, |ui| { + ui.set_min_width(580.0); + let index = packs::available(); + let installed = packs::installed(); + ui.horizontal(|ui| { + let search_label = ui.label(tl!("Search:")); + let mut search = std::mem::take(&mut app.packs_rt.search); + let r = ui + .add(egui::TextEdit::singleline(&mut search).desired_width(280.0).hint_text(tl!("Dutch, Nederlands or nl"))) + .labelled_by(search_label.id); + if !r.has_focus() && app.packs_rt.search.is_empty() && search.is_empty() && !app.packs_rt.focused { + r.request_focus(); + } + app.packs_rt.focused = true; + app.packs_rt.search = search; + if packs::fetching() { + ui.spinner(); + ui.label(RichText::new(tl!("Getting the list of languages…")).small()); + } else if ui.button(tl!("Refresh")).on_hover_text(tl!("Get the list of languages again")).clicked() { + start_fetch(app, &ui.ctx().clone()); + } + }); + if let Some(e) = error_of(app, "") { + ui.add(egui::Label::new(RichText::new(e).small().color(t.red)).wrap()); + } + ui.add_space(4.0); + let list = picker_packs(&index, &installed, &app.packs_rt.search); + if list.is_empty() { + let text = if index.is_empty() { tl!("No languages to show yet.") } else { tl!("No language matches your search.") }; + ui.label(RichText::new(text).weak()); + } + let mut install = None; + egui::ScrollArea::vertical().id_salt("add_language_list").max_height(340.0).auto_shrink([false, true]).show(ui, |ui| { + crate::rtl::grid(ui, egui::Grid::new("add_language_grid").num_columns(4).spacing(vec2(14.0, 8.0)).striped(true), |ui| { + for (name, pack) in &list { + ui.vertical(|ui| { + ui.set_width(180.0); + ui.label(name.as_str()); + let endonym = shown(&pack.name, MAX_BAR_NAME); + let detail = if endonym == *name { pack.locale.clone() } else { format!("{endonym} · {}", pack.locale) }; + ui.label(RichText::new(tl!(&detail)).small().weak()); + }); + ui.label(if pack.size > 0 { size_text(pack.size) } else { String::new() }); + ui.vertical(|ui| { + ui.set_width(150.0); + let licence = shown(&pack.licence, 300); + ui.add(egui::Label::new(RichText::new(licence.as_str()).small()).truncate()).on_hover_text(licence_hover(pack)); + let source = pack.source_link(); + if !source.is_empty() { + ui.hyperlink_to(tl!("Source"), source).on_hover_text(shown(source, 300)); + } + }); + ui.horizontal(|ui| match progress(&pack.locale) { + Some((done, total)) => { + ui.add(egui::ProgressBar::new(done.min(total) as f32 / total as f32).desired_width(80.0).show_percentage()); + if ui.small_button(tl!("Cancel")).clicked() { + packs::cancel(&pack.locale); + } + } + None => { + if ui.button(tl!("Install")).clicked() { + install = Some(pack.clone()); + } + } + }); + ui.end_row(); + if let Some(e) = error_of(app, &pack.locale) { + ui.label(""); + ui.add(egui::Label::new(RichText::new(e).small().color(t.red)).wrap()); + ui.label(""); + ui.label(""); + ui.end_row(); + } + } + }); + }); + if let Some(p) = install { + start_install(app, &ui.ctx().clone(), &p); + } + }); + if !open { + app.packs_rt.picker = false; + app.packs_rt.focused = false; + } } /// Height of About › Language data's list. @@ -920,4 +1161,178 @@ mod tests { } assert!(packs::is_installed("pl")); } + + // ---- Options › Language: Your languages, Add a language (CP4.3) ---- + + struct ResetBackend; + impl Drop for ResetBackend { + fn drop(&mut self) { + packs::set_background(None); + packs::set_backend(None); + } + } + + /// An app on File › Options › `pane`, with the sample packs (downloading as `network`), and + /// the context to draw it in. + fn options_app(pane: &str, network: bool) -> (WordApp, egui::Context, std::sync::Arc) { + let ctx = egui::Context::default(); + crate::theme::install_fonts(&ctx); + crate::theme::apply(&ctx, crate::theme::Appearance::Light); + ctx.run_ui(egui::RawInput::default(), |_| {}).drop_without_applying_deltas(); + ctx.enable_accesskit(); + let backend = std::sync::Arc::new(FixedBackend::sample()); + backend.network.store(network, Ordering::Relaxed); + packs::set_backend(Some(backend.clone() as std::sync::Arc)); + let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), crate::Services::default()); + a.ui.backstage = true; + a.ui.backstage_page = "options".into(); + a.ui.options_pane = pane.into(); + (a, ctx, backend) + } + + /// The widgets after a few frames: accessibility updates carry only what changed, so each + /// frame's nodes are merged (the latest of a widget wins). + fn settled(a: &mut WordApp, ctx: &egui::Context) -> egui::accesskit::TreeUpdate { + // A command (a document edit, an install) can close the Backstage: Options stays open. + a.ui.backstage = true; + a.ui.backstage_page = "options".into(); + let mut merged: std::collections::BTreeMap = Default::default(); + let mut last = frame(a, ctx, Vec::new()); + for i in 0..5 { + for (id, node) in last.nodes.drain(..) { + merged.insert(id.0, (id, node)); + } + if i < 4 { + last = frame(a, ctx, Vec::new()); + } + } + last.nodes = merged.into_values().collect(); + last + } + + /// Installs Dutch: on the engine's thread when another test's window moved installs there + /// (`tick`), so waits for it. + fn install_nl(a: &mut WordApp) { + a.run("proof.installPack", json!({"locale": "nl"})).unwrap(); + for _ in 0..500 { + if packs::is_installed("nl") { + return; + } + std::thread::sleep(std::time::Duration::from_millis(10)); + } + } + + fn labels(tree: &egui::accesskit::TreeUpdate) -> Vec { + tree.nodes.iter().filter_map(|(_, n)| n.label().or_else(|| n.value()).map(str::to_string)).collect() + } + + fn has(tree: &egui::accesskit::TreeUpdate, label: &str) -> bool { + labels(tree).iter().any(|l| l == label) + } + + /// A fresh install lists English, built in and the default; with Dutch installed, Dutch is a + /// row with Installed and Remove; a document in Thai (no pack) says Not available yet, one in + /// Polish (a pack, grammar built in) offers to install the spelling. + #[test] + fn your_languages_list_the_status_of_each() { + let _g = BACKEND_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let _reset = ResetBackend; + let (mut a, ctx, _backend) = options_app("language", true); + let tree = settled(&mut a, &ctx); + assert!(has(&tree, "English (United States) (default)"), "{:?}", labels(&tree)); + assert!(has(&tree, "Built in")); + assert!(!labels(&tree).iter().any(|l| l == "Remove" || l == "Installed")); + install_nl(&mut a); + a.run("document.setText", json!({"text": "สวัสดี\nCześć"})).unwrap(); + for (para, lang) in [(0, "th-TH"), (1, "pl-PL")] { + a.run("caret.set", json!({"pos": {"block": para, "off": 0}})).unwrap(); + a.run("select.paragraph", json!({})).unwrap(); + a.run("review.language", json!({"lang": lang})).unwrap(); + } + let tree = settled(&mut a, &ctx); + let all = labels(&tree); + assert!(all.iter().any(|l| l == "Dutch"), "{all:?}"); + assert!(all.iter().any(|l| l == "Installed") && all.iter().any(|l| l == "Remove")); + assert!(all.iter().any(|l| l == "Thai") && all.iter().any(|l| l == "Not available yet"), "{all:?}"); + assert!(all.iter().any(|l| l == "Polish") && all.iter().any(|l| l == "Grammar built in"), "{all:?}"); + assert!(all.iter().any(|l| l.starts_with("Install spelling (")), "{all:?}"); + // Listed by name: Dutch, English, Polish, Thai. + let view: Vec = super::your_view(&mut a, &packs::available(), &packs::installed()).into_iter().map(|(n, ..)| n).collect(); + assert_eq!(view, ["Dutch", "English (United States)", "Polish", "Thai"], "by the name shown"); + // The Proofing tab no longer has the Dictionaries section; the folder is on this tab. + assert!(all.iter().any(|l| l == "Your own dictionaries folder") && all.iter().any(|l| l == "Add a language…")); + a.ui.options_pane = "proofing".into(); + let tree = settled(&mut a, &ctx); + let all = labels(&tree); + assert!(!all.iter().any(|l| l.starts_with("Dictionaries") || l.contains("dictionaries folder")), "{all:?}"); + assert!(all.iter().any(|l| l == "Custom dictionary")); + } + + /// The picker finds Dutch by its English name, its own name and its code, leaves out what is + /// installed and sorts by the name shown. + #[test] + fn the_picker_searches_by_name_own_name_and_code() { + let _g = BACKEND_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let _reset = ResetBackend; + let index = index_packs(); + let none: Vec = Vec::new(); + for q in ["dutch", "Dutch", "nederlands", "NL", "nl", " nl "] { + let found: Vec = super::picker_packs(&index, &none, q).into_iter().map(|(_, p)| p.locale).collect(); + assert!(found.iter().any(|l| l == "nl"), "{q}: {found:?}"); + } + assert_eq!(super::picker_packs(&index, &none, "zzzz").len(), 0); + let all = super::picker_packs(&index, &none, ""); + assert_eq!(all.len(), index.len(), "regional variants are rows of their own"); + assert!(all.windows(2).all(|w| crate::ribbon::sort_key(&w[0].0) <= crate::ribbon::sort_key(&w[1].0)), "sorted by shown name"); + let installed = vec![packs::Installed { locale: "nl".into(), name: "Nederlands".into(), licence: String::new(), path: Default::default() }]; + assert!(!super::picker_packs(&index, &installed, "dutch").iter().any(|(_, p)| p.locale == "nl")); + } + + /// Add a language…: a click the control channel made never turns downloading on (it says + /// why and opens nothing); the person's own click does, and opens the picker. + #[test] + fn a_faked_click_on_add_a_language_never_turns_on_downloading() { + let _g = BACKEND_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let _reset = ResetBackend; + let (mut a, ctx, backend) = options_app("language", false); + let tree = settled(&mut a, &ctx); + let add = spot(&tree, "Add a language").expect("the button"); + as_agent(&mut a, &ctx, "ui.click", json!({"x": add.0, "y": add.1})); + assert!(!backend.network.load(Ordering::Relaxed), "a faked click leaves downloading off"); + assert!(!a.packs_rt.picker, "and opens nothing"); + assert!(a.packs_rt.errors.get("").is_some_and(|e| e.contains("Only you")), "{:?}", a.packs_rt.errors); + // The reason is shown above the button, which moves down. + let add = spot(&settled(&mut a, &ctx), "Add a language").expect("the button"); + user_click(&mut a, &ctx, add); + assert!(backend.network.load(Ordering::Relaxed), "the person's click is the consent"); + assert!(a.packs_rt.picker); + for _ in 0..500 { + if !packs::fetching() { + break; + } + std::thread::sleep(std::time::Duration::from_millis(10)); + } + let tree = settled(&mut a, &ctx); + assert!(has(&tree, "Search:") && has(&tree, "Refresh"), "{:?}", labels(&tree)); + assert!(labels(&tree).iter().any(|l| l == "Catalan"), "the packs are listed by name: {:?}", labels(&tree)); + } + + /// Set as default sets the default proofing language: new text is written in it. + #[test] + fn set_as_default_changes_new_texts_language() { + let _g = BACKEND_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let _reset = ResetBackend; + let (mut a, ctx, _backend) = options_app("language", true); + install_nl(&mut a); + let tree = settled(&mut a, &ctx); + // Dutch is listed first and isn't the default: its Set as default is the first one. + let set = spot(&tree, "Set as default").expect("Dutch can be made the default"); + assert_eq!(a.session.prefs.default_language, None); + user_click(&mut a, &ctx, set); + assert_eq!(a.session.prefs.default_language.as_deref(), Some("nl-NL")); + let tree = settled(&mut a, &ctx); + assert!(has(&tree, "Dutch (default)"), "{:?}", labels(&tree)); + // The caret is in Dutch now, so it is the bold row, and English can be set back. + assert!(spot(&tree, "Set as default").is_some()); + } } diff --git a/crates/ui-egui/src/options.rs b/crates/ui-egui/src/options.rs index 2e6a01864d..b2a3da0363 100644 --- a/crates/ui-egui/src/options.rs +++ b/crates/ui-egui/src/options.rs @@ -337,20 +337,17 @@ fn proofing(app: &mut WordApp, ui: &mut Ui) { ui.add_space(8.0); section(ui, "Custom dictionary"); custom_dictionary(app, ui); - ui.add_space(8.0); - section(ui, "Dictionaries"); - dictionaries(app, ui); } -/// Where the spelling dictionaries come from (#1063): a folder searched before the system's -/// usual places, saved with the settings, and the dictionary each language found. An app started -/// from Finder or the Dock doesn't see `WORDCRAFT_DICTIONARIES`, so this is how it finds a -/// dictionary kept in a folder of the user's own. -fn dictionaries(app: &mut WordApp, ui: &mut Ui) { +/// Your own dictionaries folder (#1063): searched before the system's usual places, saved with +/// the settings. An app started from Finder or the Dock doesn't see `WORDCRAFT_DICTIONARIES`, so +/// this is how it finds a dictionary kept in a folder of the user's own. Each language's status +/// ("Your own dictionary") is in Your languages above. +fn dictionaries_folder(app: &mut WordApp, ui: &mut Ui) { let saved = app.session.prefs.dictionaries_folder.clone().unwrap_or_default(); let id = egui::Id::unique("options_dictionaries_folder"); let mut folder = ui.data(|d| d.get_temp::(id)).unwrap_or_else(|| saved.clone()); - let folder_label = ui.label(tl!("Dictionaries folder:")).id; + let folder_label = ui.label(tl!("Folder:")).id; ui.horizontal(|ui| { let r = ui .add(egui::TextEdit::singleline(&mut folder).desired_width(320.0).hint_text(tl!("Not set: the system's usual places"))) @@ -372,64 +369,7 @@ fn dictionaries(app: &mut WordApp, ui: &mut Ui) { } }); ui.data_mut(|d| d.insert_temp(id, folder)); - note(ui, "Hunspell .aff and .dic files here (pl_PL, pt_BR, it_IT, hr_HR, tr_TR) are used before the system's."); - // The dictionary each language found, looked up again after the folder changes. - let found_id = egui::Id::unique("options_dictionaries_found"); - let generation = wordcraft_engine::proof::dictionary_generation(); - let cached = ui.data(|d| d.get_temp::<(u64, Vec<(String, Option, Option)>)>(found_id)).filter(|(g, _)| *g == generation); - let found = match cached { - Some((_, f)) => f, - None => { - let f: Vec<(String, Option, Option)> = wordcraft_engine::proof::installed_dictionaries() - .into_iter() - .map(|(lang, dic)| { - let error = wordcraft_engine::proof::dictionary_load_error(lang); - (language_name(lang).to_string(), dic.map(|d| d.to_string_lossy().into_owned()), error) - }) - .collect(); - ui.data_mut(|d| d.insert_temp(found_id, (generation, f.clone()))); - f - } - }; - for (language, file, error) in found { - let line = match (file, error) { - (Some(f), Some(e)) => crate::i18n::fmt( - tl!("{language}: {file} (unreadable: {reason})"), - &[("language", &language), ("file", &crate::i18n::isolate_path(&f)), ("reason", &e)], - ), - (Some(f), None) => crate::i18n::fmt(tl!("{language}: {file}"), &[("language", &language), ("file", &crate::i18n::isolate_path(&f))]), - (None, _) => crate::i18n::fmt(tl!("{language}: no dictionary found"), &[("language", &language)]), - }; - ui.add(egui::Label::new(RichText::new(line).small()).truncate()); - } -} - -/// The interface name of a language with a Hunspell dictionary. -fn language_name(lang: wordcraft_engine::proof::ProofLang) -> &'static str { - use wordcraft_engine::proof::ProofLang; - match lang { - ProofLang::Pl => tl!("Polish"), - ProofLang::Pt => tl!("Portuguese (Brazil)"), - ProofLang::It => tl!("Italian"), - ProofLang::Hr => tl!("Croatian"), - ProofLang::Tr => tl!("Turkish"), - ProofLang::Ru => tl!("Russian"), - ProofLang::Cs => tl!("Czech"), - ProofLang::Id => tl!("Indonesian"), - ProofLang::Es => tl!("Spanish (Spain)"), - ProofLang::EsMx => tl!("Spanish (Mexico)"), - ProofLang::Es419 => tl!("Spanish (Latin America)"), - ProofLang::EsUy => tl!("Spanish (Uruguay)"), - // English uses its bundled word list; Bulgarian and German have no dictionary yet. - ProofLang::En - | ProofLang::EnGb - | ProofLang::EnCa - | ProofLang::EnAu - | ProofLang::Bg - | ProofLang::De - | ProofLang::Pack(_) - | ProofLang::Other => "", - } + note(ui, "Hunspell .aff and .dic files here (pl_PL, pt_BR, it_IT, hr_HR, tr_TR) are used before Language packs and the system's."); } /// The custom dictionary: the words Add to Dictionary kept, each with a Remove button, and a @@ -519,7 +459,11 @@ fn language(app: &mut WordApp, ui: &mut Ui) { }; ui.label(RichText::new(text).small().weak()); ui.add_space(8.0); - crate::language_packs::options_section(app, ui); + crate::language_packs::your_languages_section(app, ui); + ui.add_space(8.0); + section(ui, "Your own dictionaries folder"); + dictionaries_folder(app, ui); + crate::language_packs::add_language_window(app, &ui.ctx().clone()); } /// Draws Accessibility options: the animation setting and Read Aloud speed and skip-citations. diff --git a/crates/ui-egui/src/options/tests.rs b/crates/ui-egui/src/options/tests.rs index 3bb85f05c8..166d111761 100644 --- a/crates/ui-egui/src/options/tests.rs +++ b/crates/ui-egui/src/options/tests.rs @@ -259,9 +259,11 @@ fn options_panes_open_and_change_settings() { assert_eq!(h.state().dialog.as_ref().map(|d| d.name()), Some("autoCorrect")); h.state_mut().dialog = None; h.run_steps(2); - // #1063: the dictionaries folder and the dictionary each language found. - assert!(h.query_by_label("Dictionaries folder:").is_some()); - assert!(h.query_by_label_contains("Polish: ").is_some(), "the Polish dictionary's line"); + // #1063: the dictionaries folder moved to Language (CP4.3); Proofing has no Dictionaries section. + assert!(h.query_by_label("Dictionaries folder:").is_none() && h.query_by_label("Folder:").is_none()); + h.get_by_label("Language").click(); + h.run_steps(4); + assert!(h.query_by_label("Folder:").is_some(), "Your own dictionaries folder"); h.get_by_label("Advanced").click(); h.run_steps(4); h.get_by_label("Typing replaces selected text").click(); diff --git a/crates/ui-egui/src/ribbon.rs b/crates/ui-egui/src/ribbon.rs index b54ae0576d..f172242cdf 100644 --- a/crates/ui-egui/src/ribbon.rs +++ b/crates/ui-egui/src/ribbon.rs @@ -47,13 +47,14 @@ use insert::insert; #[cfg(test)] pub(crate) use language::PROOFING_LANGUAGES; #[cfg(test)] +pub(crate) use language::all_languages; +#[cfg(test)] use language::language_checks; #[cfg(test)] pub(crate) use language::short_languages; -#[cfg(test)] -pub(crate) use language::{all_languages, sort_key}; +pub(crate) use language::sort_key; pub(crate) use language::{ - caret_language, caret_language_proofed, caret_missing_dictionary, caret_no_proof, caret_unreadable_dictionary, language_menu, + caret_lang_tag, caret_language, caret_language_proofed, caret_missing_dictionary, caret_no_proof, caret_unreadable_dictionary, language_menu, }; pub(crate) use language::{language_list, language_name, same_language, tag_for_pack}; use layout::layout; diff --git a/crates/ui-egui/src/ribbon/language.rs b/crates/ui-egui/src/ribbon/language.rs index ffe6d972ca..c5d17e2278 100644 --- a/crates/ui-egui/src/ribbon/language.rs +++ b/crates/ui-egui/src/ribbon/language.rs @@ -309,7 +309,7 @@ fn caret_char(app: &WordApp) -> wordcraft_doc::resolve::ResolvedChar { } /// The language tag at the caret, resolved through the styles and the document default. -fn caret_lang_tag(app: &WordApp) -> Option { +pub(crate) fn caret_lang_tag(app: &WordApp) -> Option { caret_char(app).lang } diff --git a/docs/gaps.md b/docs/gaps.md index bdf176ca66..538c78069d 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where WordCraft falls short of Word -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** trivial (#3 narrowed: a pasted text box story is charged for the formatting it copies); previously trivial (#3 narrowed: a .doc table row keeps one override per cell); previously trivial (#3 narrowed: a .doc file's sections find their paragraphs by index); previously minor (#11: Arabic interface with mirrored shell landed, #1195; hi/id/pt-PT and Hebrew UI remain); previously trivial (#8: language-packs-2 is published and pinned: 75 packs, adding Danish, German (Germany, Austria, Switzerland), Esperanto, Estonian, Persian, Croatian, Hungarian, Norwegian (Bokmål, Nynorsk), Dutch and Swedish (Sweden, Finland); no ranked gap changed); previously trivial (#8: language-packs-1 is published and pinned, 61 packs: Lithuanian, Romanian, Catalan, French, Greek, Slovak, Serbian and Latvian install as Language packs; Dutch, German and the other compounding languages wait on craft-proof; no ranked gap changed); previously minor (#8: Language packs: every other language's spelling and hyphenation installs from File › Options › Language or the missing-pack bar, through the font store; Lithuanian and Romanian are available as a Language pack once language-packs-1 is published; Dutch, Catalan, French, Greek, Slovak, Serbian and Latvian packs wait on craft-proof engine support); previously trivial (gap 8: English spelling reads SCOWL 2026, one dictionary per English, #40, #520, #5205; no ranked gap changed);; previously trivial (DOCX table rows and cells inside selected alternate-content branches survive open and repeated saves (#5219); broader corpus qualification and readiness estimates unchanged); previously trivial (#26 narrowed: MHT opens and `w:altChunk` content is brought in on open; saving MHT remains) previously trivial (gap 8 points at craft-proof in craft-libs, its data in craft-i18n, #5202; no ranked gap changed); previously trivial (arrowheads keep their kind, width and length and are drawn at Word's sizes; no ranked gap changed); previously trivial (.doc default font from the stylesheet's standard font, #5066; no ranked gap changed); previously trivial (a middle or bottom cell of a row split across pages lines up on the first page; no ranked gap changed); previously trivial (tab leader dots spaced and placed as in Word; no ranked gap changed); previously trivial (a list level above counts its first number at the first deeper item; no ranked gap changed); previously trivial (only the PDF sent to the printer leaves out link annotations; Save these pages as PDF keeps them, #4734; no ranked gap changed); previously trivial (documents with links print: the print job leaves out link annotations, #4734; no ranked gap changed; previously trivial: aligned-copy review fixes retain the document axis through scrolling and include secondary selections (#4764)); previously trivial (connector rerouting indexes laid-out object positions once per batch (#3631); previously trivial (custom-property bookmark-link preservation, #4767); previously trivial (Relative font-size commands preserve mixed sizes in the selection (#4903); existing button steps and one-point shortcuts are unchanged; readiness estimates unchanged); previously trivial (Arabic Backspace removes one combining mark and keeps its base letter (#4757); previously trivial (note conversion reference-run membership uses one ordered walk, #4750); previously trivial (DOCX comment-ID save lookups); previously trivial (gap 19: RTF reads and writes WMF and EMF pictures, #4259); previously trivial (#4658 bounds nested Markdown reference-label work); previously trivial (HTML import keeps preformatted lines with CR or CRLF input newlines, #4810); previously trivial (Recipient labels continue across product-sized sheets instead of stopping after the first sheet (#4880)); previously trivial (View windows: several open documents and Switch Windows in the engine; previously trivial: explicit documents keep the editor when recovery discovery finishes; readable recovery controls; previously trivial: text mini toolbar available with the right-click menu, #2959; previously trivial: personal templates in File › New and Save as Word Template, #2852; previously trivial: tracked table/row/cell/section property changes record in WordCraft, narrowing gap 5; previously trivial: a document with many content controls saves in the time the controls take, #13; previously trivial: Format Page Numbers dialog carries Word's number formats and Continue from previous section / Start at, #1113; previously trivial: centred list labels after leading page breaks, #2964; previously trivial: fixed font inputs in four layout controls; previously trivial: a right, centre or decimal tab whose text doesn't fit, or a left tab past the right indent, goes to the next line with its text, #1840; previously trivial: Bullets and Numbering toggle off style-inherited lists at their effective level, including basedOn chains and numbered ListParagraph styles; other paragraphs and list definitions stay unchanged (related to #3459); previously trivial: Russian sorting keeps ё with е and recognises decomposed ё/й; previously trivial: #8: English dialects — en-GB, en-CA, en-AU… flag each other's spellings, #1281; previously trivial: #1: shape gradients and transparency, #1500; previously trivial: text typed into a content control takes the control's formatting; localized placeholder styles recognised; previously trivial: forms protection keeps its content controls: no inserting, Properties or Remove Content Control; previously trivial: clearing a no-match font query keeps the recent heading visible, #2068; previously trivial: line breaking: a slash opening a word travels whole to the next line, #2963; previously trivial: recipient list search and merged-only view, #1576; previously trivial: #2 impact restated: only ink rendering and OLE editing remain; previously trivial: #2 narrowed: native ink nested in groups and drawing canvases kept on save; previously trivial: opening a DOCX no longer copies its pictures; previously trivial: RTF export writes sections (gap 19); previously trivial: ODT export writes sections (gap 19); previously trivial: automatic Asian/Latin and Asian/number spacing laid out, #2358; previously trivial: hint-reliant CJK outlines; previously trivial: numbered headings, #1793; previously trivial: legacy outline, shadow, emboss and imprint text effects drawn, #2534; previously trivial: #8 narrowed: Indonesian proofing from the installed Hunspell dictionary, #498; previously trivial: glossary/building blocks closed; previously trivial: Split Cells and Convert Text to Table follow the Word check, #2592; previously trivial: Language dialog keeps inherited proofing language and no-proof choices (#2717); previously trivial: #29: a copied equation also goes in the MathML clipboard formats, #1297; previously trivial: #24: the Spike, Ctrl+F3 and Ctrl+Shift+F3; previously trivial: VML freeforms read and kept on save; previously trivial: consistent preferred cell widths; previously trivial: multi-paragraph field instructions no longer add blank lines; previously trivial: page-break-only list paragraphs hide their labels; previously trivial: floating-table overlap ignores empty line-break lines; previously trivial: copies keep their formatting on the clipboard as HTML, #1523; previously trivial: sample-text formulas on Enter, #1067; previously trivial: #29: copied equations as MathML, OMML open as #1297, #816; previously trivial: the Font list no longer keeps every previewed font in memory, #848; previously trivial: table column and row markers on the rulers, #700; previously trivial: table borders and the resize handle drag on the page, #217; previously trivial: formatting revisions landed, #41; previously trivial: Draw Table and Eraser landed, #303; previously minor: beta distance restated: ~15 points, ~150–230 h; previously: first version; every known shortfall from the 2026-10-10 re-measure, ranked) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** trivial (#8: Options › Language lists Your languages and Add a language… replaces the Language packs table); previously trivial (#8: language-packs-2 is published and pinned: 75 packs, adding Danish, German (Germany, Austria, Switzerland), Esperanto, Estonian, Persian, Croatian, Hungarian, Norwegian (Bokmål, Nynorsk), Dutch and Swedish (Sweden, Finland)) > **Highlight update:** 2026-10-25 · Highlight shortcut toggles the last chosen colour off when the whole selection has it; explicit colour commands remain setters (#4085). Readiness estimates unchanged. > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-29 · **Change:** trivial (aligned-copy review fixes retain the document axis through scrolling and include secondary selections (#4764)); previously trivial (#15: bibliography sources keep a corporate author, #4848); previously trivial (Table Properties applies to the selected rows, columns and cells, #4857); previously trivial (Relative font-size commands preserve mixed sizes in the selection (#4903); existing button steps and one-point shortcuts are unchanged; readiness estimates unchanged); previously trivial (Arabic Backspace removes one combining mark and keeps its base letter (#4757); previously trivial (Recipient labels continue across product-sized sheets instead of stopping after the first sheet (#4880)); previously trivial (#7: Custom Document Properties dialog, #2982; previously trivial: egui 0.37 migration: the interface catalogs stay shared and pinned by `craft-i18n.rev` at `9205108cfdced5177706264038848b68b2422d2b` (27 languages, English fallback); input-method handling has new regressions but managed CI passed, and native IME acceptance plus native-speaker catalog review remain open; previously trivial: Markdown code spans keep line-broken text literal, #3738; previously trivial: small follow-ups from the field, table and AutoFormat batch, #4232; previously trivial: highlight target includes selected paragraph marks, #4085; previously trivial: full-target highlight check beyond 10,000 runs, #4085; previously trivial: Exact-spacing table contact uses the specified line height rather than paragraph-mark metrics (#3977); previously trivial: cu20we: restrict pre-spacing float origins to paragraph anchors; document cap helpers and regressions; previously trivial: a command that changes nothing is not an edit: no undo step, no unsaved changes, no relayout, and the redo stack survives it; previously minor: #8 narrowed: Spanish proofing (Spain, Mexico, Latin America, Uruguay) from the installed Hunspell dictionaries, #3360, #3553; previously trivial: gap 10: group connector rerouting preserves transformed free and unresolved endpoints under nonuniform scaling; obstacle routing still missing; readiness estimates unchanged; previously trivial: a word with no break opportunity in it no longer makes the layout quadratic, #3412; previously trivial: the ranked gap list held two rows each for #19, #20 and #21; each gap appears once now; a document with many relationships opens in the time its part takes, #3411; previously trivial: the file commands that change the document are checked on a protected document, the protection of a protected document needs an explicit stop, the session author can't change through `file.setAuthor` under protection (the CLI's `--author` uses the same protection check), and the post-check compares the settings and the metadata; previously trivial: explicit documents keep the editor when recovery discovery finishes; readable recovery controls; previously trivial: text mini toolbar available with the right-click menu, #2959; previously trivial: personal templates in File › New and Save as Word Template, #2852; previously trivial: tracked table/row/cell/section property changes record in WordCraft, narrowing gap 5; previously trivial: a document with many content controls saves in the time the controls take, #13; previously trivial: Format Page Numbers dialog carries Word's number formats and Continue from previous section / Start at, #1113; previously trivial: centred list labels after leading page breaks, #2964; previously trivial: fixed font inputs in four layout controls; previously trivial: a right, centre or decimal tab whose text doesn't fit, or a left tab past the right indent, goes to the next line with its text, #1840; previously trivial: Bullets and Numbering toggle off style-inherited lists at their effective level, including basedOn chains and numbered ListParagraph styles; other paragraphs and list definitions stay unchanged (related to #3459); previously trivial: Russian sorting keeps ё with е and recognises decomposed ё/й; previously trivial: #8: English dialects — en-GB, en-CA, en-AU… flag each other's spellings, #1281; previously trivial: #1: shape gradients and transparency, #1500; previously trivial: text typed into a content control takes the control's formatting; localized placeholder styles recognised; previously trivial: forms protection keeps its content controls: no inserting, Properties or Remove Content Control; previously trivial: clearing a no-match font query keeps the recent heading visible, #2068; previously trivial: line breaking: a slash opening a word travels whole to the next line, #2963; previously trivial: recipient list search and merged-only view, #1576; previously trivial: #2 impact restated: only ink rendering and OLE editing remain; previously trivial: #2 narrowed: native ink nested in groups and drawing canvases kept on save; previously trivial: opening a DOCX no longer copies its pictures; previously trivial: RTF export writes sections (gap 19); previously trivial: ODT export writes sections (gap 19); previously trivial: automatic Asian/Latin and Asian/number spacing laid out, #2358; previously trivial: hint-reliant CJK outlines; previously trivial: numbered headings, #1793; previously trivial: legacy outline, shadow, emboss and imprint text effects drawn, #2534; previously trivial: #8 narrowed: Indonesian proofing from the installed Hunspell dictionary, #498; previously trivial: glossary/building blocks closed; previously trivial: Split Cells and Convert Text to Table follow the Word check, #2592; previously trivial: Language dialog keeps inherited proofing language and no-proof choices (#2717); previously trivial: #29: a copied equation also goes in the MathML clipboard formats, #1297; previously trivial: #24: the Spike, Ctrl+F3 and Ctrl+Shift+F3; previously trivial: VML freeforms read and kept on save; previously trivial: consistent preferred cell widths; previously trivial: multi-paragraph field instructions no longer add blank lines; previously trivial: page-break-only list paragraphs hide their labels; previously trivial: floating-table overlap ignores empty line-break lines; previously trivial: copies keep their formatting on the clipboard as HTML, #1523; previously trivial: sample-text formulas on Enter, #1067; previously trivial: #29: copied equations as MathML, OMML open as #1297, #816; previously trivial: the Font list no longer keeps every previewed font in memory, #848; previously trivial: table column and row markers on the rulers, #700; previously trivial: table borders and the resize handle drag on the page, #217; previously trivial: formatting revisions landed, #41; previously trivial: Draw Table and Eraser landed, #303; previously minor: beta distance restated: ~15 points, ~150–230 h; previously: first version; every known shortfall from the 2026-10-10 re-measure, ranked) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4 Recovery discovery no longer interrupts an explicitly created or opened document. Older copies remain in File › Recover, whose buttons use the interface palette. See [local recovery](recovery.md). @@ -156,6 +156,7 @@ Table rows and cells inside `mc:AlternateContent` use the same selected-branch p | Date | Change | Summary | |---|---|---| | 2026-11-03 | minor | #11: Arabic interface with mirrored shell (#1195); key languages missing are now hi and id (plus pt-PT); Hebrew UI still open | +| 2026-11-03 | trivial | #8 (CP4.3): File › Options › Language lists Your languages and Add a language… (searchable, sorted by name) replaces the Language packs table; dictionaries folder moved from Proofing | | 2026-11-03 | trivial | #8: language-packs-2 published and pinned, 75 packs; Danish, German, Dutch, Swedish, Norwegian, Hungarian, Estonian, Croatian, Persian and Esperanto available as Language packs | | 2026-11-02 | trivial | #8 (CP4.4): language-packs-1 published and pinned, 61 packs; Lithuanian, Romanian, Catalan, French, Greek, Slovak, Serbian and Latvian available as Language packs; Dutch, German and the other compounding languages wait on craft-proof; Basque, Ukrainian and Uyghur excluded; no ranked gap changed | | 2026-11-02 | trivial | Gap 8's evidence: English spelling reads the SCOWL 2026 dictionaries, one per English (en-US, British-spelling via en-GB, en-CA), with regression tests for #40 (British words in en-GB) and #520 (common modern words); #40 is no longer listed as open (#5205). No ranked gap changed. | diff --git a/docs/localization-parity.md b/docs/localization-parity.md index 65a09d3876..d34ee97800 100644 --- a/docs/localization-parity.md +++ b/docs/localization-parity.md @@ -1,6 +1,6 @@ # Localization parity with Microsoft Word -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** trivial (Language lists: every installed and available Language pack's language can be chosen in Set Proofing Language, installed ones in Review › Language and the status bar; every published pack has an English name); previously trivial (Language packs: language-packs-2 is published and pinned: 75 packs, adding Danish, German (Germany, Austria, Switzerland), Esperanto, Estonian, Persian, Croatian, Hungarian, Norwegian (Bokmål, Nynorsk), Dutch and Swedish (Sweden, Finland)); previously trivial (Language packs: language-packs-1 is published and pinned, 61 packs; the language requests it covers); previously minor (Language packs: languages beyond English install their spelling dictionary and hyphenation as a pack from File › Options › Language or the missing-pack bar; the default build embeds English Language data only); previously minor (English spelling reads SCOWL 2026 per English, CP2; previously trivial: proofing file paths point at craft-proof in craft-libs and craft-i18n `language-data/`, #5202; previously trivial: word count counts each Han ideograph and kana as a word, #4547; previously trivial: the Traditional Chinese interface draws hanzi to the Taiwan standard with an installed Traditional Chinese font first: PingFang TC, Microsoft JhengHei, Noto Sans CJK TC; previously minor: the egui 0.37 migration preserves the equation “Delete Around Caret in Equation” translation in all 27 catalogs through the shared catalog pin; previously minor: Spanish proofing: es-ES, es-MX, es-419 and es-UY from the installed Hunspell dictionaries, Uruguayan `vos` forms, opening `¿`/`¡` checks, #3360, #3553; previously minor: the interface catalogs moved to storytold/craft-i18n and are looked up through the `craft-i18n` crate, embedded at build time from the commit in `craft-i18n.rev`; previously trivial: interface-language tests: a missing translation never fails a test, `cargo xtask i18n-report` in `cargo xtask ci` prints the strings each language lacks, and lookup and template tests use inline fixture catalogs or the pseudo-language; previously trivial: interface audit: missing catalog entries are reported per language and don't fail the audit; previously minor: disabled-control reasons in ribbon hints translated in every catalog, #2678; previously trivial: Slovenian interface catalog: every key of every other catalog, 2,614 entries; previously minor: Romanian interface catalog; previously trivial: the File › Home greeting is translated in every catalog; previously trivial: Japanese row: ruby (Phonetic Guide) is supported and HTML export/import keeps it, #1681; previously trivial: Russian sorting keeps ё with е and recognises decomposed ё/й; previously minor: English dialects: en-GB, en-CA, en-AU and the other British-spelling Englishes proof their own spellings and flag the other dialect's, #1281, #1045; previously minor: how to install the Hunspell dictionaries on Windows, macOS and Linux: `docs/spelling-dictionaries.md`; previously minor: Read Aloud speaks each sentence in its own language, #1843; previously minor: Indonesian proofing: id-ID spelling from the installed Hunspell dictionary, dictionary-driven suggestions, generic checks with Indonesian messages, #498; previously trivial: print-area strings translated in every catalog; previously trivial: Italian: the interface audit checks the Italian catalog, `Privacy Settings` wording; previously trivial: Italian grammar: `po'`, `qual è`, `È`, `un`/`un'` rules; more elisions and truncations in spelling; previously trivial: Czech interface catalog completed, 2,447 entries; previously trivial: interface audit runs in CI again: size labels translated, 20 strings in every catalog, Read Aloud error race fixed, #1128; previously trivial: Review › Language reaches every language again — Set Proofing Language… and Set As Default, #860; previously minor: Italian proofing: it-IT spelling from the installed Hunspell dictionary, accent-first suggestions, conservative grammar with Italian messages; previously minor: Portuguese proofing; previously trivial: Turkish interface catalog completed, 2,325 entries, #774; previously minor: Hungarian interface added; previously trivial: sorting and table numbers follow the text's language, #836, #837; previously minor: Polish interface; Polish proofing — spelling, grammar, hyphenation — and a proofing language per run; previously minor: Turkish interface added; previously major: first version; catalogs measured from `crates/ui-egui/src/i18n`, Word's languages from its bundle listing) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** trivial (Options › Language redesign: Your languages, Add a language…, Set as default; dictionaries folder moved from Proofing); previously trivial (Language lists: every installed and available Language pack's language can be chosen in Set Proofing Language, installed ones in Review › Language and the status bar) Interface languages, script support and proofing per language. How translation works (adding a language, the embedded catalogs): `crates/ui-egui/src/i18n.rs`. The catalogs, their format and @@ -130,9 +130,9 @@ Set Proofing Language › Set As Default keeps the chosen language in user prefe | Language | Spelling | Suggestions | Grammar | Hyphenation | |---|---|---|---|---| -| English: American (`en-US`, other regions, text with no language), British spelling (`en-GB`, `en-AU`, `en-NZ`, `en-IE`, `en-ZA`, `en-IN`…), Canadian (`en-CA`) | SCOWL 2026 (`rel-2026.02.25`, size 60) Hunspell dictionaries, one per English: en-US, en-GB `-ise` (also the other British-spelling Englishes) and en-CA, embedded from craft-i18n `language-data/` and read by the affix engine (ordinals such as `21st` and `112th` by `COMPOUNDRULE`). A word is right when the English's own dictionary or our supplement (`en-extra.txt`) knows it (never because another English's does: `colourblind` is wrong in en-US), unless our list of ~280 American/British pairs (craft-i18n [`language-data/en-us/en-variants.txt`](https://github.com/storytold/craft-i18n/blob/main/language-data/en-us/en-variants.txt)) marks it as the other dialect's: each English flags the other dialect's spellings (`colour` in en-US; `color`, `center`, `analyze` in en-GB; `organise` in en-CA), British English accepts `-ize` and `-ise` (Oxford spelling, as Word does; SCOWL's en-GB `-ise` alone would flag `organize`), and a dialect's form of a known word is right even if the list lacks it (`realisation`). Text with no language takes any English's word. An English Hunspell dictionary in File › Options › Proofing › Dictionaries folder comes first (the document's own English); without the SCOWL files, an installed Hunspell English, then the Moby word list (public domain, ~165k words) built into craft-proof. No system dictionary needed | the dialect's own spelling first (`colour` → `color`), then the dialect's SCOWL dictionary's suggestions (its TRY/REP tables, one typo, a stem scan; a missing space only between two words of 3+ letters, last), in the dialect's spelling | repeated word, `a`/`an`, sentence capital, space before punctuation, double space | Moby dictionary, our Liang patterns, heuristic | +| English: American (`en-US`, other regions, text with no language), British spelling (`en-GB`, `en-AU`, `en-NZ`, `en-IE`, `en-ZA`, `en-IN`…), Canadian (`en-CA`) | SCOWL 2026 (`rel-2026.02.25`, size 60) Hunspell dictionaries, one per English: en-US, en-GB `-ise` (also the other British-spelling Englishes) and en-CA, embedded from craft-i18n `language-data/` and read by the affix engine (ordinals such as `21st` and `112th` by `COMPOUNDRULE`). A word is right when the English's own dictionary or our supplement (`en-extra.txt`) knows it (never because another English's does: `colourblind` is wrong in en-US), unless our list of ~280 American/British pairs (craft-i18n [`language-data/en-us/en-variants.txt`](https://github.com/storytold/craft-i18n/blob/main/language-data/en-us/en-variants.txt)) marks it as the other dialect's: each English flags the other dialect's spellings (`colour` in en-US; `color`, `center`, `analyze` in en-GB; `organise` in en-CA), British English accepts `-ize` and `-ise` (Oxford spelling, as Word does; SCOWL's en-GB `-ise` alone would flag `organize`), and a dialect's form of a known word is right even if the list lacks it (`realisation`). Text with no language takes any English's word. An English Hunspell dictionary in File › Options › Language › Your own dictionaries folder comes first (the document's own English); without the SCOWL files, an installed Hunspell English, then the Moby word list (public domain, ~165k words) built into craft-proof. No system dictionary needed | the dialect's own spelling first (`colour` → `color`), then the dialect's SCOWL dictionary's suggestions (its TRY/REP tables, one typo, a stem scan; a missing space only between two words of 3+ letters, last), in the dialect's spelling | repeated word, `a`/`an`, sentence capital, space before punctuation, double space | Moby dictionary, our Liang patterns, heuristic | | Russian (`ru`) | A Russian Hunspell dictionary installed on the system (`ru_RU` from the OS, a package manager, LibreOffice's `dict-ru` or the `WORDCRAFT_DICTIONARIES` folder; UTF-8, KOI8-R or Windows-1251; not bundled, so no Russian spelling marks without it), read by the same affix engine; `ё` optional (`елка`/`ёлка`, `еще`/`ещё`); hyphenated words whole, then by parts (`кто-то`, `по-русски`, `кое-где`, `северо-западный`, `ИИ-консультант`); solid compounds (`высокоэластичный`), `не` with adjectives, participles and verbal nouns (not verbs), productive prefixes (`ультра-`, `эко-`) and prefixed verbs; abbreviations with endings (`ГИПа`) and camel case left alone; our supplement of ~200 modern words with their declensions (craft-i18n [`language-data/ru/ru-extra.txt`](https://github.com/storytold/craft-i18n/blob/main/language-data/ru/ru-extra.txt): `маркетплейс`, `промокод`, `интеграция`, `колеровать`) | `ё`/`е` first, then slips within letter groups (unstressed vowels, voiced and voiceless pairs, `ь`/`ъ`), the common confusions (`жы`, `чя`, `тся`/`ться`, doubled consonants, unpronounced consonants: `здраствуй` → `здравствуй`), a missing space (`незнаю` → `не знаю`; not a preposition before a verb), one typo, then a stem scan | Russian messages: repeated word, space before punctuation, double space, sentence capital (knows `т. е.`, `г.`, `руб.`, `ул.`, initials, numbers, dialogue dashes), possibly missing comma before `что`/`чтобы`/`если`/`хотя`/`поскольку`/`который` and before `потому что` (not after conjunctions and particles such as `и`, `только`, `даже`, `так`, `для того`; not after a preposition; not in `хотя бы`, `что-то`), doubled punctuation | The rules of Russian word division as code (no pattern file): a vowel on each side, two letters at least, `ь`/`ъ`/`й` kept with the letter before, a break after `ъ`, a consonant cluster divided after its first consonant | -| Polish (`pl`) | The Hunspell `pl_PL` dictionary installed on the system (OS package, Homebrew, LibreOffice, the folder set in File › Options › Proofing › Dictionaries folder, or `WORDCRAFT_DICTIONARIES`; not bundled, so no Polish spelling marks without it; the same pane shows which file each language found), read at runtime by a Hunspell-style affix engine (craft-proof [`src/affix.rs`](https://github.com/storytold/craft-libs/blob/main/crates/proof/src/affix.rs) in craft-libs); names capitalized, compounds part by part, `Kennedy'ego` | missing diacritics first (`zolw` → `żółw`), the dictionary's confusion table (`żeka` → `rzeka`, `chuśtawka` → `huśtawka`), missing space (`napewno` → `na pewno`), one typo, then a stem scan within two typos | Polish messages: repeated word, space before punctuation, double space, sentence capital (knows `np.`, `r.`, initials, ordinals, dialogue dashes), missing comma before `że`/`który`/`ponieważ`/`gdyż`/`aby`/`żeby`/`jeśli`/`jeżeli`/`gdyby`/`lecz` (not after `mimo`, `chyba`, `tak`, prepositions…), `we`/`ze` (`we wtorek`, `ze szkoły`), doubled punctuation | TeX Polish patterns (Kołodziejska, Jackowski, Ryćko; MIT option) with their 20 exception words; a Polish syllable heuristic for letters outside the alphabet | +| Polish (`pl`) | The Hunspell `pl_PL` dictionary installed on the system (OS package, Homebrew, LibreOffice, the folder set in File › Options › Language › Your own dictionaries folder, or `WORDCRAFT_DICTIONARIES`; not bundled, so no Polish spelling marks without it; the same pane shows which file each language found), read at runtime by a Hunspell-style affix engine (craft-proof [`src/affix.rs`](https://github.com/storytold/craft-libs/blob/main/crates/proof/src/affix.rs) in craft-libs); names capitalized, compounds part by part, `Kennedy'ego` | missing diacritics first (`zolw` → `żółw`), the dictionary's confusion table (`żeka` → `rzeka`, `chuśtawka` → `huśtawka`), missing space (`napewno` → `na pewno`), one typo, then a stem scan within two typos | Polish messages: repeated word, space before punctuation, double space, sentence capital (knows `np.`, `r.`, initials, ordinals, dialogue dashes), missing comma before `że`/`który`/`ponieważ`/`gdyż`/`aby`/`żeby`/`jeśli`/`jeżeli`/`gdyby`/`lecz` (not after `mimo`, `chyba`, `tak`, prepositions…), `we`/`ze` (`we wtorek`, `ze szkoły`), doubled punctuation | TeX Polish patterns (Kołodziejska, Jackowski, Ryćko; MIT option) with their 20 exception words; a Polish syllable heuristic for letters outside the alphabet | | Portuguese (`pt`, any region) | The Hunspell `pt_BR` dictionary installed on the system — VERO and its derivatives (same places as Polish; not bundled, LGPL/MPL), read at runtime by the same affix engine, which reads its `FLAG UTF-8`, 106 flags, continuation classes and `FORBIDDENWORD` spellings; names capitalized, compounds part by part (`guarda-roupa`, `ex-marido`) | missing accents first (`coraçao` → `coração`, `saude` → `saúde`), the dictionary's confusion table (`seje` → `seja`, `excessão` → `exceção`), missing space (`nãoé` → `não é`), one typo, then an accent-folding stem scan | Portuguese messages: repeated word (the emphatic doubles are allowed), space before punctuation, double space, sentence capital (knows `etc.`, `pág.`, `Dr.`, initials, ordinals, dialogue dashes), doubled punctuation; no comma rule — `que` opens a clause only sometimes | TeX Portuguese patterns (Rezende, Almeida, Araujo, Benevides; BSD 3-clause) with their 2 exception words | | Czech (`cs`, `cs-CZ`, `ces`, `cze`) | The system Hunspell `cs_CZ` dictionary, read at runtime (Debian/Ubuntu: `hunspell-cs`; the same system, LibreOffice and `WORDCRAFT_DICTIONARIES` search paths as Polish). No dictionary data is bundled; without an installed dictionary spelling stays off | suggestions from the loaded dictionary's MAP/REP/TRY/KEY tables, missing spaces and a stem scan; short-word splits rank after deleting an extra letter; NOSUGGEST stems and their derived forms are accepted when typed but excluded from suggestions | Czech messages (including Czech quotation marks) for repeated words, space before punctuation and double spaces only; digit-space-colon-space-digit ratios keep their spaces; no Czech-specific grammar rules | existing English fallback, as for `Other`; no Czech patterns bundled (the TeX/LibreOffice Czech patterns are GPL-2) | | Italian (`it`, any region) | The Hunspell `it_IT` dictionary installed on the system (same places as Polish and Portuguese; not bundled — the upstream file is GPL-licensed), read at runtime by the same affix engine; elided forms check the word after the apostrophe (`l'amico`, `un'idea`, `c'è`, `dov'è`, `senz'altro`), truncations keep their apostrophe (`po'`, `mo'`), hyphenated compounds part by part | missing accents first (`caffe` → `caffè`, `perche` → `perché`), the dictionary's confusion table, missing space (`perme` → `per me`), one typo, then an accent-folding stem scan | Italian messages: repeated word (emphatic doubles like `piano piano` are allowed), space before punctuation, double space, sentence capital (knows `ecc.`, `dott.`, `prof.`, initials, ordinals), doubled punctuation, `un pò` → `un po'`, `qual'è` → `qual è`, `E'` → `È`, `un'altro` → `un altro` and `un altra` → `un'altra` (gender from the ending, masculine `-ista`/`-ma`/`-cida`… left alone); these work without a dictionary; no comma rule | TeX Italian patterns (Beccari; MIT option), no exception words | @@ -170,9 +170,11 @@ pack** (its spelling dictionary, hyphenation patterns and licence texts), listed pinned pack index and installed through the font store into `/language-packs//` ([installing languages](spelling-dictionaries.md#language-packs)): -- File › Options › Language lists the installed and available packs with name, size, licence and - source, and installs or removes them (`proof.packs`, `proof.installPack`, `proof.removePack` for - agents). A pack is read at once; the lookup order is the dictionaries folder, the installed pack, +- File › Options › Language › Your languages lists English, the installed packs and the + document's languages with each one's proofing status, and installs, removes or sets the default + (Set as default); Add a language… opens a searchable list of the other packs with name, size, + licence and source (`proof.packs` with its `languages` rows, `proof.installPack`, + `proof.removePack` for agents). A pack is read at once; the lookup order is the dictionaries folder, the installed pack, then the system's Hunspell dictionaries. - A document with text in a language whose pack is available but not installed shows a bar offering it; it never shows for a language without a pack, and closes per document. @@ -264,6 +266,7 @@ WordCraft keeps 2,54 cm). | Date | Change | Summary | |---|---|---| | 2026-11-03 | minor | Arabic (`ar`) interface: ~2,730 catalog rows from craft-i18n, `ar-*` locales, mirrored shell (ribbon, panes, File page, dialogs, menus), Arabic UI font fallback, document canvas independent (#1195); 28 languages; Hebrew UI still open | +| 2026-11-03 | minor | Options › Language redesign (CP4.3): Your languages shows where each language's proofing comes from (Built in, Installed, Your own dictionary, Install, Grammar built in, Not available yet); Add a language… replaces the Language packs table and Show available languages; Set as default; the dictionaries folder moved from Proofing | | 2026-11-03 | trivial | Language lists: Set Proofing Language, Review › Language and the status bar offer the Language pack languages (Bulgarian was in none); every published pack named in English (Belarusian) | | 2026-11-03 | trivial | Language packs: language-packs-2 published and pinned, 75 packs, with Danish, German, Dutch, Swedish, Norwegian, Hungarian, Estonian, Croatian, Persian and Esperanto | | 2026-11-02 | trivial | Language packs (CP4.4): language-packs-1 published and pinned, 61 packs; Lithuanian, Romanian, Catalan, French, Greek, Slovak, Serbian and Latvian available; Dutch, German and the other compounding languages wait on craft-proof; Basque, Ukrainian and Uyghur excluded | @@ -295,7 +298,7 @@ WordCraft keeps 2,54 cm). | 2026-10-14 | trivial | Print area translated in all 18 interface catalogs (printer list, duplex, grayscale, discovery/submission feedback, print commands) — 18 strings that shipped English-only with the craft-print integration; written from the English meaning, pending native-speaker review like the rest of the catalogs | | 2026-10-14 | trivial | Italian: the interface audit's catalog check covers Italian too, as it does Russian, Hungarian, Turkish and Bulgarian; `Privacy Settings` no longer says "current" ("attuali"); a test pins the envelope size labels #1128 made translatable (Italian inches, the region's decimal comma) | | 2026-10-14 | minor | Italian grammar rules that work without a dictionary: `un pò`/`un po` → `un po'`, `qual'è` → `qual è`, `E'` → `È`, `un'` only before feminine words (`un'altro` → `un altro`, `un altra` → `un'altra`, also `nessun`/`ciascun`/`qualcun`/`alcun`); spelling accepts more elisions (`dov'è`, `anch'io`, `senz'altro`, `nessun'altra`) and truncations (`po'`, `mo'`) and leaves `pò`/`qual'è` to grammar so they aren't marked twice; more emphatic doubles allowed | -| 2026-10-12 | minor | File › Options › Proofing › Dictionaries folder (#1063): a saved folder of Hunspell dictionaries searched first, so an app started from Finder or the Dock finds them without `WORDCRAFT_DICTIONARIES`; the pane lists the dictionary file each language found — Polish, Portuguese, Italian, Croatian, Turkish (`file.options` `dictionariesFolder`) | +| 2026-10-12 | minor | File › Options › Language › Your own dictionaries folder (#1063): a saved folder of Hunspell dictionaries searched first, so an app started from Finder or the Dock finds them without `WORDCRAFT_DICTIONARIES`; the pane lists the dictionary file each language found — Polish, Portuguese, Italian, Croatian, Turkish (`file.options` `dictionariesFolder`) | | 2026-10-12 | minor | Czech interface catalog completed: 386 entries added (2,447 total), including built-in style names, numbered families, equation gallery, watermarks, paper sizes and preview tiles; coverage test requires every Russian and Spanish key and retains Chinese coverage | | 2026-10-14 | minor | Italian interface reviewed by a native speaker: Word names for tabs and commands, consistent terms (input penna, Disponi testo, Ombreggiatura), imperatives for commands | | 2026-10-12 | minor | Italian proofing: it-IT spelling from the installed Hunspell dictionary (system `it_IT`, never bundled — upstream is GPL), accent-first suggestions, conservative grammar with Italian messages, TeX Italian hyphenation patterns (MIT option); Review › Language already offered Italian; an `it` interface writes it-IT documents | diff --git a/docs/mcp.md b/docs/mcp.md index e3d5f3cea4..f05e884a22 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -134,7 +134,7 @@ command returns `"started": true` at once, and `proof.packs` shows it under `ins pack's install ends. Headless, they act on the same font store folder and return when done. The web build has no packs. -A click or key sent with `click`/`key` on Install, Show available languages or Refresh never turns +A click or key sent with `click`/`key` on Add a language…, Install or Refresh never turns downloading on either: only the person's own click does; the app shows why instead. Installing reads the pinned index of craft-i18n's language-packs-2 release (75 languages). For diff --git a/docs/spelling-dictionaries.md b/docs/spelling-dictionaries.md index 596e7e6ecb..d89989f5ca 100644 --- a/docs/spelling-dictionaries.md +++ b/docs/spelling-dictionaries.md @@ -1,6 +1,6 @@ # Installing languages and spelling dictionaries -> **Last reviewed:** 2026-10-16 · **Last updated:** 2026-11-03 · **Change:** trivial (Language packs: language-packs-2 is published and pinned: 75 packs, adding Danish, German (Germany, Austria, Switzerland), Esperanto, Estonian, Persian, Croatian, Hungarian, Norwegian (Bokmål, Nynorsk), Dutch and Swedish (Sweden, Finland); Mongolian and Thai aren't packs yet); previously trivial (Language packs: the first set, language-packs-1, is published and pinned: 61 languages, and which aren't packs yet); previously minor (Language packs: install a language's spelling and hyphenation from File › Options › Language, or from the bar a document in that language shows; they are searched after the dictionaries folder and before the system's dictionaries; previously trivial: the Flatpak's own dictionaries folder; previously trivial: WordCraft's own dictionaries folder is searched on macOS and Linux too, as on Windows, so a dictionary dropped there works without a setting; previously minor: ISO 8859-9 Turkish dictionaries are read, #3692; previously minor: Spanish: `es_ES`, `es_MX`, `es_419` and `es_UY` with their fallbacks, #3360, #3553; previously trivial: every Hunspell language shows (no dictionary), not only Polish and Portuguese, and Indonesian is listed, #3150; previously trivial: ISO 8859-1 dictionaries are read, #2824) +> **Last reviewed:** 2026-10-16 · **Last updated:** 2026-11-03 · **Change:** trivial (Language packs are installed from Your languages and Add a language…; the dictionaries folder is in Options › Language); previously trivial (Language packs: language-packs-2 is published and pinned: 75 packs, adding Danish, German (Germany, Austria, Switzerland), Esperanto, Estonian, Persian, Croatian, Hungarian, Norwegian (Bokmål, Nynorsk), Dutch and Swedish (Sweden, Finland)) English spelling works out of the box. Polish, Russian, Portuguese, Czech, Italian, Croatian, Turkish, Indonesian and Spanish spelling use a standard **Hunspell** dictionary (an `.aff` and a `.dic` file) that @@ -27,14 +27,18 @@ built in; every other language is a pack. > split Thai text, which has no spaces, into words). Basque, > Ukrainian and Uyghur aren't packs: their data's licence doesn't allow it, or isn't clear. -- **File › Options › Language › Language packs** lists the packs, each with its size, its licence - and a link to where it comes from. Click **Install** next to a language; **Remove** takes it out - again. The first time, click **Show available languages** to get the list. +- **File › Options › Language › Your languages** lists English, the languages of the open + document and every installed pack, each with where its proofing comes from (*Built in*, + *Installed*, *Your own dictionary*, *Not available yet*). **Install** gets a document language's + pack; **Remove** takes an installed one out; **Set as default** makes it the language new text is + written in. **Add a language…** opens a list of the other packs: type *dutch*, *nederlands* or + *nl* to search, see each pack's size, licence and a link to where it comes from, and click + **Install**. - When a document has text in a language whose pack isn't installed, a bar under the ribbon says *Dutch proofing isn't installed.* with an **Install** button showing the download size. ✕ hides it for that document. It never shows for a language that has no pack. - Installing needs **downloading** on: the same single setting as WordCraft's font downloads - (the font store). Clicking Install, Show available languages or Refresh turns it on; nothing is + (the font store). Clicking Add a language…, Install or Refresh turns it on; nothing is downloaded before. Each pack is checked against the sha256 in WordCraft's pinned list before it is used. - Text in that language is checked and hyphenated as soon as the pack is installed: no restart. @@ -87,9 +91,9 @@ Turkish `tr_TR` dictionaries ISO 8859-9). The first folder holding a matching pair wins: -1. The folder set in **File › Options › Proofing › Dictionaries folder**. This is the easiest - way on every system, and it works for an app started from the Start menu, Finder or the Dock. - The same pane lists the dictionary file each language found. +1. The folder set in **File › Options › Language › Your own dictionaries folder**. This is the + easiest way on every system, and it works for an app started from the Start menu, Finder or + the Dock. Your languages marks each language it supplies *Your own dictionary*. 2. The folder in the `WORDCRAFT_DICTIONARIES` environment variable, and WordCraft's own `dictionaries` folder (the first row of each system below). 3. An installed [Language pack](#language-packs) for the language. @@ -183,6 +187,7 @@ Never commit dictionary files to this repository: they stay on the user's system | Date | Change | Summary | |---|---|---| +| 2026-11-03 | trivial | Language packs: install from Your languages or Add a language… in Options › Language; the dictionaries folder is in Options › Language, not Proofing | | 2026-11-03 | trivial | Language packs: language-packs-2 is published and pinned (75 languages, adding the compounding languages); Mongolian and Thai aren't packs yet, and why | | 2026-11-02 | trivial | Language packs: language-packs-1 is published and pinned (61 languages); which languages aren't packs yet and why (CP4.4) | | 2026-11-02 | trivial | The Flatpak's own dictionaries folder (`~/.var/app/ai.storyteller.wordcraft/data/wordcraft/dictionaries`); the host's folders are outside its sandbox | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 59b692cef2..6316090d30 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI parity with Microsoft Word -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** minor (Arabic mirrored interface: ribbon, panes, File page, dialogs, menus; document canvas independent, #1195); previously trivial (Alt, F badges the Backstage pages; Alt, F, P and V open Print, #4960); previously trivial (View › Macros opens a Macros dialog with Run, Delete and Record, #4327); previously trivial (aligned-copy review fixes retain the document axis through scrolling and include secondary selections (#4764)); previously trivial (Table Properties: row, column and cell settings apply to the selected rows, columns and cells; mixed row check boxes, #4857); previously trivial (Insert › Shapes shows the basic shapes as a grid of drawn icon tiles, #4349); previously trivial (File › Options › Proofing › AutoCorrect Options opens with no document open, #4585); previously trivial (the Shading buttons show the last picked colour, #4412); previously trivial (a blank User Name in File › Options stays blank after a restart, #4368); previously trivial (window size falls back to the screen rectangle when the reported inner size is invalid; equation symbol tooltips no longer repeat a missing glyph's name); previously trivial (window titles and suggested file names omit NUL characters, #3634); previously trivial (Recipient labels continue across product-sized sheets instead of stopping after the first sheet (#4880)); previously trivial (Custom Document Properties dialog from File › Info › Properties › Advanced Properties…, #2982; previously trivial: View › Window › New Window opens another window on the document, each with its own caret and view; previously trivial: mail merge: First Record, Last Record and a record number box in Preview Results; Finish & Merge asks which records to merge or print, #3028; previously trivial: selection bar for right-to-left paragraphs and table rows; previously trivial: read only and comments-only protection grey out edits; previously trivial: the Font dialog previews "NaN" or "inf" in the Size box at 12 pt, #3663; previously trivial: File › Options disables the User name field while Restrict Editing is active; previously trivial: while editing a header or footer, a click in the other one edits it there without scrolling; previously trivial: explicit documents keep the editor when recovery discovery finishes; readable recovery controls; previously trivial: Insert Table of Figures dialog: any caption label, #3013; previously trivial: Home › Underline drop-down shows its lines, #2738; previously trivial: the text context menu includes the formatting mini toolbar, #2959; previously trivial: personal templates in File › New and Save as Word Template, #2852; previously trivial: the scrollbar page tip stays on one line as the page number grows, #3341; previously trivial: File › Home and New: templates and recent documents are buttons named for screen readers, #3176; previously trivial: forms protection greys out the Developer tab's control buttons and Properties; previously trivial: AltGr doesn't open KeyTips, #2388; previously trivial: closing the header or footer puts the caret back where it was in the body, #3331; previously trivial: Format Page Numbers dialog: number format and Continue from previous section / Start at, #1113; previously trivial: inline pictures drag to a dashed insertion cursor and stay inline, #2233, #2234; previously trivial: Save Changes prompt: a text file saved over itself closes, #2376; previously trivial: the equation being edited is framed as in Word: an outline as tall as its line, a grip, an options strip that opens its menu, and its current argument shaded; previously trivial: the table handles show while the caret is in the table, #2428; previously trivial: legacy menu keys, #1697; previously trivial: Shape Fill › Gradient and the Format Shape pane, #1500; previously trivial: Focus fills the screen, and Full Screen View shows the pages alone, #1678; previously trivial: the text pointer over the page is drawn black or white on Windows, #1746; previously trivial: a click in the header/footer band from the body no longer scrolls to the body text, #2103; previously trivial: File › Recover follows the app theme, #3243; previously trivial: long navigation headings wrap onto further lines within the pane, #3015; previously trivial: clearing a no-match font query keeps the recent heading visible, #2068; previously trivial: dragging the vertical scrollbar names the page at the top of the window, #2551; previously trivial: Add Font imports every selected font file, #1789); previously trivial (File › Close keeps the window, #1712; previously trivial: the Spike: Ctrl+F3 and Ctrl+Shift+F3; previously trivial: Ctrl+wheel zoom no longer scrolls the document, #1743; previously trivial: a mouse drag on a table leaves the view where it is, #1738; previously trivial: numbered headings, #1793; previously trivial: Navigation Find exposes Results, #2096; previously trivial: the tab strip never draws tabs over Comments / Editing / Share, #2026; previously trivial: Columns on selected text, #2024; previously trivial: Different First Page headers reachable from page 1, #2826; previously trivial: a copied equation also goes in the clipboard's MathML formats, #1297; previously trivial: Read Mode keeps the keyboard, shows whole columns and keeps text clear of the page-turn bar, #1772); previously trivial: font list entries of tall-ascent fonts sit in their row, not cut off, #2570); previously trivial: Split Cells and Convert Text to Table dialogs follow Word's merged-cell limits and Initial column width, #2592; previously trivial: a new source's Tag is made like Word's, three letters of the author and two digits of the year with a number added when taken, and an edit keeps the Tag, #2094; previously trivial: Web Layout text fills the window width, #1876; previously trivial: Language dialog keeps inherited proofing language and no-proof choices (#2717)); previously trivial: comment balloons readable in the dark theme, #2045; previously trivial: Recently Used Fonts section at the top of the font list, #2068; previously trivial: web preferences kept between visits, #2132; previously trivial: dialog close control: a Windows-style box at the title bar's right end, the whole box clickable, red on hover, #1885); previously trivial (Modify Table Style formats every table style part, #714); previously trivial: a click on the ribbon chrome hands the keyboard to the page in the same frame, #1093 follow-up; previously trivial: Page Setup vertical alignment, #1320; previously trivial: the app opens on the Home tab every launch, as in Word; previously trivial: no document behind the Start screen, #1129; previously trivial: equation pictures share a few textures, #1002; previously trivial: selection bar in the left margin, #856; previously trivial: table column and row markers on the rulers, #700; previously trivial: table borders and the resize handle drag on the page, #217; previously major: first version; ribbon, dialogs, shortcuts and on-canvas interaction measured from `crates/ui-egui` and the command registry) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** trivial (Options › Language redesign: Your languages, Add a language…, Set as default; dictionaries folder moved from Proofing); previously trivial (Alt, F badges the Backstage pages) Recovery discovery no longer interrupts an explicitly created or opened document. Older copies remain in File › Recover, whose buttons use the interface palette. See [local recovery](recovery.md). @@ -93,6 +93,7 @@ Right-click and Shift+F10 keep the compact suggestions menu. The pane is shared | Date | Change | Summary | |---|---|---| | 2026-11-03 | minor | Arabic mirrored interface: title bar, ribbon, panes, File page, dialogs and menus run from the right; document canvas stays independent (#1195); Hebrew UI still open | +| 2026-11-03 | minor | File › Options › Language: Your languages (English variants in use, installed Language packs, the document's languages) with each one's proofing status, Install, Remove and Set as default; Add a language… opens a searchable picker (dutch, nederlands, nl) sorted by name; the folder of your own dictionaries moved here from Proofing, which has no Dictionaries section any more (CP4.3) | | 2026-10-31 | trivial | Keytips: Alt, F badges the Backstage pages with Word's letters and the letter opens the page; Alt, F, P and Alt, F, V open Print; the badges end with the Backstage (#4960) | | 2026-10-31 | trivial | View › Macros opens a Macros dialog (also Alt+F8 and command search): the macros of this session listed with Run, Delete and Record, which reads Stop Recording while a recording runs; the button did nothing before, as `tools.macros` without a macro to run, define or delete only returned the list (#4327) | | 2026-10-31 | trivial | Synchronize the existing Proofing pane with main `eecbb8f`; preserve explicit-position lookup, implicit selection, navigation, undo and per-window state; fresh exact-SHA hosted validation pending, readiness unchanged |