-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add localization support 1 #226
Conversation
990101e
to
571b93b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes should hopefully fix the layout invalidation issues reported on Discord.
dbb42f6
to
15343ac
Compare
Issues: * Labels for checkboxes should change when the `dynamic_locale` is changed.
The labels change dynamically, but sometimes they are clipped/cropped.
Issues: * The updated label is only shown when the local changes.
…numbers for the counter and prevent overflow.
d5d8d3e
to
c655883
Compare
This refactor attempts to address these concerns from the current implementation: - Window title and other strings needed a new type that could either be a hardcoded string or a localized string. - The Window title needs to be evaluated in a context where DynamicDisplay isn't possible: the window itself isn't a widget, and so a WidgetContext can't be created to pass into DynamicDisplay. - The Fluent bundle was reparsed on a per-window basis - The fallback logic only ever created a fallback for the system locale. When there is an overridden locale, we need to support looking up into fallback locales that might match. - Fallback logic needed to look in all possible fallback bundles, not just the first bundle that exists. - This feature adds quite a few dependencies, so it now has a feature flag enabling and disabling it.
I've done a major refactoring on this to introduce the The example has been updated and that's probably the best place to see the diff of most of the API changes: 64d06a5#diff-42a98171141d7e7760d41d679d6f551d906f60bcf7ff44babd6c577c514c923f |
- IntoValue conveniences for localization args - MakeWidgetWithTag for Localize, removing all need for into_label usages - Renamed localized to localized_in.
Removed all references to "translations" and wrote overview documentation
I've finished these changes and am going to get this merged. If you have any feedback on my updates, please don't hesitate to either comment here, chat on Discord, or open up new issues! Thank you for getting this work started! |
Current state: work-in-progress.
TODO:
Initial cut of localization support using Fluent.
See
examples/localized.rs
.Features:
Localized
to allow for multiple translations to be used at the same time. Use-case is a form designer or report viewer where the main application is in one-language, but you want to preview a form or report in a different language. It works in the same way to being able to override the theme for a widget.Screenshots:
In this screenshot, the window uses the default locale, and the first container shows a label using the window's default locale.
The second container shows a label using a specific locale. The third container is using uses a dynamic locale which can be changed using the radio buttons. It has buttons which update a dynamic value which is used as an argument for a translation.
In this screenshot, the language was changed to "Spanish (Spain)" and the "+" button was clicked once. Here we can see the translations were used.
Fluent translation file for 'es-ES' in the screenshots above is as follows:
In this screenshot, we can see what the UI looks like when no translations are provided.
Limitations:
Acknowledgements: