es-fluent-cli
The official command-line tool for es-fluent.
This tool automatically manages your Fluent (.ftl) translation files by analyzing your Rust code. It finds types with #[derive(EsFluent)] and creates corresponding message entries, so you don't have to keep them in sync manually.
Installation
Commands
Ensure you have an i18n.toml in your crate root:
= "i18n"
= "en-US"
Generate
When you add new localizable structs or enums to your code, run:
This will:
- Scan your
src/directory. - Update
i18n/en-US/{your_crate}.ftl.- New items: Added as new messages.
- Changed items: Variables updated (e.g. if you added a field).
- Existing translations: Preserved untouched.
Use --dry-run to preview changes without writing them.
Watch
Same as generate, but runs in watch mode, updating FTL files as you type:
Check
To ensure all your translations are valid and no keys are missing:
Use --all to check all locales, not just the fallback language.
Clean
Remove orphan keys and groups that are no longer present in your source code:
Use --dry-run to preview changes without writing them.
Format
Standardize the formatting of your FTL files using fluent-syntax rules:
Use --dry-run to preview changes without writing them. Use --all to format all locales.
Sync
Propagate keys from your fallback language to other languages (e.g., from en-US to fr and de), creating placeholders for missing translations:
Use --locale <LANG> to sync a specific locale, or --all to sync all locales, --dry-run to preview changes without writing them.