CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 1999
    Posts
    66

    WPF: Change the culture when application runs.

    Hi all,

    I’m very very new in C#/WPF world, but this fascinates me more and more. Now I must find a way how our future application will use the localization / globalization. I did all the steps I found in MSDN to create this (UID, LocBaml, satellite, etc.) and I it works perfect (a little bit complicated but anyway it works). The application starts in the OS culture starts, also if I put at the beginning this code:
    public App()
    {
    Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE");
    //Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
    }
    It works perfect.
    Now I try (and I spent too much time for this issue) to change the culture online, when the application runs. Something like:
    private void CheckLanguage(object sender, RoutedEventArgs e)
    {
    Thread.CurrentThread.CurrentUICulture = new CultureInfo((german) ? "de-DE" : "en-US", true);
    }
    When the user clicks a button to change from german to English. I guess I’m too naive to believe that, but I don’t know what should I write so to get my current main window show all stuff in other language?
    For any idea thank you in advance!

    Best regards,
    Emanuil

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: WPF: Change the culture when application runs.

    I would start with a very small WPF application and follow some of the online articles to get it working before attempting this in a large scale in your application.

    A few things to check:

    Make sure that your controls have the proper localization id on them.
    Make sure that the proper satellite dlls get built.
    Make sure that the satellite dlls are stored in the proper hierarchy at runtime.

  3. #3
    Join Date
    Sep 1999
    Posts
    66

    Re: WPF: Change the culture when application runs.

    Hi Arjay,

    some "small WPF applications" I have behind me and if my boss give me this job to find a solution for localization / globalization in WPF projects, I cannot say "Hey boss the company should wait until I exercise WPF with more tutorials". Also I do not understand how the threading problematic will solve my problem.
    To your check list:
    1. all elements of the xaml windows have the UIDs given by "msbuild /t:updateuid ..."
    2. yes the satellite are built correctly, it works well if I put the wished UI-culture in the application constructor.
    3. "the satellite dlls are stored in the proper hierarchy at runtime" - this sounds like the solution.
    How should I verify this and how can I change the satellites during the programm runs (e.g. from the main window), so all open windows update to the new culture ???

    Thank you for your ideas,
    Emanuil

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured