bevy-fluent
Skill16 starsChanged 3 months agoMITView on GitHub
Use when adding localization to a Bevy 0.19 app with `es-fluent-manager-bevy`, defining typed messages with `#[derive(EsFluent)]`, wrapping UI text in `FluentText<T>`, auto-registering locale updates with `#[derive(BevyFluentText)]`, or reacting to locale switches via `LocaleChangeEvent`. Covers `I18nPlugin`, `RequestedLanguageId`, `i18n.toml` config, and hot-reload of `.ftl` assets.
In this repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- bevy-a11ySkill
- bevy-animationSkill
- bevy-assetsSkill
- bevy-audioSkill
- bevy-camerasSkill
- bevy-captureSkill
- bevy-cargo-featuresSkill
- bevy-core-conceptsSkill
- bevy-custom-assetsSkill
- bevy-diagnostics-profilingSkill
- bevy-ecs-componentsSkill
- bevy-ecs-queriesSkill
- bevy-ecs-systemsSkill
- bevy-input-actionsSkill
- bevy-migration-0-17-to-0-18Skill
- bevy-migration-0-18-to-0-19Skill
- bevy-pbr-materialsSkill
- bevy-physicsSkill
- bevy-portingSkill
- bevy-renderingSkill
- bevy-save-loadSkill
- bevySkill
- bevy-testingSkill
- bevy-uiSkill
- bevy-vfxSkill
- bevy-voxel-dataSkill
- bevy-voxel-pipelineSkill
- bevy-voxel-runtimeSkill
- bevy-wasm-webgpuSkill
- similarity-rsSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 137
Events are Messages: Use MessageWriter<LocaleChangeEvent> and MessageReader<LocaleChangedEvent> — not EventWriter/EventReader (renamed in …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Bevy 0.19 — Localization (es-fluent)
When to use this skill
- Adding Fluent-based i18n to a Bevy app (
es-fluent-manager-bevy = "0.19.2"). - Defining typed UI messages with
#[derive(EsFluent)]and#[derive(BevyFluentText)]. - Wrapping a UI text entity with
FluentText<T>for automatic locale-driven refresh. - Switching locales at runtime via
LocaleChangeEvent. - Reading the current locale from
RequestedLanguageId.
Canonical pattern — 5-file minimum shape
Cargo.toml:
[dependencies]
bevy = "0.19"
es-fluent = { version = "0.18.1", features = ["derive"] }
es-fluent-manager-bevy = { version = "0.19.2", features = ["macros"] }
unic-langid = "0.9"i18n.toml (crate root, read at compile time):
fallback_language = "en"
assets_dir = "assets/locales"src/i18n.rs:
es_fluent_manager_bevy::define_i18n_module!();src/lib.rs — message types must live here (see Gotchas):
use bevy::prelude::*;
use es_fluent::EsFluent;
use es_fluent_manager_bevy::{
BevyFluentText, FluentText, I18nPlugin, LocaleChangeEvent, RequestedLanguageId,
};
use unic_langid::langid;
pub mod i18n;
#[derive(BevyFluentText, Clone, EsFluent)]
#[fluent(namespace = "ui")]
pub enum UiMessage { StartGame, Settings, QuitGame }
pub fn build_i18n_plugin() -> I18nPlugin {
I18nPlugin::with_language(langid!("en"))
}
pub fn setup_ui(mut commands: Commands) {
commands.spawn(Camera2d);
// FluentText<T> writes translations into a sibling Text component.
commands.spawn((FluentText::new(UiMessage::StartGame), Text::new("")));
}
pub fn switch_locale_on_keypress(
keys: Res<ButtonInput<KeyCode>>,
requested: Res<RequestedLanguageId>,
mut locale_events: MessageWriter<LocaleChangeEvent>,
) {
if keys.just_pressed(KeyCode::KeyL) {
let next = if requested.0.to_string() == "en" { langid!("fr") } else { langid!("en") };
locale_events.write(LocaleChangeEvent(next));
}
}src/main.rs — thin binary entry point:
use bevy::prelude::*;
use my_game::{build_i18n_plugin, setup_ui, switch_locale_on_keypress};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(build_i18n_plugin())
.add_systems(Startup, setup_ui)
.add_systems(Update, switch_locale_on_keypress)
.run();
}Replace my_game with your package name (hyphens become underscores). The full
walkthrough — including the lib-vs-binary rationale, package-name placeholder,
and pure-binary-crate workarounds — is in
references/lib-target-layout.md.
Topics
| Topic | Reference |
Why types must live in the lib target; cargo es-fluent generate invisibility footgun; full layout | references/lib-target-layout.md |
BevyFluentText derive vs FluentText<T> component; Text::new("") | references/components.md |
LocaleChangeEvent (request) vs LocaleChangedEvent (confirmation); RequestedLanguageId; Messages vs Events | references/locale-events.md |
i18n.toml full schema, assets_dir, I18nPluginConfig runtime override | references/i18n-toml.md |
generate, watch, check, clean, sync, tree, format — dev and CI workflows | references/cli.md |
rustc 1.96+ requirement; rust-toolchain.toml pin; failure modes on older toolchains | references/toolchain.md |
Gotchas
cargo es-fluent generateonly sees the lib target. Message enums declared only insrc/main.rsare invisible to the CLI and produce empty.ftloutput with no error. Move everyBevyFluentText/EsFluent-derived type tosrc/lib.rs(or a module reachable from it). See references/lib-target-layout.md.BevyFluentTextis a derive macro;FluentText<T>is the component. The derive registers refresh systems viainventory. The component is what you spawn on UI entities. In 0.19.2 the message type needsFluentMessage + Clone + Send + Sync + 'static; it does not deriveComponentitself. See references/components.md.- Minimum rustc 1.96. Older toolchains fail with cryptic trait-resolution
errors that do not mention the version requirement. Pin with
rust-toolchain.toml([toolchain]/channel = "1.96"). See references/toolchain.md. - Events are Messages. Use
MessageWriter<LocaleChangeEvent>andMessageReader<LocaleChangedEvent>— notEventWriter/EventReader(renamed in Bevy 0.17). See references/locale-events.md.
See also
bevy-ui—FluentText<T>is used alongsideText,Node, andButton.bevy-ecs-components—#[derive(Component)]patterns required byFluentText<T>.bevy-assets— how Bevy'sAssetServerloads.ftlfiles; relevant for hot-reload.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

