Quantcast
Channel: VBForums - WPF, WCF, WF
Viewing all articles
Browse latest Browse all 256

Need help understanding Resource strings and locales

$
0
0
Hi!

I am confused. We have written a vb.net wpf app where the user is supposed to change languages of the UI texts by selecting a dropdown list and tehn restarts the app, the selected locale is saved in registry and the below method is called on PAge_LOad

The texts are in resx-files. As it is prepared, we have the english texts in the resource files you edit by right clicking the wpf project and select the resources tab. Then in the project, we have another resx file named "Resources.sv-SE.resx" which contains swedish translations.

In the code, we use the My.Resources.TextName to access the text, and in the xaml we add a xmlns to the My.Resources namespace and access it is as a x:Static.

To change the translations we use this method:

Code:

Private Sub ChangeLocale(locale As String)
        Dim culture = New CultureInfo(locale)
        Thread.CurrentThread.CurrentCulture = culture
        Thread.CurrentThread.CurrentUICulture = culture
        FrameworkElement.LanguageProperty.OverrideMetadata(GetType(FrameworkElement), New FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)))
    End Sub


The problem is that when calling the method with sv-SE it nworks perfectly, both from xaml and from code the strings change to swedish texts.

But when calling it with en-US it woerks ONLY from code behind and not xaml.

I tried to change the language of windows 8 to en-US and then running the app without the above code it changes everything to english. WHat is wrong here, why doesn't it work when ruynning the above code to change language? Is there something we need to reinitialize? WHat is the difference?

Help me understand...


/Henrik

Viewing all articles
Browse latest Browse all 256

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>