开发者

C# Windows Forms Localization Testing

I have setup a windows forms project to use localization so that it will support Chinese and English languages. I have built in a way of forcing the language to one or the other when the form loads. Before InitializeComponent() is called I have a bit of code that does this...

     switch (Properties.Settings.Default.SelectedLanguage)
        {
            case "":
                break;
            case "English":
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
                Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
                break;
            case "Chinese":
                try
                {
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CHT");
                    Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-CHT");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                break;   
        }

So when the SelectedLanguage property is set to "Chinese" the program should use the Chinese localization right? I tested this while debugging and it worked exactly as expected. That is, when SelectedLanguage == "Chinese" at the program start all the buttons and labels display in the Chinese text that I entered. When the SelectedLangugage == "English" everything is displayed in the English Text that I have entered.

The problem is that when I install this program and run it (not debu开发者_开发问答gging) it doesn't work. Even on my development machine. No matter what SelectedLanguage is set to the program always displays the English Localization. I even put in a message box to pop up at the beginning of the program which displays `Application.CurrentCulture.Name' and it shows the Chinese culture name (zh-CHT) but it still displays everything in English. So what is the difference between what happens during debugging and during actual run time? And how can i fix it?!?


Make sure that your localized resources Dll are correctly installed.

Your installer should put resources files into sub-folders such as

zh-CHT\AssemblyName.resources.dll


It sounds like the english default is being used at all times, which would suggest that the resources you have set up for Chinese are not being included in the build. Double check your resources and make sure it is included in your deployment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜