How to Change Language at Run Time?

Themes, Shared, and Core Libraries for Avalonia Forum

Posted 3 days ago by Water_Me10n
Version: 26.1.0
Avatar

Hello,

I saw "You should paste this code in your application startup so that it is run before any user interface has been loaded." in "Customizing String Resources" Chapter, it seems dynamic change language is not allowed at runtime,  is this True?

Best Regards.

Comments (1)

Answer - Posted 3 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

That is primarily since some UI string resources could be applied as the default value for Avalonia properties in their static initializer, and those only occur once per app lifetime.  We generally provide public properties where you could update those property values programmatically after a language change.

There are also some cases where string resource values are assigned to properties in XAML templates.  That value would not update unless the control's template was reapplied.

Those two reasons are why we generally recommend that you restart the application after a language change, to ensure all possible string resource updates are applied properly.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.