1
votes

For testing purpose, I'm trying to localize a dummy application, in order to see what match the best our needs.

I wanted to try WPF Localization Extension.

So I :

  1. Created a whole new WPF application, created a main windows.

  2. Added the references to WPF Localization Extension through nugget.

  3. Created one resx named Localization.resx and one Localization.fr.resx

  4. I Added in both resx a text for the "WelcomeText" key.

  5. In main windows, I put:

    xmlns:lex="http://wpflocalizeextension.codeplex.com"
    lex:LocalizeDictionary.DesignCulture="en"
    lex:ResxLocalizationProvider.DefaultAssembly="LocalizedApplication"
    lex:ResxLocalizationProvider.DefaultDictionary="Localization"
    

    In the Window declaration

  6. I added one TextBlock within the grid: <TextBlock Text="{lex:Loc WelcomeText}" />

If I run the application, I've the text displayed in english.

Now I add the following in the App.cs constructor:

    public App():base()
    {
        Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr");
        Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture;
        CultureInfo.DefaultThreadCurrentCulture = Thread.CurrentThread.CurrentUICulture;
        CultureInfo.DefaultThreadCurrentUICulture = Thread.CurrentThread.CurrentUICulture;
    }

To test the application in FR. I rebuild and restart, but I still get the message in english.

So first: What did I do wrong? Then: How should I change the current culture at runtime?

1

1 Answers

3
votes

In fact, I think I just found the answer.

It seems that it doesn't use the CurrentCulture and that you have to set it with:

LocalizeDictionary.Instance.Culture = new CultureInfo("fr");

Sorry for the issue