| Crates.io | bevy_locales |
| lib.rs | bevy_locales |
| version | 0.1.0 |
| created_at | 2025-11-24 17:16:31.041356+00 |
| updated_at | 2025-11-24 17:16:31.041356+00 |
| description | A Simple i18n for bevy |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1948211 |
| size | 100,096 |
This project is a wrapper around bevy_fluent, designed to simplify localization in Bevy applications.
Cargo.toml[dependencies]
bevy_locale = "0.1.0"
main.rsapp
.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.ronYour .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.
The .ftl files follow the standard Fluent syntax, allowing for variables and advanced localization features.
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.
| Bevy | bevy_locales |
|---|---|
| 0.16.0 | 0.1.0 |