1 unstable release
Uses new Rust 2024
| 0.1.0 | Nov 24, 2025 |
|---|
#175 in Internationalization (i18n)
27KB
165 lines
bevy_locale
This project is a wrapper around bevy_fluent, designed to simplify localization in Bevy applications.
Usage
Cargo.toml
[dependencies]
bevy_locale = "0.1.0"
main.rs
app
.insert_resource(Locale::new(zh::TW).with_default(zh::TW))
.add_plugins(bevy_locales::I18nPlugin {
filepath: vec!["locales/zhtw/zhtw.ftl.ron".to_string()],
});
// ...
locales/zhtw/zhtw.ftl.ron
Your .ron file should look like this:
(
locale: "zh-TW",
resources: [
"card.ftl",
]
)
If you support multiple languages, simply create additional .ftl.ron files for each locale.
Fluent Files
The .ftl files follow the standard Fluent syntax, allowing for variables and advanced localization features.
UI Integration
To localize UI elements, use the I18n component like this:
command.spawn((
Node,
Text::new(txt.clone()),
I18n("txtkey"),
));
The system will automatically replace the text with the appropriate translation based on the current locale.
✅ Compatibility
| Bevy | bevy_locales |
|---|---|
| 0.16.0 | 0.1.0 |
Dependencies
~73MB
~1.5M SLoC