Share via

Language not refreshing on runtime

Puri, Sahil 20 Reputation points
2024-01-27T06:53:38.92+00:00

I am trying to change the language from resx in setting page through Shell navigation. But it is not reflecting the changes at runtime in MAUI application. If i am relaunching the app it is working fine from the App.xaml.cs file. I want a solution to change it on runtime in the same launch without again launching the application. Below is the sample code i am using for that. Any guesses on why it is not happening or what is missing in this?

Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(a);
AppResources.Culture = Thread.CurrentThread.CurrentUICulture;
var vv = MauiProgram.ServiceProvider.GetService<Views.MyPage>();             App.Current.MainPage = new Services.NavigationService(vv);
Developer technologies | .NET | .NET Multi-platform App UI

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.