Click here to Skip to main content
15,889,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on Localization in WPF.I have two resources files one for english and one for french.Through dropdownlist i am changing the language but the text is not changing according to the language
C#
private void cmb_Loaded_1(object sender, RoutedEventArgs e)
      {
          cmb.Items.Add("en-US");
          cmb.Items.Add("fr-FR");
      }

      private void cmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
      {
          var comboBox = sender as ComboBox;
          string value = comboBox.SelectedItem as string;
          Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(value);
          SelectLanguage(value);
          InitializeComponent();
      }


C#
  private void SelectLanguage(string str)
        {

            // Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(str);
            switch (str)
            {
                case "en-US":

                    TranslationManager.Instance.TranslationProvider = new ResxTranslationProvider
                                ("WpfAppl.Global-en-US", Assembly.GetExecutingAssembly());
                    break;
                case "fr-FR":

                    TranslationManager.Instance.TranslationProvider = new ResxTranslationProvider
                                ("WpfAppl.Global-fr-FR", Assembly.GetExecutingAssembly());

                    break;
}
Posted
Updated 13-Oct-15 21:25pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900