mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-04 09:20:15 -06:00
Compare commits
17
Commits
+41
@@ -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
|
||||
+7
-1
File diff suppressed because one or more lines are too long
@@ -11,7 +11,7 @@ use crate::{CmdError, CmdResult, CommandSpec, Session, p};
|
||||
pub fn specs() -> Vec<CommandSpec> {
|
||||
vec![
|
||||
CommandSpec::new("proof.packs", "Language Packs", "File › Options › Language", list)
|
||||
.params(r#"{"refresh"?: bool (fetch the pinned index again; only while downloading is on; in the app it runs in the background: see "refreshing")} — opens nothing. Returns {"packs": [{"locale", "name", "size" (bytes), "licence" (SPDX), "class", "source" (where the data comes from), "archive" (the download), "spelling", "hyphenation", "installed"}], "installed": [{"locale", "name", "licence"}], "installing": [{"locale", "done", "total"} (bytes)], "refreshing": bool, "errors": {locale or "" (the list): message} (the last failure of each), "index_override": string|null (a test index in use instead of the pinned one), "network": bool (downloading on), "available": bool (a font store to install into)}"#)
|
||||
.params(r#"{"refresh"?: bool (fetch the pinned index again; only while downloading is on; in the app it runs in the background: see "refreshing")} — opens nothing. Returns {"packs": [{"locale", "name", "size" (bytes), "licence" (SPDX), "class", "source" (where the data comes from), "archive" (the download), "spelling", "hyphenation", "installed"}], "languages": [{"tags", "pack", "installed", "size", "proofing" (built_in, installed, own_dictionary, system_dictionary, install, grammar_built_in, not_available), "default"}] (Options › Language › Your languages), "installed": [{"locale", "name", "licence"}], "installing": [{"locale", "done", "total"} (bytes)], "refreshing": bool, "errors": {locale or "" (the list): message} (the last failure of each), "index_override": string|null (a test index in use instead of the pinned one), "network": bool (downloading on), "available": bool (a font store to install into)}"#)
|
||||
.pure(),
|
||||
CommandSpec::new("proof.installPack", "Install Language Pack", "File › Options › Language", install)
|
||||
.params(r#"{"locale": string (a pack's locale from proof.packs, like nl or pt-pt)} — downloads, verifies (sha256) and installs it; spelling and hyphenation in that language use it at once. Needs downloading on (only the person in the app can turn it on). Opens nothing. In the app it runs in the background and returns {"started": true}: follow it with proof.packs ("installing", then "installed" or "errors"); elsewhere it returns when installed."#)
|
||||
@@ -33,7 +33,7 @@ fn locale_param(v: &Value) -> Result<String, CmdError> {
|
||||
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::<Vec<_>>(),
|
||||
"installing": packs::installing(),
|
||||
"refreshing": packs::fetching(),
|
||||
@@ -162,6 +163,159 @@ 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<std::path::PathBuf> {
|
||||
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 valencian_text_is_on_the_valencian_packs_row() {
|
||||
let mut b = FixedBackend::sample();
|
||||
let mut v = b.packs.first().cloned().unwrap();
|
||||
v.locale = "ca-valencia".into();
|
||||
v.size = 1_500_000;
|
||||
b.packs.push(v);
|
||||
with_backend(b, |s, b| {
|
||||
s.run("document.setText", &json!({"text": "Bon dia"})).unwrap();
|
||||
mark(s, 0, "ca-ES-valencia");
|
||||
let rows = packs::your_languages_with(s, None, &none);
|
||||
assert_eq!(row(&rows, "ca-ES-valencia").pack.as_deref(), Some("ca-valencia"), "as the bar offers it");
|
||||
// Installing the Catalan pack doesn't make Valencian installed.
|
||||
b.network.store(true, Ordering::Relaxed);
|
||||
s.run("proof.installPack", &json!({"locale": "ca"})).unwrap();
|
||||
let rows = packs::your_languages_with(s, None, &none);
|
||||
let v = row(&rows, "ca-ES-valencia");
|
||||
assert_eq!((v.pack.as_deref(), v.installed, v.proofing), (Some("ca-valencia"), false, Proofing::Install));
|
||||
});
|
||||
}
|
||||
|
||||
#[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 preferred_only_sets_the_pref_and_nothing_else() {
|
||||
with_backend(FixedBackend::sample(), |s, _| {
|
||||
s.run("document.setText", &json!({"text": "Hello"})).unwrap();
|
||||
s.run("select.all", &json!({})).unwrap();
|
||||
let (doc, sel) = (s.doc.styles.default_chr.lang.clone(), s.sel.clone());
|
||||
let normal = s.doc.styles.styles.iter().find(|x| x.id == "Normal").map(|x| x.chr.lang.clone());
|
||||
let rev = s.rev();
|
||||
s.run("review.language", &json!({"lang": "nl-NL", "preferredOnly": true})).unwrap();
|
||||
assert_eq!(s.prefs.default_language.as_deref(), Some("nl-NL"));
|
||||
assert_eq!(s.doc.styles.default_chr.lang, doc);
|
||||
assert_eq!(s.doc.styles.styles.iter().find(|x| x.id == "Normal").map(|x| x.chr.lang.clone()), normal);
|
||||
assert_eq!(s.sel, sel);
|
||||
assert_eq!(packs::document_languages(s), ["en-US"], "the text keeps its language");
|
||||
assert_eq!(s.rev(), rev);
|
||||
assert!(s.run("review.language", &json!({"preferredOnly": true})).is_err());
|
||||
});
|
||||
}
|
||||
|
||||
#[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| {
|
||||
@@ -229,6 +383,21 @@ mod tests {
|
||||
assert_eq!(packs::pack_for_tag("pt-PT", &packs).map(|p| p.locale.as_str()), Some("pt-pt"));
|
||||
assert_eq!(packs::pack_for_tag("pt_BR", &packs).map(|p| p.locale.as_str()), Some("pt"));
|
||||
assert_eq!(packs::pack_for_tag("nl-BE", &packs).map(|p| p.locale.as_str()), Some("nl"));
|
||||
// A script-qualified tag finds its script's pack before the language's (CP4.3: Serbian
|
||||
// (Latin) chosen in the Language dialog is proofed by `sr-latn`, not the Cyrillic `sr`).
|
||||
packs.push(Pack { locale: "sr".into(), ..packs[0].clone() });
|
||||
packs.push(Pack { locale: "sr-latn".into(), ..packs[0].clone() });
|
||||
assert_eq!(packs::pack_for_tag("sr-Latn-RS", &packs).map(|p| p.locale.as_str()), Some("sr-latn"));
|
||||
assert_eq!(packs::pack_for_tag("sr-Cyrl-RS", &packs).map(|p| p.locale.as_str()), Some("sr"));
|
||||
assert_eq!(packs::pack_for_tag("sr-latn", &packs).map(|p| p.locale.as_str()), Some("sr-latn"));
|
||||
assert_eq!(packs::pack_for_tag("-", &packs), None);
|
||||
assert_eq!(packs::pack_for_tag("nl--", &packs).map(|p| p.locale.as_str()), Some("nl"));
|
||||
// A variant after the region is its language-and-variant pack's; the region alone isn't.
|
||||
packs.push(Pack { locale: "ca-valencia".into(), ..packs[0].clone() });
|
||||
assert_eq!(packs::pack_for_tag("ca-ES-valencia", &packs).map(|p| p.locale.as_str()), Some("ca-valencia"));
|
||||
assert_eq!(packs::pack_for_tag("ca_es_VALENCIA", &packs).map(|p| p.locale.as_str()), Some("ca-valencia"));
|
||||
assert_eq!(packs::pack_for_tag("ca-ES", &packs).map(|p| p.locale.as_str()), Some("ca"));
|
||||
assert_eq!(packs::pack_for_tag("ca", &packs).map(|p| p.locale.as_str()), Some("ca"));
|
||||
assert_eq!(packs::pack_for_tag("en-GB", &packs), None);
|
||||
assert_eq!(packs::pack_for_tag("", &packs), None);
|
||||
assert!(packs::valid_locale("sr-latn"));
|
||||
@@ -486,5 +655,159 @@ mod tests {
|
||||
assert_eq!(messages(pt_pt), messages(ProofLang::Pt), "Portugal text gets the Portuguese grammar checks");
|
||||
}
|
||||
|
||||
/// A font store that has never fetched the list (a fresh install), or whose cached list is
|
||||
/// for an older pin: `index` has nothing until a fetch.
|
||||
struct Uncached(FixedBackend);
|
||||
|
||||
impl Backend for Uncached {
|
||||
fn index(&self) -> Result<Vec<Pack>, String> {
|
||||
Ok(Vec::new())
|
||||
}
|
||||
fn fetch_index(&self, c: &packs::Cancel) -> Result<Vec<Pack>, String> {
|
||||
self.0.fetch_index(c)
|
||||
}
|
||||
fn network_on(&self) -> bool {
|
||||
self.0.network_on()
|
||||
}
|
||||
fn enable_network(&self) -> Result<(), String> {
|
||||
self.0.enable_network()
|
||||
}
|
||||
fn install(&self, pack: &Pack, cancel: &packs::Cancel, progress: &mut dyn FnMut(u64, u64)) -> Result<(), String> {
|
||||
self.0.install(pack, cancel, progress)
|
||||
}
|
||||
fn remove(&self, locale: &str) -> Result<(), String> {
|
||||
self.0.remove(locale)
|
||||
}
|
||||
fn packs_dir(&self) -> Option<std::path::PathBuf> {
|
||||
None
|
||||
}
|
||||
fn installed(&self) -> Vec<packs::Installed> {
|
||||
self.0.installed()
|
||||
}
|
||||
}
|
||||
|
||||
/// The sample packs and Greenlandic (`kl`), a language no system has a dictionary for.
|
||||
fn with_greenlandic() -> FixedBackend {
|
||||
let mut b = FixedBackend::sample();
|
||||
let kl = Pack { locale: "kl".into(), name: "Kalaallisut".into(), ..b.packs[0].clone() };
|
||||
b.packs.push(kl);
|
||||
b
|
||||
}
|
||||
|
||||
fn with_uncached<T>(b: FixedBackend, f: impl FnOnce(&mut Session, &Uncached) -> T) -> T {
|
||||
let _g = LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
|
||||
let _reset = Reset;
|
||||
let b = Arc::new(Uncached(b));
|
||||
packs::set_backend(Some(b.clone() as Arc<dyn Backend>));
|
||||
let mut s = Session::new(wordcraft_doc::Document::new());
|
||||
f(&mut s, &b)
|
||||
}
|
||||
|
||||
/// Martin's test of a fresh install: Greenlandic text, no list fetched yet. The bar still
|
||||
/// offers the language (never English, nor one with a dictionary); getting it fetches the
|
||||
/// list and installs its pack. A language the list then has no pack for (Klingon) stops
|
||||
/// being offered.
|
||||
#[test]
|
||||
fn with_no_list_yet_the_bar_still_offers_the_language() {
|
||||
with_uncached(with_greenlandic(), |s, b| {
|
||||
s.run("document.setText", &json!({"text": "Hello there\nAluu, qanoq ippit?\ntlhIngan Hol"})).unwrap();
|
||||
for (para, lang) in [(1, "kl-GL"), (2, "tlh")] {
|
||||
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();
|
||||
}
|
||||
assert!(packs::available().is_empty() && packs::missing(s).is_empty(), "no list: no pack to offer");
|
||||
for tag in ["kl-GL", "tlh"] {
|
||||
assert!(wordcraft_proof::missing_dictionary(Some(tag)).is_some(), "{tag} has no dictionary here");
|
||||
}
|
||||
assert_eq!(packs::unlisted(s), ["kl-GL", "tlh"], "English is never offered");
|
||||
// Downloading off: getting it fails up front, and asks for nothing.
|
||||
assert!(packs::start_get("kl-GL").is_err());
|
||||
assert!(!packs::fetched());
|
||||
b.0.network.store(true, Ordering::Relaxed);
|
||||
assert_eq!(packs::start_get("kl-GL"), Ok(false), "fetched and installed here (no background thread)");
|
||||
assert!(packs::is_installed("kl"));
|
||||
assert!(packs::fetched());
|
||||
assert!(packs::unlisted(s).is_empty(), "the list is known now: Klingon, which it lacks, isn't offered");
|
||||
assert!(packs::missing(s).is_empty());
|
||||
});
|
||||
}
|
||||
|
||||
/// Review: a get refused because downloading is off isn't remembered, so a later fetch (the
|
||||
/// person's Refresh in Options) doesn't install it unasked.
|
||||
#[test]
|
||||
fn a_refused_get_is_not_installed_by_a_later_fetch() {
|
||||
with_uncached(with_greenlandic(), |_, b| {
|
||||
assert!(packs::start_get("kl-GL").is_err(), "downloading off");
|
||||
b.0.network.store(true, Ordering::Relaxed);
|
||||
assert_eq!(packs::start_refresh(), Ok(false));
|
||||
assert!(packs::find("kl").is_some(), "the list has it");
|
||||
assert!(!packs::is_installed("kl"), "but nobody asked for it after the refusal");
|
||||
});
|
||||
}
|
||||
|
||||
/// The list was fetched, but lists nothing for the language: the bar stops offering it.
|
||||
#[test]
|
||||
fn a_language_the_fetched_list_lacks_is_no_longer_offered() {
|
||||
with_uncached(FixedBackend::sample(), |s, b| {
|
||||
s.run("document.setText", &json!({"text": "tlhIngan Hol"})).unwrap();
|
||||
s.run("select.all", &json!({})).unwrap();
|
||||
s.run("review.language", &json!({"lang": "tlh"})).unwrap();
|
||||
assert_eq!(packs::unlisted(s), ["tlh"]);
|
||||
b.0.network.store(true, Ordering::Relaxed);
|
||||
assert_eq!(packs::start_get("tlh"), Ok(false));
|
||||
assert!(packs::installed().is_empty(), "nothing to install");
|
||||
assert!(packs::unlisted(s).is_empty() && packs::missing(s).is_empty());
|
||||
});
|
||||
}
|
||||
|
||||
/// With downloading already on and no list (or one for an older pin), the window fetches it
|
||||
/// once in the background, asking nothing; never with downloading off, never twice.
|
||||
#[test]
|
||||
fn a_missing_list_is_fetched_once_when_downloading_is_on() {
|
||||
let _g = LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
|
||||
let _reset = Reset;
|
||||
let b = Arc::new(Uncached(with_greenlandic()));
|
||||
packs::set_backend(Some(b.clone() as Arc<dyn Backend>));
|
||||
assert!(!packs::refresh_if_stale(), "no background thread (the CLI, MCP): never");
|
||||
packs::set_background(Some(Arc::new(|| {})));
|
||||
assert!(!packs::refresh_if_stale(), "downloading off: no request");
|
||||
b.0.network.store(true, Ordering::Relaxed);
|
||||
assert!(!packs::refresh_if_stale(), "asked once a session: turned on later, the person's own click fetches");
|
||||
// A new session (the backend set again) with downloading on.
|
||||
packs::set_backend(Some(b.clone() as Arc<dyn Backend>));
|
||||
let mut s = Session::new(wordcraft_doc::Document::new());
|
||||
s.run("document.setText", &json!({"text": "Aluu"})).unwrap();
|
||||
s.run("select.all", &json!({})).unwrap();
|
||||
s.run("review.language", &json!({"lang": "kl"})).unwrap();
|
||||
let before = packs::finished();
|
||||
assert!(packs::refresh_if_stale());
|
||||
wait_for_finish(before);
|
||||
assert!(packs::fetched());
|
||||
assert_eq!(packs::missing(&s).into_iter().map(|p| p.locale).collect::<Vec<_>>(), ["kl"], "the bar offers the pack");
|
||||
assert!(!packs::refresh_if_stale(), "once a session");
|
||||
assert!(packs::installed().is_empty(), "nothing installed without a click");
|
||||
}
|
||||
|
||||
/// Martin's test: choosing a language with nothing selected (the caret only) sets the typing
|
||||
/// language; the bar offers its pack before anything is typed.
|
||||
#[test]
|
||||
fn the_caret_typing_language_asks_for_its_pack() {
|
||||
with_backend(FixedBackend::sample(), |s, _| {
|
||||
s.run("document.setText", &json!({"text": "Hello there"})).unwrap();
|
||||
s.run("caret.set", &json!({"pos": {"block": 0, "off": 11}})).unwrap();
|
||||
assert!(packs::missing(s).is_empty());
|
||||
s.run("review.language", &json!({"lang": "nl-NL"})).unwrap();
|
||||
assert!(s.sel.is_collapsed());
|
||||
assert!(!packs::document_languages(s).iter().any(|l| l == "nl-NL"), "no Dutch text yet");
|
||||
assert_eq!(packs::caret_language(s).as_deref(), Some("nl-NL"));
|
||||
assert_eq!(packs::missing(s).into_iter().map(|p| p.locale).collect::<Vec<_>>(), ["nl"]);
|
||||
// Do not check spelling or grammar at the caret: nothing asked.
|
||||
s.run("review.language", &json!({"lang": "nl-NL", "noProof": true})).unwrap();
|
||||
assert_eq!(packs::caret_language(s), None);
|
||||
assert!(packs::missing(s).is_empty());
|
||||
});
|
||||
}
|
||||
|
||||
use crate::packs::Pack;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,14 @@ pub(super) fn language(s: &mut Session, v: &Value) -> CmdResult {
|
||||
),
|
||||
None => None,
|
||||
};
|
||||
// Options › Language › Set as default: only the saved default proofing language (what future
|
||||
// blank documents are written in), as Word's Set as Preferred; neither this document nor
|
||||
// the selection changes.
|
||||
if p::bool(v, "preferredOnly") == Some(true) {
|
||||
let l = lang.ok_or_else(|| CmdError::Params("`preferredOnly` needs `lang`".into()))?;
|
||||
s.prefs.default_language = Some(l.clone());
|
||||
return Ok(json!({"preferred": l}));
|
||||
}
|
||||
let no_proof = p::bool(v, "noProof");
|
||||
let detect = p::bool(v, "detect");
|
||||
if let Some(d) = detect {
|
||||
|
||||
@@ -337,7 +337,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
})
|
||||
.params(r#"{"format": "decimal|upperRoman|lowerLetter…", "text"?: "%1.", "start"?: n}"#),
|
||||
CommandSpec::new("review.language", "Language", "Review › Language", language).params(
|
||||
r#"{"lang"?: "en-US|en-GB|pl-PL|fr-FR|…" (BCP 47; default en-US), "noProof"?: bool, "detect"?: bool (detect language automatically, a preference), "default"?: bool (also the document's default and the saved language for future blank documents)}"#,
|
||||
r#"{"lang"?: "en-US|en-GB|pl-PL|fr-FR|…" (BCP 47; default en-US), "noProof"?: bool, "detect"?: bool (detect language automatically, a preference), "default"?: bool (also the document's default and the saved language for future blank documents), "preferredOnly"?: bool (with `lang`: only the saved default proofing language for future blank documents, as Options › Language › Set as default does; the open document and the selection don't change)}"#,
|
||||
),
|
||||
CommandSpec::new("review.showMarkup", "Show Markup", "Review › Tracking", |s, v| {
|
||||
s.view.show_markup = p::bool(v, "value").unwrap_or(!s.view.show_markup);
|
||||
|
||||
+330
-9
@@ -143,6 +143,9 @@ pub fn set_backend(backend: Option<Arc<dyn Backend>>) {
|
||||
let dir = backend.as_ref().and_then(|b| b.packs_dir());
|
||||
*BACKEND.write().unwrap_or_else(PoisonError::into_inner) = backend;
|
||||
set_index(None);
|
||||
FETCHED.store(false, Ordering::Relaxed);
|
||||
AUTO_REFRESHED.store(false, Ordering::Relaxed);
|
||||
WANTED.lock().unwrap_or_else(PoisonError::into_inner).clear();
|
||||
jobs().errors.clear();
|
||||
wordcraft_proof::packs::set_packs_dir(dir);
|
||||
}
|
||||
@@ -219,6 +222,8 @@ pub fn refresh(cancel: &Cancel) -> Result<Vec<Pack>, String> {
|
||||
}
|
||||
let index = clean_index(b.fetch_index(cancel)?);
|
||||
set_index(Some(index.clone()));
|
||||
FETCHED.store(true, Ordering::Relaxed);
|
||||
install_wanted(&index);
|
||||
Ok(index)
|
||||
}
|
||||
|
||||
@@ -575,15 +580,47 @@ pub fn licence_texts() -> Vec<(String, String)> {
|
||||
/// About › Language data's title for SCOWL's notices.
|
||||
pub const SCOWL_TITLE: &str = "English spelling dictionaries (SCOWL)";
|
||||
|
||||
/// The pack locale for a document language tag: the whole tag (`pt-pt`), else its language
|
||||
/// (`nl` for `nl-NL`), whichever the index has. `None` for English and tags with no pack.
|
||||
/// The pack locale for a document language tag: the whole tag (`pt-pt`), else each shorter
|
||||
/// prefix of it (`sr-latn` for `sr-Latn-RS`, `nl` for `nl-NL`), the first the index has. A
|
||||
/// variant after the region is also tried without the region, before the region alone
|
||||
/// (`ca-ES-valencia` is the `ca-valencia` pack's), as craft-proof looks its dictionary up. `None`
|
||||
/// for English and tags with no pack.
|
||||
pub fn pack_for_tag<'a>(tag: &str, packs: &'a [Pack]) -> Option<&'a Pack> {
|
||||
let tag = tag.trim().replace('_', "-").to_ascii_lowercase();
|
||||
let base = tag.split('-').next().unwrap_or("");
|
||||
pack_candidates(tag).iter().find_map(|c| packs.iter().find(|p| &p.locale == c))
|
||||
}
|
||||
|
||||
/// The pack locales [`pack_for_tag`] tries for `tag`, best first.
|
||||
fn pack_candidates(tag: &str) -> Vec<String> {
|
||||
// A tag is a handful of short subtags; anything longer is junk and only its start is read.
|
||||
let tag: String = tag.trim().chars().take(64).collect::<String>().replace('_', "-").to_ascii_lowercase();
|
||||
let parts: Vec<&str> = tag.split('-').collect();
|
||||
let base = parts.first().copied().unwrap_or("");
|
||||
if base.is_empty() || base == "en" {
|
||||
return None;
|
||||
return Vec::new();
|
||||
}
|
||||
packs.iter().find(|p| p.locale == tag).or_else(|| packs.iter().find(|p| p.locale == base))
|
||||
let region = parts
|
||||
.iter()
|
||||
.enumerate()
|
||||
.skip(1)
|
||||
.find(|(_, p)| (p.len() == 2 && p.bytes().all(|b| b.is_ascii_alphabetic())) || (p.len() == 3 && p.bytes().all(|b| b.is_ascii_digit())));
|
||||
let mut out: Vec<String> = Vec::new();
|
||||
for n in (1..=parts.len()).rev() {
|
||||
let prefix = parts.get(..n).unwrap_or_default();
|
||||
for c in [
|
||||
Some(prefix.join("-")),
|
||||
region
|
||||
.filter(|(r, _)| r + 1 < n)
|
||||
.map(|(r, _)| prefix.iter().enumerate().filter(|(i, _)| *i != r).map(|(_, p)| *p).collect::<Vec<&str>>().join("-")),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
{
|
||||
if !out.contains(&c) {
|
||||
out.push(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The languages (`w:lang`, resolved through the styles) of the body text, in first-seen order.
|
||||
@@ -671,8 +708,33 @@ fn has_pack_for_tag(tag: &str) -> bool {
|
||||
PACK_LOOKUP.lock().unwrap_or_else(PoisonError::into_inner).get(generation, tag, || pack_for_tag(tag, &available()).is_some())
|
||||
}
|
||||
|
||||
/// The packs the document's text asks for that are available and not installed: what the
|
||||
/// missing-pack bar offers. Never a language without a pack, nor one proofing can't use.
|
||||
/// The language new text at the caret gets (its typing language, resolved through the styles
|
||||
/// and the document default), unless it is marked Do not check spelling or grammar: choosing a
|
||||
/// language with nothing selected asks for its pack before anything is typed in it.
|
||||
pub fn caret_language(s: &Session) -> Option<String> {
|
||||
let style = s.doc.para_at(&s.sel.focus).and_then(|p| p.props.style.as_deref());
|
||||
let rc = s.doc.styles.resolve_char(style, &s.typing_props());
|
||||
if rc.no_proof {
|
||||
return None;
|
||||
}
|
||||
Some(rc.lang.unwrap_or_else(|| "en-US".into()))
|
||||
}
|
||||
|
||||
/// The languages the missing-pack bar looks at: the body text's ([`document_languages`]), then
|
||||
/// the caret's typing language ([`caret_language`]).
|
||||
pub fn wanted_languages(s: &Session) -> Vec<String> {
|
||||
let mut out = document_languages(s);
|
||||
if let Some(tag) = caret_language(s)
|
||||
&& !out.contains(&tag)
|
||||
{
|
||||
out.push(tag);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The packs the document's text (or the caret's typing language) asks for that are available
|
||||
/// and not installed: what the missing-pack bar offers. Never a language without a pack, nor one
|
||||
/// proofing can't use.
|
||||
pub fn missing(s: &Session) -> Vec<Pack> {
|
||||
let packs = available();
|
||||
if packs.is_empty() {
|
||||
@@ -680,7 +742,7 @@ pub fn missing(s: &Session) -> Vec<Pack> {
|
||||
}
|
||||
let installed = installed();
|
||||
let mut out: Vec<Pack> = Vec::new();
|
||||
for tag in document_languages(s) {
|
||||
for tag in wanted_languages(s) {
|
||||
if proofable(&tag)
|
||||
&& let Some(p) = pack_for_tag(&tag, &packs)
|
||||
&& !installed.iter().any(|i| i.locale == p.locale)
|
||||
@@ -692,6 +754,265 @@ pub fn missing(s: &Session) -> Vec<Pack> {
|
||||
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<String>,
|
||||
/// The pack locale: the installed pack, else the one the index offers.
|
||||
pub pack: Option<String>,
|
||||
/// 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`, in [`pack_for_tag`]'s order. `None` for English and junk.
|
||||
fn locale_for_tag(tag: &str, has: &dyn Fn(&str) -> bool) -> Option<String> {
|
||||
pack_candidates(tag).into_iter().find(|c| has(c))
|
||||
}
|
||||
|
||||
/// [`your_languages_with`] against the dictionaries on this computer.
|
||||
pub fn your_languages(s: &Session) -> Vec<LanguageRow> {
|
||||
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<PathBuf> {
|
||||
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<PathBuf>) -> Vec<LanguageRow> {
|
||||
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<LanguageRow> = Vec::new();
|
||||
let mut add = |tag: Option<&str>, locale: Option<String>| {
|
||||
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;
|
||||
}
|
||||
// The most specific pack, installed or offered, as the bar picks it ([`pack_for_tag`]): with
|
||||
// `ca` installed, Valencian text is still the `ca-valencia` pack's row.
|
||||
let locale = locale_for_tag(t, &|l| installed.iter().any(|i| i.locale == 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
|
||||
}
|
||||
|
||||
/// The index was fetched this session (since the backend was set): what it lists is then the
|
||||
/// whole answer, even when it lists nothing.
|
||||
static FETCHED: AtomicBool = AtomicBool::new(false);
|
||||
/// The automatic fetch of a missing or stale list ([`refresh_if_stale`]) was tried.
|
||||
static AUTO_REFRESHED: AtomicBool = AtomicBool::new(false);
|
||||
/// Languages (document tags) whose pack the person asked for before the list was known
|
||||
/// ([`start_get`]): installed once a fetch lists one.
|
||||
static WANTED: Mutex<Vec<String>> = Mutex::new(Vec::new());
|
||||
|
||||
/// Whether the index was fetched since the backend was set.
|
||||
pub fn fetched() -> bool {
|
||||
FETCHED.load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
/// The languages the document (or the caret) asks for while there is no list of packs yet (a
|
||||
/// fresh install, or a list cached for an older pin): proofable, not English, with no dictionary
|
||||
/// and no pack installed, one per proofing language, as the document tags them (`tr-TR`). The
|
||||
/// bar offers to get them: the list is fetched first, and the language then installed if it has
|
||||
/// a pack. Nothing once a list is known or was fetched this session ([`missing`] then answers).
|
||||
pub fn unlisted(s: &Session) -> Vec<String> {
|
||||
if backend().is_none() || fetched() || available_len() > 0 {
|
||||
return Vec::new();
|
||||
}
|
||||
let installed = installed();
|
||||
let mut seen: Vec<wordcraft_proof::ProofLang> = Vec::new();
|
||||
let mut out = Vec::new();
|
||||
for tag in wanted_languages(s) {
|
||||
let base = tag.split(['-', '_']).next().unwrap_or("").to_ascii_lowercase();
|
||||
let lang = wordcraft_proof::ProofLang::from_tag(Some(&tag));
|
||||
if base.is_empty()
|
||||
|| base == "en"
|
||||
|| !proofable(&tag)
|
||||
|| wordcraft_proof::missing_dictionary(Some(&tag)).is_none()
|
||||
|| seen.contains(&lang)
|
||||
|| installed.iter().any(|i| i.locale == base || tag.eq_ignore_ascii_case(&i.locale))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
seen.push(lang);
|
||||
out.push(tag);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The person asked for `tag`'s pack before the list was known (the bar's Install, after their
|
||||
/// consent turned downloading on): fetch the list ([`start_refresh`]), then install the pack it
|
||||
/// lists for `tag`, if any; with none, the bar stops offering it. Downloading must be on.
|
||||
/// Returns whether it is still running.
|
||||
pub fn start_get(tag: &str) -> Result<bool, String> {
|
||||
let tag = tag.trim();
|
||||
if tag.is_empty() || tag.len() > MAX_LOCALE_LEN {
|
||||
return Err(format!("`{tag}` isn't a language tag"));
|
||||
}
|
||||
if let Some(p) = pack_for_tag(tag, &available()) {
|
||||
return start_install(&p.locale);
|
||||
}
|
||||
let b = backend().ok_or_else(no_store)?;
|
||||
if !b.network_on() {
|
||||
// Never queued: a later fetch mustn't install what was refused.
|
||||
return Err(network_off());
|
||||
}
|
||||
let queued = {
|
||||
let mut w = WANTED.lock().unwrap_or_else(PoisonError::into_inner);
|
||||
let new = !w.iter().any(|t| t == tag) && w.len() < MAX_DOC_LANGUAGES;
|
||||
if new {
|
||||
w.push(tag.to_string());
|
||||
}
|
||||
new
|
||||
};
|
||||
let r = start_refresh();
|
||||
if r.is_err() && queued {
|
||||
WANTED.lock().unwrap_or_else(PoisonError::into_inner).retain(|t| t != tag);
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
/// After a fetch: install the packs asked for before the list was known ([`start_get`]).
|
||||
fn install_wanted(index: &[Pack]) {
|
||||
let wanted = std::mem::take(&mut *WANTED.lock().unwrap_or_else(PoisonError::into_inner));
|
||||
for tag in wanted {
|
||||
let Some(p) = pack_for_tag(&tag, index) else { continue };
|
||||
if is_installed(&p.locale) {
|
||||
continue;
|
||||
}
|
||||
if let Err(e) = start_install(&p.locale) {
|
||||
set_error(&p.locale, Some(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Once a session (the first time it is asked once requests run on a thread, [`runs_in_background`]:
|
||||
/// the window), with downloading already on and no list (none cached, or one cached for an older
|
||||
/// pin): fetch it in the background, so the bar can offer packs. The person's consent is the
|
||||
/// downloading setting itself; nothing is asked. Its failure is recorded for Options (""). The
|
||||
/// window asks every frame: after the first time this reads nothing (the downloading setting is
|
||||
/// a file). Returns whether a fetch was started.
|
||||
pub fn refresh_if_stale() -> bool {
|
||||
let Some(b) = backend() else { return false };
|
||||
if !runs_in_background() || AUTO_REFRESHED.swap(true, Ordering::Relaxed) {
|
||||
return false;
|
||||
}
|
||||
if !b.network_on() || fetched() || fetching() || available_len() > 0 {
|
||||
return false;
|
||||
}
|
||||
start_refresh().is_ok()
|
||||
}
|
||||
|
||||
/// A backend with a fixed list and installs that only record themselves: tests and `ui_shot`.
|
||||
#[derive(Default)]
|
||||
pub struct FixedBackend {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -16,6 +16,8 @@ use crate::theme::{Tokens, regular, semibold};
|
||||
|
||||
mod balloons;
|
||||
mod context_menu;
|
||||
#[cfg(test)]
|
||||
pub(crate) use context_menu::issue_heading;
|
||||
mod cursor;
|
||||
mod geometry;
|
||||
mod input;
|
||||
|
||||
@@ -48,6 +48,17 @@ fn equation_menu(app: &mut WordApp, ui: &mut Ui) {
|
||||
}
|
||||
}
|
||||
|
||||
/// The heading of a proofing issue's context menu, in the interface language like the rest of
|
||||
/// the menu: a spelling issue's own message is in the text's language (craft-proof's, "Faute
|
||||
/// d'orthographe possible" for French text), so it says Possible spelling mistake instead.
|
||||
/// English grammar rules' messages are catalog keys; other languages' rules explain in their own.
|
||||
pub(crate) fn issue_heading(issue: &serde_json::Value) -> String {
|
||||
if issue.get("kind").and_then(|k| k.as_str()) == Some("spelling") {
|
||||
return tl!("Possible spelling mistake").to_string();
|
||||
}
|
||||
tl!(issue.get("message").and_then(|m| m.as_str()).unwrap_or("")).to_string()
|
||||
}
|
||||
|
||||
pub(super) fn context_menu(app: &mut WordApp, ui: &mut Ui) {
|
||||
if app.session.math.is_some() {
|
||||
return equation_menu(app, ui);
|
||||
@@ -67,8 +78,7 @@ pub(super) fn context_menu(app: &mut WordApp, ui: &mut Ui) {
|
||||
.and_then(|v| v.as_array())
|
||||
.map(|a| a.iter().filter_map(|x| x.as_str().map(str::to_string)).collect())
|
||||
.unwrap_or_default();
|
||||
// English rules' messages are catalog keys; Polish rules already explain in Polish.
|
||||
ui.label(egui::RichText::new(tl!(issue.get("message").and_then(|m| m.as_str()).unwrap_or(""))).small().weak());
|
||||
ui.label(egui::RichText::new(issue_heading(&issue)).small().weak());
|
||||
if sugg.is_empty() {
|
||||
ui.label(egui::RichText::new(tl!("(no suggestions)")).italics());
|
||||
}
|
||||
|
||||
@@ -322,21 +322,17 @@ impl LanguageForm {
|
||||
|
||||
/// A language's name in the interface language (the tag itself when we don't know it).
|
||||
pub(super) fn language_name(tag: &str) -> String {
|
||||
LANGUAGES.iter().find(|(t, _)| t.eq_ignore_ascii_case(tag)).map(|(_, n)| tl!(n).to_string()).unwrap_or_else(|| tag.to_string())
|
||||
tl!(&crate::ribbon::language_name(Some(tag))).to_string()
|
||||
}
|
||||
|
||||
pub(super) fn language_ui(app: &mut WordApp, ui: &mut Ui, f: &mut LanguageForm) -> bool {
|
||||
ui.label(tl!("Mark selected text as:"));
|
||||
let mut list: Vec<(String, String)> = LANGUAGES.iter().map(|(t, _)| (t.to_string(), language_name(t))).collect();
|
||||
if !LANGUAGES.iter().any(|(t, _)| t.eq_ignore_ascii_case(&f.lang)) {
|
||||
list.push((f.lang.clone(), f.lang.clone()));
|
||||
}
|
||||
list.sort_by_key(|a| a.1.to_lowercase());
|
||||
let list = crate::ribbon::language_list(&f.lang);
|
||||
egui::Frame::NONE.stroke(egui::Stroke::new(1.0, crate::theme::Tokens::get(ui.ctx()).border_strong)).inner_margin(4.0).show(ui, |ui| {
|
||||
egui::ScrollArea::vertical().max_height(220.0).min_scrolled_height(220.0).show(ui, |ui| {
|
||||
ui.set_min_width(300.0);
|
||||
for (tag, name) in &list {
|
||||
let on = f.lang.eq_ignore_ascii_case(tag);
|
||||
let on = crate::ribbon::same_language(&f.lang, tag);
|
||||
let r = ui.selectable_label(on, name.as_str());
|
||||
if r.clicked() {
|
||||
f.lang = tag.clone();
|
||||
|
||||
+1036
-153
File diff suppressed because it is too large
Load Diff
@@ -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::<String>(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<String>, Option<String>)>)>(found_id)).filter(|(g, _)| *g == generation);
|
||||
let found = match cached {
|
||||
Some((_, f)) => f,
|
||||
None => {
|
||||
let f: Vec<(String, Option<String>, Option<String>)> = 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.
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -47,11 +47,16 @@ 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;
|
||||
pub(crate) use language::language_name;
|
||||
#[cfg(test)]
|
||||
pub(crate) use language::short_languages;
|
||||
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;
|
||||
#[cfg(test)]
|
||||
use layout::{columns_items, margins_items, orientation_items};
|
||||
|
||||
@@ -20,13 +20,159 @@ pub(crate) const PROOFING_LANGUAGES: [(&str, &str); 16] = [
|
||||
("es-UY", "Spanish (Uruguay)"),
|
||||
];
|
||||
|
||||
/// Every language WordCraft has an English name for, by tag: the Language menu's short list, the
|
||||
/// Language dialog's built-in list, then the Language pack languages neither has (Bulgarian…).
|
||||
fn known() -> impl Iterator<Item = &'static (&'static str, &'static str)> {
|
||||
PROOFING_LANGUAGES.iter().chain(crate::dialogs_layout::LANGUAGES.iter()).chain(crate::language_packs::MORE_LANGUAGES.iter())
|
||||
}
|
||||
|
||||
/// The language tag a document stores for text in a Language pack's language: the tag WordCraft
|
||||
/// already names for it (`nl` → `nl-NL`, `sr-latn` → `sr-Latn-RS`, `bg` → `bg-BG`), else the
|
||||
/// locale in BCP 47 case (`de-at` → `de-AT`). [`wordcraft_engine::packs::pack_for_tag`] finds the
|
||||
/// same pack again from it, so text marked in a pack's language is proofed by that pack.
|
||||
pub(crate) fn tag_for_pack(locale: &str) -> String {
|
||||
let exact = known().find(|(t, _)| t.eq_ignore_ascii_case(locale));
|
||||
let prefixed = || {
|
||||
known().find(|(t, _)| {
|
||||
t.len() > locale.len()
|
||||
&& t.get(..locale.len()).is_some_and(|p| p.eq_ignore_ascii_case(locale))
|
||||
&& t.as_bytes().get(locale.len()) == Some(&b'-')
|
||||
})
|
||||
};
|
||||
// A variant WordCraft names with its region (`ca-valencia` is `ca-ES-valencia`).
|
||||
let regioned =
|
||||
|| known().find(|(t, _)| t.contains('-') && without_region(&t.to_ascii_lowercase()) == locale.to_ascii_lowercase().replace('_', "-"));
|
||||
if let Some((t, _)) = exact.or_else(prefixed).or_else(regioned) {
|
||||
return (*t).to_string();
|
||||
}
|
||||
let parts: Vec<String> = locale
|
||||
.split(['-', '_'])
|
||||
.enumerate()
|
||||
.map(|(i, p)| {
|
||||
let alpha = p.chars().all(|c| c.is_ascii_alphabetic());
|
||||
if i > 0 && alpha && p.len() == 2 {
|
||||
p.to_ascii_uppercase()
|
||||
} else if i > 0 && alpha && p.len() == 4 {
|
||||
let lower = p.to_ascii_lowercase();
|
||||
let mut c = lower.chars();
|
||||
c.next().map(|f| f.to_ascii_uppercase().to_string() + c.as_str()).unwrap_or_default()
|
||||
} else {
|
||||
p.to_ascii_lowercase()
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
parts.join("-")
|
||||
}
|
||||
|
||||
/// A pack language's name for the lists, in English: the name WordCraft has for its tag, else the
|
||||
/// pack's own name (as shown, without format characters), else the tag.
|
||||
fn pack_language_name(tag: &str, endonym: &str) -> String {
|
||||
let named = language_name(Some(tag));
|
||||
if !named.eq_ignore_ascii_case(tag) || endonym.trim().is_empty() {
|
||||
return named;
|
||||
}
|
||||
crate::language_packs::shown(endonym, 40)
|
||||
}
|
||||
|
||||
/// The installed and available Language packs, as (document tag, pack's own name), installed first.
|
||||
fn pack_languages(available: bool) -> Vec<(String, String)> {
|
||||
let installed = wordcraft_engine::packs::installed().into_iter().map(|i| (i.locale, i.name));
|
||||
let index: Vec<(String, String)> =
|
||||
if available { wordcraft_engine::packs::available().into_iter().map(|p| (p.locale, p.name)).collect() } else { Vec::new() };
|
||||
installed.chain(index).map(|(locale, name)| (tag_for_pack(&locale), name)).collect()
|
||||
}
|
||||
|
||||
/// Review › Language's and the status bar's short list, as (tag, English name): the languages
|
||||
/// WordCraft proofs itself, then each installed Language pack's language not among them, by name.
|
||||
pub(crate) fn short_languages() -> Vec<(String, String)> {
|
||||
let mut out: Vec<(String, String)> = PROOFING_LANGUAGES.iter().map(|(t, n)| ((*t).to_string(), (*n).to_string())).collect();
|
||||
let mut more: Vec<(String, String)> = Vec::new();
|
||||
for (tag, endonym) in pack_languages(false) {
|
||||
if !out.iter().chain(&more).any(|(t, _)| t.eq_ignore_ascii_case(&tag)) {
|
||||
let name = pack_language_name(&tag, &endonym);
|
||||
more.push((tag, name));
|
||||
}
|
||||
}
|
||||
more.sort_by_cached_key(|(_, n)| sort_key(tl!(n)));
|
||||
out.extend(more);
|
||||
out
|
||||
}
|
||||
|
||||
/// The Set Proofing Language dialog's list, as (tag, name in the interface language), sorted by
|
||||
/// name: every language WordCraft names, every installed Language pack's and every available
|
||||
/// one's, each once.
|
||||
pub(crate) fn all_languages() -> Vec<(String, String)> {
|
||||
let mut out: Vec<(String, String)> = Vec::new();
|
||||
let builtin = PROOFING_LANGUAGES.iter().chain(crate::dialogs_layout::LANGUAGES.iter()).map(|(t, n)| ((*t).to_string(), (*n).to_string()));
|
||||
let packs = pack_languages(true).into_iter().map(|(tag, endonym)| {
|
||||
let name = pack_language_name(&tag, &endonym);
|
||||
(tag, name)
|
||||
});
|
||||
for (tag, name) in builtin.chain(packs) {
|
||||
if !out.iter().any(|(t, _)| t.eq_ignore_ascii_case(&tag)) {
|
||||
out.push((tag, tl!(&name).to_string()));
|
||||
}
|
||||
}
|
||||
out.sort_by_cached_key(|(_, n)| sort_key(n));
|
||||
out
|
||||
}
|
||||
|
||||
/// The Set Proofing Language dialog's list: [`all_languages`], with the `current` language when
|
||||
/// it is none of them ([`same_language`]: a row is checked for it then).
|
||||
pub(crate) fn language_list(current: &str) -> Vec<(String, String)> {
|
||||
let mut list = all_languages();
|
||||
// A tag the list has under another spelling (`nl` for `nl-NL`) is that row, not another.
|
||||
if !current.is_empty() && !list.iter().any(|(t, _)| same_language(current, t)) {
|
||||
list.push((current.to_string(), tl!(&language_name(Some(current))).to_string()));
|
||||
list.sort_by_cached_key(|(_, n)| sort_key(n));
|
||||
}
|
||||
list
|
||||
}
|
||||
|
||||
/// How a language name sorts: case-insensitively, a Latin letter with a mark beside the plain one
|
||||
/// (Čeština with Czech, Ελληνικά and other scripts after Latin, by code point).
|
||||
pub(crate) fn sort_key(name: &str) -> (String, String) {
|
||||
const FOLD: [(&str, &str); 22] = [
|
||||
("àáâãäåāăą", "a"),
|
||||
("æ", "ae"),
|
||||
("çćĉċč", "c"),
|
||||
("ďđð", "d"),
|
||||
("èéêëēĕėęě", "e"),
|
||||
("ĝğġģ", "g"),
|
||||
("ĥħ", "h"),
|
||||
("ìíîïĩīĭįı", "i"),
|
||||
("ĵ", "j"),
|
||||
("ķ", "k"),
|
||||
("ĺļľŀł", "l"),
|
||||
("ñńņňʼn", "n"),
|
||||
("òóôõöøōŏő", "o"),
|
||||
("œ", "oe"),
|
||||
("ŕŗř", "r"),
|
||||
("śŝşšș", "s"),
|
||||
("ß", "ss"),
|
||||
("ţťŧțþ", "t"),
|
||||
("ùúûüũūŭůűų", "u"),
|
||||
("ŵ", "w"),
|
||||
("ýÿŷ", "y"),
|
||||
("źżž", "z"),
|
||||
];
|
||||
let lower = name.to_lowercase();
|
||||
let mut folded = String::with_capacity(lower.len());
|
||||
for c in lower.chars() {
|
||||
match FOLD.iter().find(|(from, _)| from.contains(c)) {
|
||||
Some((_, to)) => folded.push_str(to),
|
||||
None => folded.push(c),
|
||||
}
|
||||
}
|
||||
(folded, lower)
|
||||
}
|
||||
|
||||
/// The English name of a proofing language tag, as the status bar shows it (no tag: WordCraft's
|
||||
/// default, US English): a listed language by its name; another region of one by the language
|
||||
/// and the region ("French (Canada)"); a bare language subtag by its usual variant; else the tag.
|
||||
pub(crate) fn language_name(tag: Option<&str>) -> String {
|
||||
let tag = tag.unwrap_or("en-US");
|
||||
let named =
|
||||
|t: &str| PROOFING_LANGUAGES.iter().chain(crate::dialogs_layout::LANGUAGES.iter()).find(|(l, _)| l.eq_ignore_ascii_case(t)).map(|(_, n)| *n);
|
||||
let named = |t: &str| known().find(|(l, _)| l.eq_ignore_ascii_case(t)).map(|(_, n)| *n);
|
||||
// Any language the Language dialog offers (French, German…) by its name, not its tag (#860).
|
||||
if let Some(name) = named(tag) {
|
||||
return name.to_string();
|
||||
@@ -39,8 +185,7 @@ pub(crate) fn language_name(tag: Option<&str>) -> String {
|
||||
match region {
|
||||
// A region the list doesn't have: the language's name without its own region or variant.
|
||||
Some(r) => {
|
||||
let language = crate::dialogs_layout::LANGUAGES
|
||||
.iter()
|
||||
let language = known()
|
||||
.find(|(l, _)| l.split('-').next().is_some_and(|p| p.eq_ignore_ascii_case(primary)))
|
||||
.map(|(_, n)| n.split(" (").next().unwrap_or(n));
|
||||
match language {
|
||||
@@ -61,14 +206,23 @@ pub(crate) fn language_name(tag: Option<&str>) -> String {
|
||||
wordcraft_engine::proof::ProofLang::Es => "Spanish (Spain)".into(),
|
||||
wordcraft_engine::proof::ProofLang::De => "German (Germany)".into(),
|
||||
wordcraft_engine::proof::ProofLang::En if tag.eq_ignore_ascii_case("en") => "English (United States)".into(),
|
||||
_ => tag.to_string(),
|
||||
// A language (and script) without its region: the named tag it starts (`bg` is
|
||||
// Bulgarian, `sr-Latn` Serbian (Latin)).
|
||||
_ => known()
|
||||
.find(|(t, _)| {
|
||||
t.len() > tag.len()
|
||||
&& t.get(..tag.len()).is_some_and(|p| p.eq_ignore_ascii_case(tag))
|
||||
&& t.as_bytes().get(tag.len()) == Some(&b'-')
|
||||
})
|
||||
.or_else(|| known().find(|(t, _)| t.contains('-') && without_region(&t.to_ascii_lowercase()).eq_ignore_ascii_case(tag)))
|
||||
.map_or_else(|| tag.to_string(), |(_, n)| (*n).to_string()),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// The English name of a region subtag the language list has no entry for (else the subtag).
|
||||
fn region_name(code: &str) -> String {
|
||||
const REGIONS: [(&str, &str); 62] = [
|
||||
const REGIONS: [(&str, &str); 69] = [
|
||||
("AE", "U.A.E."),
|
||||
("AO", "Angola"),
|
||||
("AR", "Argentina"),
|
||||
@@ -85,6 +239,7 @@ fn region_name(code: &str) -> String {
|
||||
("CN", "China"),
|
||||
("CO", "Colombia"),
|
||||
("CR", "Costa Rica"),
|
||||
("CU", "Cuba"),
|
||||
("CV", "Cabo Verde"),
|
||||
("CY", "Cyprus"),
|
||||
("DE", "Germany"),
|
||||
@@ -92,10 +247,13 @@ fn region_name(code: &str) -> String {
|
||||
("EC", "Ecuador"),
|
||||
("EG", "Egypt"),
|
||||
("ES", "Spain"),
|
||||
("FI", "Finland"),
|
||||
("FR", "France"),
|
||||
("GB", "United Kingdom"),
|
||||
("GQ", "Equatorial Guinea"),
|
||||
("GT", "Guatemala"),
|
||||
("HK", "Hong Kong SAR"),
|
||||
("HN", "Honduras"),
|
||||
("IE", "Ireland"),
|
||||
("IN", "India"),
|
||||
("IQ", "Iraq"),
|
||||
@@ -114,8 +272,10 @@ fn region_name(code: &str) -> String {
|
||||
("MX", "Mexico"),
|
||||
("MY", "Malaysia"),
|
||||
("MZ", "Mozambique"),
|
||||
("NI", "Nicaragua"),
|
||||
("NL", "Netherlands"),
|
||||
("NZ", "New Zealand"),
|
||||
("PA", "Panama"),
|
||||
("PE", "Peru"),
|
||||
("PH", "Philippines"),
|
||||
("PR", "Puerto Rico"),
|
||||
@@ -124,6 +284,7 @@ fn region_name(code: &str) -> String {
|
||||
("QA", "Qatar"),
|
||||
("RU", "Russia"),
|
||||
("SG", "Singapore"),
|
||||
("SV", "El Salvador"),
|
||||
("SY", "Syria"),
|
||||
("TW", "Taiwan"),
|
||||
("UA", "Ukraine"),
|
||||
@@ -148,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<String> {
|
||||
pub(crate) fn caret_lang_tag(app: &WordApp) -> Option<String> {
|
||||
caret_char(app).lang
|
||||
}
|
||||
|
||||
@@ -189,23 +350,12 @@ pub(crate) fn language_menu(ui: &mut Ui, app: &mut WordApp) {
|
||||
_ => String::new(),
|
||||
};
|
||||
let no_proof = st.get("noProof").and_then(Value::as_bool).unwrap_or(false);
|
||||
let listed = |tag: &str| {
|
||||
current.eq_ignore_ascii_case(tag)
|
||||
|| (tag == "pl-PL" && current.eq_ignore_ascii_case("pl"))
|
||||
|| (tag == "pt-BR" && current.eq_ignore_ascii_case("pt"))
|
||||
|| (tag == "it-IT" && current.eq_ignore_ascii_case("it"))
|
||||
|| (tag == "hr-HR" && current.eq_ignore_ascii_case("hr"))
|
||||
|| (tag == "tr-TR" && current.eq_ignore_ascii_case("tr"))
|
||||
|| (tag == "cs-CZ" && wordcraft_engine::proof::ProofLang::from_tag(Some(¤t)) == wordcraft_engine::proof::ProofLang::Cs)
|
||||
|| (tag == "id-ID" && wordcraft_engine::proof::ProofLang::from_tag(Some(¤t)) == wordcraft_engine::proof::ProofLang::Id)
|
||||
|| (tag == "es-ES" && current.eq_ignore_ascii_case("es"))
|
||||
|| (tag == "en-US" && current.eq_ignore_ascii_case("en"))
|
||||
};
|
||||
let checks = language_checks(¤t, listed);
|
||||
let entries = short_languages();
|
||||
let checks = language_checks(¤t, &entries);
|
||||
if let Some(name) = checks.extra {
|
||||
mi_check(ui, app, &name, true, "review.language", json!({"lang": current}));
|
||||
}
|
||||
for ((tag, name), on) in PROOFING_LANGUAGES.iter().zip(checks.listed) {
|
||||
for ((tag, name), on) in entries.iter().zip(checks.listed) {
|
||||
mi_check(ui, app, name, on, "review.language", json!({"lang": tag}));
|
||||
}
|
||||
ui.separator();
|
||||
@@ -215,21 +365,78 @@ pub(crate) fn language_menu(ui: &mut Ui, app: &mut WordApp) {
|
||||
mi_check(ui, app, "Language Preferences…", false, "file.options", json!({"pane": "language"}));
|
||||
}
|
||||
|
||||
/// The Language menu's check marks for the `current` tag: which short-list entries are checked
|
||||
/// (`listed` matches a tag), and the name of the current language when it is none of them,
|
||||
/// shown checked above. A language named like a short-list entry checks that entry, so no name
|
||||
/// shows twice.
|
||||
/// The Language menu's check marks for the `current` tag: which `entries` (tag, English name) are
|
||||
/// checked, and the name of the current language when it is none of them, shown checked above.
|
||||
/// An entry is checked for its own tag (any case), or for a tag WordCraft proofs the same way and
|
||||
/// names alike (`pl` for Polish, `ces` for Czech, `PT-br-x-test` for Portuguese (Brazil)), so no
|
||||
/// name shows twice; English (New Zealand) doesn't check English (United Kingdom).
|
||||
pub(super) struct LanguageChecks {
|
||||
pub(super) extra: Option<String>,
|
||||
pub(super) listed: [bool; PROOFING_LANGUAGES.len()],
|
||||
pub(super) listed: Vec<bool>,
|
||||
}
|
||||
|
||||
pub(super) fn language_checks(current: &str, listed: impl Fn(&str) -> bool) -> LanguageChecks {
|
||||
pub(super) fn language_checks(current: &str, entries: &[(String, String)]) -> LanguageChecks {
|
||||
let name = (!current.is_empty()).then(|| language_name(Some(current)));
|
||||
let on = PROOFING_LANGUAGES.map(|(t, n)| listed(t) || name.as_deref() == Some(n));
|
||||
let on: Vec<bool> =
|
||||
entries.iter().map(|(t, n)| t.eq_ignore_ascii_case(current) || (name.as_deref() == Some(n.as_str()) && same_proofing(current, t))).collect();
|
||||
LanguageChecks { extra: name.filter(|_| !on.contains(&true)), listed: on }
|
||||
}
|
||||
|
||||
/// Are `a` and `b` the same language as the lists show it: the same tag (any case), or named
|
||||
/// alike and proofed alike ([`same_proofing`]): `nl` is the `nl-NL` row, `pl` the `pl-PL` one.
|
||||
pub(crate) fn same_language(a: &str, b: &str) -> bool {
|
||||
a.eq_ignore_ascii_case(b) || (!a.is_empty() && language_name(Some(a)) == language_name(Some(b)) && same_proofing(a, b))
|
||||
}
|
||||
|
||||
/// Does WordCraft proof `a` and `b` the same way: the same built-in language, or two Language
|
||||
/// pack languages read from the same pack ([`wordcraft_engine::packs::pack_for_tag`]: `nl` and
|
||||
/// `nl-NL` are both the `nl` pack's, though their pack locales differ); with neither pack known,
|
||||
/// the same language and script whatever the region.
|
||||
fn same_proofing(a: &str, b: &str) -> bool {
|
||||
use wordcraft_engine::packs;
|
||||
use wordcraft_engine::proof::ProofLang;
|
||||
let (la, lb) = (ProofLang::from_tag(Some(a)), ProofLang::from_tag(Some(b)));
|
||||
if la == lb {
|
||||
return true;
|
||||
}
|
||||
let (Some(pa), Some(pb)) = (la.pack_locale(), lb.pack_locale()) else { return false };
|
||||
let mut known = packs::available();
|
||||
for i in packs::installed() {
|
||||
if !known.iter().any(|p| p.locale == i.locale) {
|
||||
known.push(packs::Pack {
|
||||
locale: i.locale,
|
||||
name: i.name,
|
||||
version: String::new(),
|
||||
url: String::new(),
|
||||
source: None,
|
||||
size: 0,
|
||||
licence: i.licence,
|
||||
class: String::new(),
|
||||
spelling: false,
|
||||
hyphenation: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
match (packs::pack_for_tag(a, &known), packs::pack_for_tag(b, &known)) {
|
||||
(Some(x), Some(y)) => x.locale == y.locale,
|
||||
(None, None) => without_region(pa.as_str()) == without_region(pb.as_str()),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// A lowercase locale without its region subtag (`nl-nl` → `nl`, `sr-latn-rs` → `sr-latn`).
|
||||
fn without_region(locale: &str) -> String {
|
||||
locale
|
||||
.split('-')
|
||||
.enumerate()
|
||||
.filter(|(i, p)| {
|
||||
*i == 0 || !((p.len() == 2 && p.bytes().all(|b| b.is_ascii_alphabetic())) || (p.len() == 3 && p.bytes().all(|b| b.is_ascii_digit())))
|
||||
})
|
||||
.map(|(_, p)| p)
|
||||
.collect::<Vec<&str>>()
|
||||
.join("-")
|
||||
}
|
||||
|
||||
/// A menu item with a check mark when `checked` (the current choice of several).
|
||||
pub(super) fn mi_check(ui: &mut Ui, app: &mut WordApp, label: &str, checked: bool, id: &str, params: Value) {
|
||||
// A vector mark needs no font glyph; the empty atom keeps labels aligned.
|
||||
|
||||
@@ -229,6 +229,59 @@ fn page_setup_menus_mark_the_current_setting() {
|
||||
assert_eq!(first_words, ["Narrow", "Landscape", "A4", "Right"], "{checked:?}");
|
||||
}
|
||||
|
||||
/// The Language menu's built-in short list, as `language_checks` takes it.
|
||||
fn short() -> Vec<(String, String)> {
|
||||
PROOFING_LANGUAGES.iter().map(|(t, n)| ((*t).to_string(), (*n).to_string())).collect()
|
||||
}
|
||||
|
||||
/// Check marks with only `tag` checked.
|
||||
fn listed_only(tag: &str) -> Vec<bool> {
|
||||
PROOFING_LANGUAGES.iter().map(|(t, _)| *t == tag).collect()
|
||||
}
|
||||
|
||||
/// CP4.3: the menu's check marks are worked out one way (the tag, or the same proofing language
|
||||
/// named alike), not by a case per language: a bare or ISO 639-2 tag checks its language, and a
|
||||
/// region WordCraft proofs like another (New Zealand like the UK) doesn't check that one.
|
||||
#[test]
|
||||
fn language_menu_checks_by_tag_or_proofing_language() {
|
||||
for (current, tag) in [
|
||||
("pl", "pl-PL"),
|
||||
("pt", "pt-BR"),
|
||||
("it", "it-IT"),
|
||||
("hr", "hr-HR"),
|
||||
("tr", "tr-TR"),
|
||||
("ces", "cs-CZ"),
|
||||
("in", "id-ID"),
|
||||
("es", "es-ES"),
|
||||
("en", "en-US"),
|
||||
("RU-ru", "ru-RU"),
|
||||
] {
|
||||
let c = language_checks(current, &short());
|
||||
assert_eq!((c.extra, c.listed), (None, listed_only(tag)), "{current}");
|
||||
}
|
||||
let c = language_checks("en-NZ", &short());
|
||||
assert_eq!(c.extra.as_deref(), Some("English (New Zealand)"));
|
||||
assert!(!c.listed.contains(&true), "English (New Zealand) doesn't check English (United Kingdom)");
|
||||
// A pack language in the list (once installed) is checked for its bare tag too.
|
||||
let mut entries = short();
|
||||
entries.push(("bg-BG".into(), "Bulgarian".into()));
|
||||
let c = language_checks("bg", &entries);
|
||||
assert_eq!((c.extra, c.listed.last().copied()), (None, Some(true)));
|
||||
// CP4.3 review: a bare pack-language tag checks the regioned row of the same pack, however
|
||||
// the packs are known (`nl` and `nl-NL` are both the `nl` pack's), and shows no second Dutch.
|
||||
entries.push(("nl-NL".into(), "Dutch".into()));
|
||||
for current in ["nl", "NL-nl"] {
|
||||
let c = language_checks(current, &entries);
|
||||
assert_eq!((c.extra, c.listed.last().copied()), (None, Some(true)), "{current}");
|
||||
}
|
||||
let c = language_checks("nl-BE", &entries);
|
||||
assert_eq!((c.extra.as_deref(), c.listed.last().copied()), (Some("Dutch (Belgium)"), Some(false)));
|
||||
assert!(super::language::same_language("sv", "sv-SE") && !super::language::same_language("sv-FI", "sv-SE"));
|
||||
// Nothing set (mixed selection): nothing checked, nothing above.
|
||||
let c = language_checks("", &entries);
|
||||
assert_eq!((c.extra, c.listed.contains(&true)), (None, false));
|
||||
}
|
||||
|
||||
/// #860 review: a tag the language list doesn't have shows by language and region, not as
|
||||
/// the tag; Portuguese (Angola) isn't Brazil's, and no name shows twice in the menu.
|
||||
#[test]
|
||||
@@ -240,17 +293,16 @@ fn other_regions_show_by_name_once() {
|
||||
assert_eq!(language_name(Some("sr-Latn-BA")), "Serbian (Bosnia and Herzegovina)");
|
||||
assert_eq!(language_name(Some("en-ZZ")), "English (ZZ)");
|
||||
assert_eq!(language_name(Some("xx-YY")), "xx-YY");
|
||||
let exact = |cur: &'static str| move |t: &str| t.eq_ignore_ascii_case(cur);
|
||||
for tag in ["fr-CA", "pt-AO", "en-SG"] {
|
||||
let c = language_checks(tag, exact(tag));
|
||||
let c = language_checks(tag, &short());
|
||||
let name = c.extra.expect("shown above the list");
|
||||
assert!(!PROOFING_LANGUAGES.iter().any(|(_, n)| *n == name), "{name} is listed once");
|
||||
assert!(!c.listed.contains(&true), "{tag}: nothing in the list checked");
|
||||
}
|
||||
// A tag named like a list entry checks that entry instead of showing it again.
|
||||
let c = language_checks("PT-br-x-test", |_| false);
|
||||
let c = language_checks("PT-br-x-test", &short());
|
||||
assert_eq!(c.extra, None);
|
||||
assert_eq!(c.listed, PROOFING_LANGUAGES.map(|(t, _)| t == "pt-BR"));
|
||||
assert_eq!(c.listed, listed_only("pt-BR"));
|
||||
}
|
||||
|
||||
/// The Englishes WordCraft proofs differently are in the menu, checked by their tags, and
|
||||
@@ -262,8 +314,8 @@ fn english_dialects_are_in_the_language_menu() {
|
||||
{
|
||||
assert!(PROOFING_LANGUAGES.contains(&(tag, name)), "{tag}");
|
||||
assert_eq!(language_name(Some(tag)), name);
|
||||
let c = language_checks(&tag.to_ascii_lowercase(), |t| t.eq_ignore_ascii_case(tag));
|
||||
assert_eq!((c.extra, c.listed), (None, PROOFING_LANGUAGES.map(|(t, _)| t == tag)), "{tag}");
|
||||
let c = language_checks(&tag.to_ascii_lowercase(), &short());
|
||||
assert_eq!((c.extra, c.listed), (None, listed_only(tag)), "{tag}");
|
||||
}
|
||||
for (tag, name) in
|
||||
[("en-NZ", "English (New Zealand)"), ("en-IE", "English (Ireland)"), ("en-ZA", "English (South Africa)"), ("en-IN", "English (India)")]
|
||||
@@ -292,12 +344,12 @@ fn spanish_varieties_are_in_the_language_menu() {
|
||||
assert!(PROOFING_LANGUAGES.contains(&(tag, name)), "{tag}");
|
||||
assert!(crate::dialogs_layout::LANGUAGES.contains(&(tag, name)), "{tag}");
|
||||
assert_eq!(language_name(Some(tag)), name);
|
||||
let c = language_checks(&tag.to_ascii_lowercase(), |t| t.eq_ignore_ascii_case(tag));
|
||||
assert_eq!((c.extra, c.listed), (None, PROOFING_LANGUAGES.map(|(t, _)| t == tag)), "{tag}");
|
||||
let c = language_checks(&tag.to_ascii_lowercase(), &short());
|
||||
assert_eq!((c.extra, c.listed), (None, listed_only(tag)), "{tag}");
|
||||
}
|
||||
assert_eq!(language_name(Some("es")), "Spanish (Spain)");
|
||||
assert_eq!(language_name(Some("es-AR")), "Spanish (Argentina)");
|
||||
let c = language_checks("es-AR", |t| t.eq_ignore_ascii_case("es-AR"));
|
||||
let c = language_checks("es-AR", &short());
|
||||
assert_eq!(c.extra.as_deref(), Some("Spanish (Argentina)"));
|
||||
assert!(!c.listed.contains(&true));
|
||||
}
|
||||
|
||||
@@ -84,8 +84,8 @@ requests are never flipped.
|
||||
Language packs (see [MCP](mcp.md#language-packs)) are commands like any other: `proof.packs`,
|
||||
`proof.installPack {"locale": "nl"}` and `proof.removePack {"locale": "nl"}`. Through the control
|
||||
channel they act on the running app's packs, and install only while its downloading setting is on;
|
||||
they never turn it on, and neither does a `ui.click` or `ui.key` on the app's Install, Show
|
||||
available languages or Refresh buttons. An install or a refresh runs in the background
|
||||
they never turn it on, and neither does a `ui.click` or `ui.key` on the app's Install, Add a
|
||||
language… or Refresh buttons. An install or a refresh runs in the background
|
||||
(`"started": true`); `proof.packs` reports its progress, then the result.
|
||||
`ui.dialog {"name": "languageData"}` opens About › Language data.
|
||||
|
||||
|
||||
+4
-2
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
# Localization parity with Microsoft Word
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** minor (Arabic `ar` interface: craft-i18n catalog, mirrored shell, font fallback, #1195; 28 languages); 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) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** minor (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); previously minor (Arabic `ar` interface: craft-i18n catalog, mirrored shell, font fallback, #1195; 28 languages); 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) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4
|
||||
|
||||
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; Your languages there shows each language's proofing status), 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,14 +170,27 @@ pack** (its spelling dictionary, hyphenation patterns and licence texts), listed
|
||||
pinned pack index and installed through the font store into `<font store>/language-packs/<locale>/`
|
||||
([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 (Built in, Installed, Your own dictionary,
|
||||
System dictionary, Grammar built in, Not available yet), 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.
|
||||
offering it, and closes per document. Once the list of packs is known it never shows for a
|
||||
language without a pack; before then (a fresh install) it offers a language with no dictionary
|
||||
provisionally: Install fetches the list, then installs the pack if there is one, and the bar goes
|
||||
if there isn't.
|
||||
- Help › About › Language data shows the full licence texts of the embedded English data and the
|
||||
installed packs.
|
||||
- One language list: Set Proofing Language lists the built-in languages and every installed or
|
||||
available pack's language (Bulgarian, Belarusian, Spanish (Cuba)…), each once and sorted by
|
||||
name; Review › Language and the status bar's menu show the short list plus the installed packs'
|
||||
languages. A pack's language is stored as the tag WordCraft names (`bg-BG`, `sr-Latn-RS`,
|
||||
`de-AT`, Word's `ca-ES-valencia` for Valencian), which finds that pack again, so the text is
|
||||
proofed by it; a bare tag (`nl`) is the same row as its regioned one (`nl-NL`). Every pack in the published
|
||||
index has an English name.
|
||||
- language-packs-2 is published and pinned (75 packs, craft-i18n `20467b63`), adding the
|
||||
compounding languages (Danish, German, Dutch, Swedish, Norwegian, Hungarian, Estonian, Croatian,
|
||||
Persian, Esperanto); Mongolian and Thai stay hidden. Install reads it,
|
||||
@@ -257,6 +270,9 @@ 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, System dictionary, 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 (CP4.3): the missing-pack bar offers a language before the list of packs is fetched (a fresh install, or a list cached for an older pin) and gets it on Install; with downloading on, a missing or stale list is fetched once in the background; the caret's typing language counts; the spelling context menu's heading is in the interface language |
|
||||
| 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 |
|
||||
| 2026-11-01 | minor | Language packs (CP4.3–CP4.5): install and remove a language's spelling and hyphenation from File › Options › Language or the missing-pack bar, About › Language data, the commands; the default build embeds English data only; the language requests point at their packs: Lithuanian and Romanian available once language-packs-1 is published, the others waiting on craft-proof engine support |
|
||||
@@ -287,7 +303,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 |
|
||||
|
||||
+4
-4
@@ -119,13 +119,13 @@ the suite's font store (see [installing languages](spelling-dictionaries.md#lang
|
||||
|
||||
| Command | Params | Returns |
|
||||
|---|---|---|
|
||||
| `proof.packs` | `{"refresh"?: bool}` (fetch the pinned index again) | `{"packs": [{"locale", "name", "size", "licence", "class", "source" (upstream), "archive", "spelling", "hyphenation", "installed"}], "installed": [...], "installing": [{"locale", "done", "total"}], "refreshing", "errors": {locale: message}, "network", "available"}` |
|
||||
| `proof.packs` | `{"refresh"?: bool}` (fetch the pinned index again) | `{"packs": [{"locale", "name", "size", "licence", "class", "source" (upstream), "archive", "spelling", "hyphenation", "installed"}], "languages": [{"tags", "pack", "installed", "size", "proofing" (built_in, installed, own_dictionary, system_dictionary, install, grammar_built_in, not_available), "default"}] (Options › Language › Your languages), "installed": [...], "installing": [{"locale", "done", "total"}], "refreshing", "errors": {locale: message}, "network", "available"}` |
|
||||
| `proof.installPack` | `{"locale": "nl"}` | `{"locale", "name", "licence", "installed": true}` (`"already": true` when it was); with `--connect`, `{"locale", "started": true}` |
|
||||
| `proof.removePack` | `{"locale": "nl"}` | `{"locale", "installed": false}` |
|
||||
|
||||
None opens anything. Downloading is the font store's single consent setting: an agent can install
|
||||
only while the person has turned it on in the app (File › Options › Language: Install or Show
|
||||
available languages), and can never turn it on itself; otherwise `proof.installPack` fails with
|
||||
only while the person has turned it on in the app (File › Options › Language: Install or Add a
|
||||
language…), and can never turn it on itself; otherwise `proof.installPack` fails with
|
||||
*downloading is turned off*. `refresh` likewise needs it on. Every archive is checked against the
|
||||
sha256 in the pinned index before it is unpacked. With `--connect` the commands act on the running
|
||||
app's packs, and an install or a `refresh` runs in the background so the window keeps working: the
|
||||
@@ -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
|
||||
|
||||
@@ -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)); 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); 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)
|
||||
|
||||
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,22 @@ 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*, *System dictionary*, *Grammar built in*, *Not available yet*).
|
||||
**Install** gets a document language's pack; **Remove** takes an installed one out; **Set as
|
||||
default** makes it the language of new blank documents (the open document is left as it is). **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.
|
||||
it for that document. It never shows for a language that has no pack. Before the list of
|
||||
packs has been fetched (a fresh install, or the list of an older WordCraft), it shows for a
|
||||
language that has no dictionary, with **Install** alone: clicking it gets the list, then the
|
||||
pack if there is one (if not, the bar goes). With downloading on, WordCraft fetches a missing
|
||||
or out-of-date list by itself once. Choosing a language with nothing selected counts too.
|
||||
- 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 +95,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 +191,8 @@ 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 (CP4.3): the missing-pack bar offers a language before the list is fetched and gets the list, then the pack, on Install; a missing or stale list is fetched once while downloading is on; the caret's typing language counts |
|
||||
| 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 |
|
||||
|
||||
+2
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user