DOCS / FEATURES
Text catalogs
The words the app shows live in catalogs, not in the code, so they're written and reviewed in one place. The browser has typed catalogs (see Frontend structure), and the API keeps its error messages and emails in catalogs read with Fluent.
Server catalogs
api/locales/en.ftl # every API message and email
api/locales/fr.ftl # the French translation
api/src/i18n.rs # Text, message lookup, catalog testsThe catalogs are compiled into the binary. A message is plain text with
{ $variables }. Plurals use Fluent's selectors:
auth-invalid-credentials = invalid email or password
email-account-locked =
.subject = Your account was locked
.body = { $greeting }, … It unlocks by itself in { $minutes ->
[one] { $minutes } minute
*[other] { $minutes } minutes
}, or use this link to unlock it now. …Errors. The client variants of AppError carry a Text: either a
catalog message, or a plain string that hasn't moved into the catalog.
use crate::i18n::Text;
Err(AppError::Unauthorized(Text::msg("auth-invalid-credentials")))
Err(AppError::Validation(Text::msg("error-unsupported-locale").arg("locale", code)))
Err(AppError::Validation("the client ID is required".into())) // not in the catalog yeterror.code never changes with the wording, so clients branch on the
code and show the message. Some errors are still plain strings. Move one
into the catalog with Text::msg when you touch it.
Emails. Each email is one message with .subject, .body, .action
(the button) and .link (the label before the URL in the plain-text
part). api/src/email/templates.rs builds all four. Values are formatted
as plain text and HTML-escaped afterwards, so a message can't inject
markup.