CP4.3: craft-libs pinned to Lane 4's pushed heads; test-source warning, upstream source links, code-drawn bar close button

- craft-proof (benandez/craft-libs 6ae4f03, storytold/craft-libs#485) and craft-font-store /
  craft-font-catalog (630e42f, #486) by git rev instead of local paths.
- ProofLang::Pack: the bar offers every language with a pack (zxx/und never).
- Options › Language warns when CRAFT_LANGUAGE_PACK_INDEX supplies a test index.
- Pack `source` (upstream link) when the index gives it, else the archive.
- The bar's close button is the code-drawn close icon: "✕" had no glyph in the interface fonts
  and egui panicked drawing it.
- `cargo xtask language` allows our own ru-extra, which stays embedded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FypgCX8LsYYE8fsj4byBm2
This commit is contained in:
Martin BallandClaude Opus 5.5 committed 2026-11-02 01:03:59 +00:00
1 parent e5d46bb242
commit 2ef046bad9
10 files changed
+83 -30

No files matched your search

Generated
+4
View File
@@ -1014,6 +1014,7 @@ dependencies = [
[[package]]
name = "craft-atomic"
version = "0.1.0"
source = "git+https://github.com/benandez/craft-libs?rev=630e42f42c49eb8514fd14a780061afe2e8ed7cb#630e42f42c49eb8514fd14a780061afe2e8ed7cb"
dependencies = [
"rustix 1.1.5",
]
@@ -1021,6 +1022,7 @@ dependencies = [
[[package]]
name = "craft-font-catalog"
version = "0.1.0"
source = "git+https://github.com/benandez/craft-libs?rev=630e42f42c49eb8514fd14a780061afe2e8ed7cb#630e42f42c49eb8514fd14a780061afe2e8ed7cb"
dependencies = [
"fontique",
"skrifa 0.47.0",
@@ -1031,6 +1033,7 @@ dependencies = [
[[package]]
name = "craft-font-store"
version = "0.1.0"
source = "git+https://github.com/benandez/craft-libs?rev=630e42f42c49eb8514fd14a780061afe2e8ed7cb#630e42f42c49eb8514fd14a780061afe2e8ed7cb"
dependencies = [
"craft-atomic",
"craft-font-catalog",
@@ -1099,6 +1102,7 @@ dependencies = [
[[package]]
name = "craft-proof"
version = "0.1.0"
source = "git+https://github.com/benandez/craft-libs?rev=6ae4f03c7f031312f2fd25d633c89ccbe7d414b5#6ae4f03c7f031312f2fd25d633c89ccbe7d414b5"
dependencies = [
"log",
"miniz_oxide 0.9.1",
+7 -6
View File
@@ -24,12 +24,13 @@ wordcraft-pdf = { path = "crates/pdf" }
# Proofing is craft-libs' craft-proof (it was crates/proof); its Language data is craft-i18n's
# language-data/, embedded from CRAFT_I18N_DIR (craft-i18n.rev). The package keeps the
# `wordcraft-proof` name here so `wordcraft_proof::` paths are unchanged.
# Pinned like the other craft-libs crates (each has its own rev). This rev is the head of
# storytold/craft-libs#482, which adds craft-proof; move it to that PR's merge commit once merged.
# TODO(CP4): path deps to Lane 4's worktrees while developing; switched to their pushed heads before push.
wordcraft-proof = { package = "craft-proof", path = "../wt-p4-libs/crates/proof" }
craft-font-store = { path = "../wt-p4-store/crates/font-store" }
craft-font-catalog = { path = "../wt-p4-store/crates/font-catalog" }
# TODO(CP4): craft-proof with Language packs is benandez/craft-libs feat/craft-proof-packs (CP4.2,
# stacked on storytold/craft-libs#482), the font store's `language-pack` kind is
# feat/font-store-language-packs (CP4.1). Move both to storytold/craft-libs merge commits once
# merged.
wordcraft-proof = { package = "craft-proof", git = "https://github.com/benandez/craft-libs", rev = "6ae4f03c7f031312f2fd25d633c89ccbe7d414b5", version = "=0.1.0" }
craft-font-store = { git = "https://github.com/benandez/craft-libs", rev = "630e42f42c49eb8514fd14a780061afe2e8ed7cb", version = "=0.1.0" }
craft-font-catalog = { git = "https://github.com/benandez/craft-libs", rev = "630e42f42c49eb8514fd14a780061afe2e8ed7cb", version = "=0.1.0" }
wordcraft-engine = { path = "crates/engine" }
wordcraft-mcp = { path = "crates/mcp" }
wordcraft-zotero = { path = "crates/zotero" }
+4 -3
View File
@@ -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)} — opens nothing. Returns {"packs": [{"locale", "name", "size" (bytes), "licence" (SPDX), "class", "source" (the archive URL), "spelling", "hyphenation", "installed"}], "installed": [{"locale", "name", "licence"}], "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)} — 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"}], "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."#)
@@ -42,7 +42,7 @@ fn list(_: &mut Session, v: &Value) -> CmdResult {
.map(|p| {
json!({
"locale": p.locale, "name": p.name, "size": p.size, "licence": p.licence, "class": p.class,
"source": p.url, "spelling": p.spelling, "hyphenation": p.hyphenation,
"source": p.source_link(), "archive": p.url, "spelling": p.spelling, "hyphenation": p.hyphenation,
"installed": installed.iter().any(|i| i.locale == p.locale),
})
})
@@ -126,7 +126,8 @@ mod tests {
fn unknown_and_hostile_locales_are_errors() {
with_backend(FixedBackend::sample(), |s, b| {
b.network.store(true, Ordering::Relaxed);
for bad in [json!({}), json!({"locale": 5}), json!({"locale": "../../etc"}), json!({"locale": "x".repeat(10_000)}), json!({"locale": ""})] {
for bad in [json!({}), json!({"locale": 5}), json!({"locale": "../../etc"}), json!({"locale": "x".repeat(10_000)}), json!({"locale": ""})]
{
assert!(s.run("proof.installPack", &bad).is_err(), "{bad}");
assert!(s.run("proof.removePack", &bad).is_err(), "{bad}");
}
+28 -5
View File
@@ -44,6 +44,9 @@ pub struct Pack {
pub version: String,
/// The archive.
pub url: String,
/// The upstream folder the data comes from, at its pinned commit (the index's optional
/// `source`), shown before install; the archive when the index gives none.
pub source: Option<String>,
/// Bytes of the archive.
pub size: u64,
/// SPDX expression.
@@ -102,6 +105,10 @@ pub trait Backend: Send + Sync {
fn installed(&self) -> Vec<Installed> {
installed_from_proof()
}
/// The test index in use instead of the pinned one (`CRAFT_LANGUAGE_PACK_INDEX`), if any.
fn index_override(&self) -> Option<String> {
None
}
}
static BACKEND: RwLock<Option<Arc<dyn Backend>>> = RwLock::new(None);
@@ -138,10 +145,13 @@ pub fn backend() -> Option<Arc<dyn Backend>> {
}
fn installed_from_proof() -> Vec<Installed> {
wordcraft_proof::packs::installed()
.into_iter()
.map(|p| Installed { locale: p.locale, name: p.name, licence: p.licence, path: p.path })
.collect()
wordcraft_proof::packs::installed().into_iter().map(|p| Installed { locale: p.locale, name: p.name, licence: p.licence, path: p.path }).collect()
}
/// The test source packs come from instead of the pinned index (`CRAFT_LANGUAGE_PACK_INDEX`):
/// Options › Language says so.
pub fn index_override() -> Option<String> {
backend().and_then(|b| b.index_override())
}
/// The packs installed now (none without a backend).
@@ -348,6 +358,13 @@ pub struct FixedBackend {
pub installed: Mutex<Vec<Installed>>,
}
impl Pack {
/// Where the data comes from: the upstream source when the index names it, else the archive.
pub fn source_link(&self) -> &str {
self.source.as_deref().filter(|s| !s.is_empty()).unwrap_or(&self.url)
}
}
impl FixedBackend {
/// A few packs shaped like the published ones, for screenshots and tests.
pub fn sample() -> Self {
@@ -356,6 +373,7 @@ impl FixedBackend {
name: name.into(),
version: "0000000".into(),
url: format!("https://github.com/storytold/craft-i18n/releases/download/language-packs-1/{locale}.tar.zst"),
source: Some("https://github.com/LibreOffice/dictionaries".into()),
size,
licence: licence.into(),
class: class.into(),
@@ -425,7 +443,12 @@ mod tests {
if std::env::var_os("CRAFT_PROOF_EMBED").is_some_and(|v| !v.is_empty()) {
return;
}
// `ru-extra` is our own word list (the repository's licence), kept embedded.
const OWN_DATA: [&str; 1] = ["ru"];
let embedded = wordcraft_proof::packs::embedded_locales();
assert!(embedded.iter().all(|l| l.starts_with("en-")), "only en-* is embedded by default, got {embedded:?}");
assert!(
embedded.iter().all(|l| l.starts_with("en-") || OWN_DATA.contains(l)),
"only en-* (and our own ru-extra) is embedded by default, got {embedded:?}"
);
}
}
+8
View File
@@ -45,6 +45,8 @@ fn pack(e: &PackEntry) -> Pack {
name: e.name.clone(),
version: e.version.clone(),
url: e.url.clone(),
// TODO(CP4): the index's optional `source` once craft-font-store's PackEntry carries it.
source: None,
size: e.size,
licence: e.licence.clone(),
class: e.class.clone(),
@@ -107,6 +109,12 @@ impl super::Backend for FontStoreBackend {
self.store.remove_language_pack(locale).map_err(|e| e.to_string())
}
fn index_override(&self) -> Option<String> {
// TODO(CP4): craft-font-store's `language_pack_index_overridden()` once it lands; the
// store reads the same variable.
std::env::var(craft_font_store::LANGUAGE_PACK_INDEX_ENV).ok().map(|v| v.trim().to_string()).filter(|v| !v.is_empty())
}
fn packs_dir(&self) -> Option<PathBuf> {
Some(self.store.language_packs_dir())
}
+2 -2
View File
@@ -170,10 +170,10 @@ impl<'a> Exempt<'a> {
names.extend([title, text]);
}
for p in wordcraft_engine::packs::available() {
names.extend([format!("{} · {}", p.name, p.locale), p.name, p.licence, p.url]);
names.extend([format!("{} · {}", p.name, p.locale), p.source_link().to_string(), p.locale, p.name, p.licence, p.url]);
}
for p in wordcraft_engine::packs::installed() {
names.extend([p.name.clone(), p.licence, format!("{} · {}", p.name, p.locale)]);
names.extend([p.name.clone(), p.licence, format!("{} · {}", p.name, p.locale), p.locale]);
}
for m in crate::credits::MODELS {
names.extend([m.company, m.model, m.version].map(str::to_string));
+26 -10
View File
@@ -259,7 +259,7 @@ pub(crate) fn bar(app: &mut WordApp, ui: &mut Ui) {
ui.add(egui::Label::new(RichText::new(e.as_str()).color(t.red)).truncate());
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if ui.small_button("✕").on_hover_text(tl!("Not now")).clicked() {
if crate::widgets::icon_button(ui, "close", tl!("Not now")).clicked() {
app.packs_rt.dismissed.insert((document, pack.locale.clone()));
}
});
@@ -268,7 +268,7 @@ pub(crate) fn bar(app: &mut WordApp, ui: &mut Ui) {
}
fn licence_hover(pack: &Pack) -> String {
crate::i18n::fmt(tl!("Licence: {licence}. Downloaded from {source}"), &[("licence", &pack.licence), ("source", &pack.url)])
crate::i18n::fmt(tl!("Licence: {licence}. Downloaded from {source}"), &[("licence", &pack.licence), ("source", pack.source_link())])
}
/// File › Options › Language › Language packs: every available and installed pack with its
@@ -287,6 +287,10 @@ pub(crate) fn options_section(app: &mut WordApp, ui: &mut Ui) {
ui.label(RichText::new(why).small().weak());
return;
};
if let Some(source) = packs::index_override() {
let line = crate::i18n::fmt(tl!("Language packs come from a test source: {source}"), &[("source", &source)]);
ui.add(egui::Label::new(RichText::new(line).small().color(t.orange)).wrap());
}
let index = packs::available();
let installed = packs::installed();
let network = backend.network_on();
@@ -323,6 +327,7 @@ pub(crate) fn options_section(app: &mut WordApp, ui: &mut Ui) {
name: i.name.clone(),
version: String::new(),
url: String::new(),
source: None,
size: 0,
licence: i.licence.clone(),
class: String::new(),
@@ -346,15 +351,23 @@ pub(crate) fn options_section(app: &mut WordApp, ui: &mut Ui) {
ui.end_row();
for (pack, is_installed) in &rows {
ui.vertical(|ui| {
ui.label(language_of(&pack.locale, &pack.name));
ui.label(RichText::new(format!("{} · {}", pack.name, pack.locale)).small().weak());
ui.set_width(180.0);
let language = language_of(&pack.locale, &pack.name);
// The pack's own name when it differs (Nederlands for Dutch), and its locale.
let detail = if language == pack.name { pack.locale.clone() } else { format!("{} · {}", pack.name, pack.locale) };
ui.label(language);
ui.label(RichText::new(detail).small().weak());
});
ui.label(if pack.size > 0 { size_text(pack.size) } else { String::new() });
ui.add(egui::Label::new(RichText::new(pack.licence.as_str()).small()).truncate()).on_hover_text(pack.licence.as_str());
if pack.url.is_empty() {
ui.vertical(|ui| {
ui.set_width(220.0);
ui.add(egui::Label::new(RichText::new(pack.licence.as_str()).small()).wrap());
});
let source = pack.source_link();
if source.is_empty() {
ui.label("");
} else {
ui.hyperlink_to(tl!("Source"), pack.url.as_str()).on_hover_text(pack.url.as_str());
ui.hyperlink_to(tl!("Source"), source).on_hover_text(source);
}
ui.horizontal(|ui| {
let job = app.packs_rt.installs.get(&pack.locale).map(|(j, c)| {
@@ -399,9 +412,12 @@ pub(crate) fn about_tab(ui: &mut Ui) {
ui.add_space(4.0);
egui::ScrollArea::vertical().id_salt("about_language_data").max_height(420.0).show(ui, |ui| {
for (title, text) in packs::licence_texts() {
egui::CollapsingHeader::new(RichText::new(title.as_str()).font(semibold(13.0))).id_salt(("language_data", title.as_str())).show(ui, |ui| {
ui.add(egui::Label::new(RichText::new(text).small().monospace()).wrap());
});
egui::CollapsingHeader::new(RichText::new(title.as_str()).font(semibold(13.0))).id_salt(("language_data", title.as_str())).show(
ui,
|ui| {
ui.add(egui::Label::new(RichText::new(text).small().monospace()).wrap());
},
);
}
});
}
+1 -1
View File
@@ -176,7 +176,7 @@ pinned pack index and installed through the font store into `<font store>/langua
offering it; it never shows for a language without a pack, and closes per document.
- Help › About › Language data shows the full licence texts of the embedded English data and the
installed packs.
- The default build embeds `en-*` data only (`cargo xtask language`); a Language build embeds the
- The default build embeds `en-*` data only, plus our own Russian word additions (`ru-extra`) (`cargo xtask language`); a Language build embeds the
locales named in `CRAFT_PROOF_EMBED`. The web build is English only.
- Lithuanian [#4707](https://github.com/storytold/wordcraft/issues/4707) and Romanian [#3438](https://github.com/storytold/wordcraft/issues/3438) are available as a Language pack once language-packs-1 is published (with Polish, Portuguese, Italian, Russian, Czech, Spanish, Bulgarian, Bosnian, Slovenian, Ukrainian and the other packs that pass CI); the packs for Dutch [#4145](https://github.com/storytold/wordcraft/issues/4145)/[#2505](https://github.com/storytold/wordcraft/issues/2505) and Catalan [#2895](https://github.com/storytold/wordcraft/issues/2895)/[#4947](https://github.com/storytold/wordcraft/issues/4947) are defined but wait on craft-proof engine support (two-character flags, `FLAG long`), French [#1325](https://github.com/storytold/wordcraft/issues/1325) on `OCONV`, Greek [#2561](https://github.com/storytold/wordcraft/issues/2561) on ISO 8859-7 decoding, Slovak [#3806](https://github.com/storytold/wordcraft/issues/3806) on `CIRCUMFIX`, Serbian [#4968](https://github.com/storytold/wordcraft/issues/4968) on numeric flags (`FLAG num`), and Latvian [#4438](https://github.com/storytold/wordcraft/issues/4438) on `FULLSTRIP` (and `CIRCUMFIX`, `NEEDAFFIX`). A language craft-proof has no rules of its own for
(Lithuanian, Romanian, Dutch…) is spell-checked from its pack alone (`ProofLang::Pack`: the
+1 -1
View File
@@ -119,7 +119,7 @@ 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", "spelling", "hyphenation", "installed"}], "installed": [...], "network", "available"}` |
| `proof.packs` | `{"refresh"?: bool}` (fetch the pinned index again) | `{"packs": [{"locale", "name", "size", "licence", "class", "source" (upstream), "archive", "spelling", "hyphenation", "installed"}], "installed": [...], "network", "available"}` |
| `proof.installPack` | `{"locale": "nl"}` | `{"locale", "name", "licence", "installed": true}` (`"already": true` when it was) |
| `proof.removePack` | `{"locale": "nl"}` | `{"locale", "installed": false}` |
+2 -2
View File
@@ -25,7 +25,7 @@ commands:
audit with its missing-translation report, then doctests
i18n-report the interface audit: fails on text that skips the catalog, and prints the
strings each language has no translation for (never a failure)
language the default build embeds only English Language data (en-*); the other
language the default build embeds only English Language data (en-*, and our own ru-extra); the other
languages come as Language packs. Skipped in a Language build (CRAFT_PROOF_EMBED set)
ci fmt --check, clippy -D warnings, test, i18n-report, language, doctest, assets,
layers, wasm
@@ -185,7 +185,7 @@ fn cmd_test() -> Result<(), String> {
const LANGUAGE_CHECK: &str = "packs::tests::the_default_build_embeds_only_english";
const LANGUAGE_CHECK_FILTER: &str = "package(wordcraft-engine) & test(=packs::tests::the_default_build_embeds_only_english)";
/// CP4.4: the embedded locale list is `en-*` unless this is a Language build, which names the
/// CP4.4: the embedded locale list is `en-*` (and our own `ru-extra`) unless this is a Language build, which names the
/// other locales it embeds in `CRAFT_PROOF_EMBED` (craft-proof's build.rs).
fn cmd_language() -> Result<(), String> {
if let Some(v) = std::env::var_os("CRAFT_PROOF_EMBED").filter(|v| !v.is_empty()) {