Replies: 5 comments 15 replies
-
|
Beta Was this translation helpful? Give feedback.
-
My take on this is that it would be great to have built-in localization support, but that the current approaches ( I think the best thing to integrate into Bevy at this stage would be the basic ingredients locale management. For example, a Then we can experiment on making localization more ergonomic and better integrated into Bevy's ECS. |
Beta Was this translation helpful? Give feedback.
-
I have just integrated Overall I agree with the analysis made above. I think it’s a very good starting point to help Bevy support localization as a first party solution. I agree that docs are very much needed and some struct naming could be improved, but overall I was able to integrate it in about a day's worth of work and going forward it’ll be much easier for me to extend the currently supported languages and add new ones. The examples especially hold it back a little, with more focussed ones it would be much clearer in my opinion how it works. One correction that I would like to do is that it does support passing arguments when retrieving a message. It does that via the Another thing that I find not ideal with Overall though, I think |
Beta Was this translation helpful? Give feedback.
-
Providing some common basis for interoperability between i18n systems seems like a great idea ! After some tinkering I have come up with an idea that allows the crates to embrace the ECS while providing a common basis on how to handle i18n, starting with the consensus on the usage of #[derive(Resource)]
pub struct Locale {
current: unic_langid::LanguageIdentifier,
fallback: unic_langid::LanguageIdentifier,
} Having some experience with integrating i18n in applications the first thing I noticed was how verbose the current solutions are, the current consensus for popular systems is to provide one simple function (ex: Trying to define a simple use case, I came up with this example: fn hello_world_system (
localization: Res<TextLocalization>
) {
let i18n = localization.use_localization();
println!( "In your language we say hello like: {}", i18n("hello") );
} You might notice, the pub trait Localization<T, K>
{
fn use_localization (&self) -> impl Fn(K) -> T;
}
impl Localization<String, &'static str> for TextLocalization {
fn use_localization (&self) -> impl Fn(&'static str) -> String {
return |key: &'static str| {
self.translate(key)
}
}
} This trait not only allows freedom of type but also error handling. While providing pretty much no verbose for the end-user. In brief, this could provide a shy but strong and flexible basis for i18n within bevy. As for the loading of resources, Since, the |
Beta Was this translation helpful? Give feedback.
-
branch: https://github.com/Exanc/bevy/tree/prototype/interoperable-i18n I18n interoperabilityJust commited to my fork of bevy a first iteration of what I think could be a basis of Bevy native I18n. This first cornerstone brings a few things:
asset_server.load(locale.to_locale_asset_path("mani_menu.txt", false)).
pub trait Localization<R, Languages>
where
Languages: Default,
Language: From<Languages>,
Self: Resource, The aimsof this first cornerstone is to standardise how we want the end-user (ie: game developers) to localize their assets wihle leaving freedom of implementation for crate developers. An example is also available: https://github.com/Exanc/bevy/blob/prototype/interoperable-i18n/examples/i18n/localization.rs Next stepI would like to get some feedback from you before commiting anymore to it. If you have any idea how we could expand it, or if something doesn't seem right. Mentions: @wilk10 @aecsocket @TimJentzsch |
Beta Was this translation helpful? Give feedback.
-
Internationalization (i18n) is important but often overlooked in games, so it's important that Bevy does this right. A 3rd party crate for i18n already exists,
bevy_fluent
, and this issue describes my thoughts on the crate.This writeup is done on version 0.8.0 of the crate.
Getting started
First thing to point out is the lack of documentation:
examples/
though)There's very little documentation right now on how to actually use the i18n features, so the best place to start is the examples. A slimmed-down version of the
minimal
example looks like:I experienced some friction with this initial, relatively simple example:
bevy_fluent
alone, this example will not compile. I also needed to addunic_langid
andfluent_content
as dependencies to the crate.fluent_content
should probably be re-exported;unic_langid
could be as well but I don't know. If it's in the public API then it should be, right?localized_hello_world
system also does a bunch of stuff relating to loading the i18n assets. This adds a ton of noise to the code for what should be a relatively simple example.Localization
derivesResource
, so an example showing how you can just addRes<Localization>
would be useful herecontent
call, which is however supported influent::FluentBundle
as well as thefluent::fluent_args!
macro. Imo it's very important to have an easy-to-use and frictionless formatting mechanism with arguments here. However I like the relative simplicity oflocalization.content("message-key")
here.In general, I like the approach of having a single
Locale
resource, and using aLocalization
to store the actual translation content, since this feels like a standard approach that an app would use:Architecture
Quickly reading through the source I like the general architecture, it's fairly simple and the module names are self-descriptive (but again, more docs would be very useful).
I'm not a fan of some of the naming like
BundleAsset
, as this is vague in meaning (the name doesn't relate to i18n in any way) and conflicts with Bevy's existingBundle
terminology (i.e. a bundle of components). In a fully qualified name likebevy_fluent::BundleAsset
it makes more sense, but if this were to be upstreamed, it should probably be renamed to make its purpose as an i18n tool clear.The "fallback chain" mechanism is somewhat unclear - it's not immediately obvious where this is configured, and how it works exactly.
The crate seems to be coupled tightly to folders - I honestly don't know if this is a good idea or not. It limits flexibility, but then again most people will be loading translations from folders.
Overall, I think the crate is in a pretty good state. My priority for this would be:
Locale
resource do?)Beta Was this translation helpful? Give feedback.
All reactions