/bevy-skills:bevy-fluentfrom bevy-skills
Adds Fluent-based localization to Bevy 0.20 apps using es-fluent-manager-bevy 0.21. Covers typed messages, FluentText UI wrapping, locale switching, and hot-reload of .ftl assets.
Ships in bevy-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
es-fluent-manager-bevy = "0.21", which depends on bevy = "0.20.1").#[derive(EsFluent)] and #[derive(BevyFluentText)].FluentText<T> for automatic locale-driven refresh.LocaleChangeMessage; confirming via LocaleChangedMessage.RequestedLanguageId / ActiveLanguageId.Cargo.toml:
[dependencies]
bevy = "0.20"
es-fluent = "0.21" # `derive` is a default feature
es-fluent-manager-bevy = "0.21" # `macros` + `file_watcher` are default features
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, LocaleChangeMessage, 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 the sibling Text (and into child Text entities).
commands.spawn((FluentText::new(UiMessage::StartGame), Text::new("")));
}
pub fn switch_locale_on_keypress(
keys: Res<ButtonInput<KeyCode>>,
requested: Res<RequestedLanguageId>,
mut locale_messages: MessageWriter<LocaleChangeMessage>,
) {
if keys.just_pressed(KeyCode::KeyL) {
let next = if requested.0.to_string() == "en" { langid!("fr") } else { langid!("en") };
locale_messages.write(LocaleChangeMessage(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 — lib-vs-binary rationale, package-name placeholder, pure-binary
workarounds — is in references/lib-target-layout.md.
| 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; trait bounds; Text::new("") | references/components.md |
LocaleChangeMessage (request) vs LocaleChangedMessage (confirmation); RequestedLanguageId; ActiveLanguageId | references/locale-events.md |
i18n.toml schema, assets_dir, I18nPluginConfig runtime override | references/i18n-toml.md |
generate, watch, check, clean, sync, tree, fmt, status, doctor, add-locale | references/cli.md |
rustc 1.99+ requirement; rust-toolchain.toml pin; failure modes on older toolchains | references/toolchain.md |
Version matrix. es-fluent-manager-bevy 0.21.x requires bevy ^0.20.1 and rustc 1.99. 0.20.x targets Bevy 0.19; 0.18.x targets Bevy 0.18. Pin the crate line to your Bevy line. See references/toolchain.md.
Message types were renamed in 0.21. LocaleChangeEvent → LocaleChangeMessage, LocaleChangedEvent → LocaleChangedMessage. Both are Bevy Messages: use MessageWriter / MessageReader, never EventWriter. Stale 0.18-era snippets fail with "cannot find type LocaleChangeEvent". See references/locale-events.md.
cargo es-fluent generate only sees the lib target. Message enums declared only in src/main.rs are invisible to the CLI and produce empty .ftl output with no error. See references/lib-target-layout.md.
T no longer needs Component (0.21). FluentText<T: FluentMessage> is the component; registration requires T: FluentMessage + Send + Sync + 'static. The 0.18 ToFluentString + Clone + Component bound is gone. Keeping #[derive(Component)] on T is harmless. See references/components.md.
Bevy-side text API changed underneath (0.19/0.20). FluentText writes into Text; styling still comes from a sibling TextFont { font: FontSource, font_size: FontSize::Px(..), .. }. font_size: 24.0 and font: handle without .into() do not compile. See bevy-ui.
BevyI18n and ActiveLanguageId are exported in 0.21. The 0.18 workaround of querying bundles directly is no longer needed; use the BevyI18n system param for imperative lookups.
bevy-ui — FluentText<T> sits next to Text, TextFont, Node, and ui_widgets::Button.bevy-migration-0-19-to-0-20 — Bevy-side changes you hit while bumping the crate pair.bevy-ecs-components — #[derive(Component)] patterns for custom text wrappers.bevy-assets — how AssetServer loads .ftl files; relevant for hot-reload (file_watcher feature).What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub chrisgliddon/bevy-skills --plugin bevy-skills32 skills in this plugin
/bevyUse when starting any Bevy task, choosing between Update and FixedUpdate, picking Cargo feature flags, or recalling which sibling skill covers ECS, assets, rendering, UI, or migration. Routes to the right Bevy 0.20 skill and pins the engine version for downstream snippets./bevy-a11yUse when designing or auditing high-standard video-game accessibility in Bevy 0.20, integrating screen readers and focus navigation, supporting adaptive controllers and complete remapping, implementing captions or audio description, checking contrast and motion safety, or building disabled-player test evidence./bevy-animationUse when wiring `AnimationPlayer` + `AnimationGraphHandle`, building an `AnimationGraph` from glTF clips, blending state-driven animations with `AnimationTransitions::play`, isolating body parts with `AnimationMask`, firing gameplay sync via `#[derive(AnimationEvent)]` + `On<E>` observers, tweening with `AnimatableCurve` / `EaseFunction` / `CubicSegment::new_bezier_easing` from `bevy::curve`, or applying the 12 Basic Principles of Animation to 3D characters in Bevy 0.20.Other plugins' skills for the same job