none
Exception handling in multilingual application. RRS feed

  • Question

  • our ,net application will be available in canada for use, we have developed multilingual application in such away that based on the location, the UI will changed,however, we aer logging the system exceptions for support/issue fixing, however, in Canada, the application will run in Windows (French version) and the exception will be in french, but we want the exception to get logged in English, any help/advise wil be greatly appreciated.
    Wednesday, August 31, 2011 1:41 AM

Answers

  • Correct. Installing the language pack will also install resource file for that language. Hence, your desired output will be in that language.
    Please mark this post as answer if it solved your problem. Happy Programming!
    • Marked as answer by Paul Zhou Wednesday, September 7, 2011 7:02 AM
    Wednesday, August 31, 2011 3:56 PM

All replies

  • I think you need to set current culture to en-US and let the Current UI culture be French.


    Please mark this post as answer if it solved your problem. Happy Programming!

    Wednesday, August 31, 2011 4:49 AM
  • Adavesh,

    Thanks for the reply, let me summarise what we have done

    1.our application currently runs in Windows(English version).

    2. We have set the current thread's culture to en-US which is by default as our application runs in windows(English version)

    3. In the catch part, we set the current culture to fr-FR(so that the curent culture would be in french) and ran the application.

    4. We are throwing the exception message

    4. We ran the application, however, the thrown exception is in english(but we are expecting in french) since we have changed the current thread to french inside the catch part).

    Code

    In form1

      private void Form1_Load(object sender, EventArgs e)
            {
                CultureInfo oldCulture = Thread.CurrentThread.CurrentCulture;
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("fr-CA");

                try 
                {   
                    System.IO.StreamReader sr=new System.IO.StreamReader(@"c:\haha");
                   

                } 
                catch(Exception ex) 
                {   
                    Console.WriteLine(ex.ToString());
                    ExceptionLogger el = new ExceptionLogger(ex);   
                    System.Threading.Thread t = new System.Threading.Thread(el.DoLog); 
                                       
                    t.CurrentUICulture = new System.Globalization.CultureInfo("fr-CA");   
                    t.Start(); 
                } 

        }

    Exception logger class

    class ExceptionLogger  {   
         Exception _ex;     
            public ExceptionLogger(Exception ex)   
            {      _ex = ex;   
            }     
            public void DoLog()   
            {
                    MessageBox.Show(_ex.ToString());
            }
     
        }

     

    Any advise please

     

    Wednesday, August 31, 2011 2:23 PM
  • Your original question was getting exception messages in English right?

    anyways, Is it your development machine or client machine? If it is your development machine I think you need to install French language pack.


    Please mark this post as answer if it solved your problem. Happy Programming!

    Wednesday, August 31, 2011 2:49 PM
  • Thanks Adavesh,

    Yes, since, i want to check how it works in development machine  which in WIndows xp(english version) -

    So, you are advising to install french language pack for this development machine, is that correct

     

    Secondly, if i need to run the executable in client machine which is Windows xp(french version),

    i would need to install english language pack - is that correct.

    Also, I want to change the code - changing the currentculture to english in exception handling so that exception handling can be seen in english - Is that correct.

     

     

    Thanks a lot for your help.

     

     

     

     

    Wednesday, August 31, 2011 3:33 PM
  • Correct. Installing the language pack will also install resource file for that language. Hence, your desired output will be in that language.
    Please mark this post as answer if it solved your problem. Happy Programming!
    • Marked as answer by Paul Zhou Wednesday, September 7, 2011 7:02 AM
    Wednesday, August 31, 2011 3:56 PM
  • Thanks for your reply......

    Wednesday, August 31, 2011 4:02 PM