Skip to main content

Crate mf2_build

Crate mf2_build 

Source
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):

ModuleWhat it does
configmf2.toml
featuresthe client feature set, from CARGO_FEATURE_* or --features
loadera locale’s files to records: .mf2 resources or flat JSON
lintthe names and levels of mf2 check’s lints
corpusreading and parsing every locale, with errors placed in their files
manifestids → MsgId, slots, markup, functions, the hash
checkthe lints themselves
slicethe locale data a corpus needs
catalogone catalog per locale: fallbacks, compression, content hashes
codegenthe generated Rust module
pseudothe pseudo-locales en-XA and ar-XB
buildBuild, 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.
CatalogConfig
[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.
LocaleDataConfig
[locale_data].
LocaleInfo
One locale in the built corpus.
Outcome
What a build produced.
Published
What Outcome::publish did.
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 of plans/12-phase-5a-work-order.md).
Error
What stops a build.
Level
What a lint does when it fires.
Lint
One check mf2 check makes.
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.