Replies: 4 comments 10 replies
-
I've my entire App localized via DynamicResources. Just like FluentTheme I can switch the lang at runtime with no effort. As the resources can be overridden, I can also have different language in a sub control. Moreover this approach would not tie us to strings only, as we can also localize images via DynRes. See: https://github.com/timunie/Tims.Avalonia.Samples/tree/main/src%2FLocalizationSample I've an Excel File that can create the .xaml files for me. This can also be an avalonia App we can share for anyone to manage their languages. That said, I'm completely open to other ideas as well. |
Beta Was this translation helpful? Give feedback.
-
This is a complex topic, but for now my main concerns are the following:
|
Beta Was this translation helpful? Give feedback.
-
This has been discussed a few places now but at a high level I think localization should be done as follows:
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Upd: closed with #13773
Currently, our controls hardcode English localization. Which makes it pretty hard to localize applications in another way.
As this task isn't trivial, I want to start at least some discussion about it, so we can initiate a solution within 11.0.
How to use and replace localized strings (most important)
3.1. DevExpress does it by creating a localizer class per each control. They also have ready-to-use helpers like CreateResXLocalizer().
3.2. Telerik by default users RESX, but also allows to replace LocalizationManager
3.3. More examples?
Dynamic language change
CultureInfo class doesn't have any events when UI thread culture was changed.
So, we have to invalidate controls when some specific Avalonia event was changed.
Some platforms also have system language changed events. Not sure though if it should be handled by Avalonia or by the developer's app.
How to store localized strings per culture
My API proposal
Avalonia side:
Users code side:
Questions to this implementation:
xml:lang
?Alternative solutions that also might be considered
Beta Was this translation helpful? Give feedback.
All reactions