Changing the language in UWP does not change the language of system functions - only when the application is restarted

I have a UWP application.

And I need to change the language on the fly, so I have this for changing the language:

Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = language.FourDigitCode;
ResourceContext.GetForViewIndependentUse().Reset();
ResourceContext.GetForCurrentView();

But there is a problem that the language of the system functions does not switch (only after restarting the application), how can I fix it?

Here is an example:

enter image description here

Now I have run this code:

Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "lv-LV";
ResourceContext.GetForViewIndependentUse().Reset();
ResourceContext.GetForCurrentView();

The user interface is localized, but system functions still remain inactive:

enter image description here

But when I restart the application, everything is fine:

enter image description here

Any ideas how I can fix this?

+4
source share
2 answers

, , , , - . PrimaryLanguageOverride :

PrimaryLanguageOverride, Languages. . , QualifierValues . , .

. , , , , , . enter image description here
, Application.Exit, .

Application.Current.Exit();
+2

, ? . .

//like this
private bool Reload(object param = null)
{
    var type = Frame.CurrentSourcePageType; 
    Frame.Navigate(type, param);
    Frame.BackStack.Remove(Frame.BackStack.Last());
}

// or like this
private bool Reload(object param = null)
{
    var frame = Window.Current.Content as Frame; 
    frame.Navigate(frame.CurrentSourcePageType, param);
    frame.BackStack.Remove(frame .BackStack.Last());
}
0

Source: https://habr.com/ru/post/1672570/


All Articles