refactor: move author-facing mail copy into a Fluent catalogue

Ports carrier's src/i18n.rs and its locales/en-US/main.ftl layout, same
fluent-bundle and unic-langid versions, so the two catalogues stay portable
between them. Only mail the daemon sends an author moves; operator CLI output
stays inline, since the operator runs the binary and reads English.

The error-reply reasons from dispatch and ApplyError are deliberately left
behind: dispatch is pure by contract, so those become reason identifiers
resolved at the mail-building edge in a separate change rather than having the
pure layer reach for a bundle.

Adds a test carrier lacks. FluentResource::try_new and add_resource both panic
on a malformed or duplicate-id catalogue, and nothing touches the bundle until
the daemon first mails someone, so without it a bad catalogue surfaces inside
poll() on a live instance.

Sentences are verbatim; the bodies are now hard-wrapped where they were single
long lines, which reads better in a plain-text client.
This commit is contained in:
randogoth 2026-10-14 18:48:31 +03:00
parent f2d2d75063
commit 3279fd3a2d
6 changed files with 321 additions and 17 deletions

View file

@ -357,13 +357,11 @@ impl Daemon {
if state.feeds[index].warned && !was_warned {
replies.push((
address.to_owned(),
"twtxt: feed at 90% of its size cap".into(),
format!(
"Your feed has reached 90% of the {}-byte cap.\n\n\
In hard-limit mode (the default) a full feed rejects new records; \
delete some with Twt-Delete, or choose FIFO pruning with \
Twt-Prune: fifo, which drops the oldest records to make room.",
self.cfg.cap_bytes
crate::i18n::t("cap-warning-subject"),
crate::i18n::t1(
"cap-warning-body",
"cap",
self.cfg.cap_bytes.to_string(),
),
));
}
@ -407,12 +405,13 @@ impl Daemon {
let text = std::str::from_utf8(&incoming.body)
.map(|t| t.chars().take(200).collect::<String>())
.unwrap_or_default();
let mut args = fluent_bundle::FluentArgs::new();
args.set("reason", reason.to_owned());
args.set("quoted", text);
replies.push((
address.to_owned(),
format!("twtxt: {reason}"),
format!(
"Your mail could not be applied.\n\nReason: {reason}\n\nQuoted mail:\n{text}\n"
),
crate::i18n::t1("reply-subject", "reason", reason.to_owned()),
crate::i18n::t_args("reply-body", Some(&args)),
));
}