| Crates.io | es-fluent-build |
| lib.rs | es-fluent-build |
| version | 0.3.0 |
| created_at | 2025-07-07 15:42:23.851892+00 |
| updated_at | 2025-12-21 07:30:14.806587+00 |
| description | A crate that expose a build script for building Fluent resources |
| homepage | |
| repository | https://github.com/stayhydated/es-fluent |
| max_upload_size | |
| id | 1741480 |
| size | 27,457 |
The es-fluent-build crate provides a build script integration for automatically generating .ftl translation files from your Rust source code.
It is designed to be used as a build-dependency in your Cargo.toml and invoked from a build.rs script. The crate parses your source files for types that derive EsFluent and generates corresponding message keys in a Fluent resource file.
Add es-fluent-build as a build dependency in your Cargo.toml:
[build-dependencies]
es-fluent-build = { version = "*" }
Create a build.rs file in your crate's root with the following content:
pub fn main() {
if let Err(e) = es_fluent_build::FluentBuilder::new()
.mode(es_fluent_build::FluentParseMode::Conservative)
.build()
{
log::error!("Error building FTL files: {}", e);
}
}
Create an i18n.toml configuration file in your crate's root to specify the output directory and fallback language:
fallback_language = "en"
assets_dir = "i18n"
Now, every time you build your crate, the script will automatically scan your src directory and generate a {crate_name}.ftl file inside i18n/en/. This file will contain all the message keys extracted from your EsFluent-derived types, ready for you to add translations.
in envs like publishing, you can set the ES_FLUENT_SKIP_BUILD environment variable. This will prevent the build script from running and thus avoid generating the FTL files.
such as:
ES_FLUENT_SKIP_BUILD=true cargo publish --workspace --dry-run