Expand description
mf2-build — a directory of translated message resources to what an
application ships: the manifest, one catalog per locale, and a generated
Rust module.
It runs from the build.rs of the crate that includes the generated
module — fn main() { mf2_build::run(); }, which reads mf2’s features
through links (run) — and from mf2-cli, reading the same
Config both times so that the two can never disagree. Nothing here is
linked into the client wasm.
locales/<tag>/*.mf2 ─▶ Loader ─▶ records ─▶ mf2-syntax ─▶ models
│
manifest ◀───┤ ids → MsgId, slots,
│ markup, functions, hash
lints (mf2 check) ◀──┤
▼
fallbacks flattened
▼
locale data sliced ─▶ mf2-catalog writer ─▶ .mf2b + .br/.gz
▼
the generated Rust module§What 2.x promises here
What an i18n crate’s build.rs and a tool call: Build and what it
returns (Outcome, Published, LocaleInfo, Report,
Diagnostic), the mf2.toml it reads (Config and its parts), the
client Features, the lints (Lint, Level) and the Error.
The pipeline — the modules below, which mf2-cli and the conformance
crate reach into — is private or hidden from the documentation, and not
promised (docs/versioning.md):
| Module | What it does |
|---|---|
config | mf2.toml |
features | the client feature set, from CARGO_FEATURE_* or --features |
loader | a locale’s files to records: .mf2 resources or flat JSON |
lint | the names and levels of mf2 check’s lints |
corpus | reading and parsing every locale, with errors placed in their files |
manifest | ids → MsgId, slots, markup, functions, the hash |
check | the lints themselves |
slice | the locale data a corpus needs |
catalog | one catalog per locale: fallbacks, compression, content hashes |
codegen | the generated Rust module |
pseudo | the pseudo-locales en-XA and ar-XB |
build | Build, which runs all of it |
§The user guide
The Rust MF2 book is the user
guide: how the crates fit together, web and native applications, the
command line, and what 2.x promises.
An application names this crate in its i18n crate’s
[build-dependencies], and mf2 in its
[dependencies].
Structs§
- Build
- A build, configured.
- Catalog
Config [catalog].- Config
- A corpus’s configuration.
- Diagnostic
- One thing a build has to say.
- Features
- Which functions the built catalogs may use, and which locale data they need.
- Locale
Data Config [locale_data].- Locale
Info - One locale in the built corpus.
- Outcome
- What a build produced.
- Published
- What
Outcome::publishdid. - Report
- Everything a build found, in the order found.
Enums§
- DataSet
- How much of one CLDR table a catalog carries.
- Emit
- What a build writes (
plans/05-tooling.md§4; owner question 1 ofplans/12-phase-5a-work-order.md). - Error
- What stops a build.
- Level
- What a lint does when it fires.
- Lint
- One check
mf2 checkmakes. - Missing
- What a locale that lacks a message gets.
- Strip
- A catalog section a production build leaves out.
Functions§
- run
- Everything a build script does:
fn main() { mf2_build::run(); }.
Type Aliases§
- Result
- The result of a build step.