Visual Studio改变应用文化 [英] Visual Studio Changing Application Culture

查看:99
本文介绍了Visual Studio改变应用文化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到visual studio 2010 SP1有些奇怪。



我有一个项目,在属性的设置文件中有一个语言设置字符串,用户可以使用表单中的按钮进行更改。单击按钮,应用程序重新启动并更改文化。



这是所有甜蜜而且相当直接的前进,但是,由于某种原因,我第一次运行来自Visual Studio的应用程序F5调试样式,然后单击表单中的德语按钮,应用程序重新启动但不会改变文化,但从那时起它工作正常吗?



此外,如果我构建应用程序,请转到Debug文件夹,将其复制到桌面并运行,没有问题,文化更改在首次运行时有效。什么交易???



它与应用程序重启过程有关吗?



代码是:



I have noticed something strange with visual studio 2010 SP1.

I have a project, with a language setting string in a setting file in properties, which the user can change with buttons in the form. Click the button and the applciation re-boots and changes the culture.

This is all sweet and pretty straight foward, however, for some reason, the FIRST time I run the app F5 debug style from Visual Studio, and click say the German button in the form, the app reboots but doesn''t change the culture, but it works fine from then on?

Also, if I build the app, go to the Debug folder, copy it to desktop and run, no prob, the culture change works on first run. Whats the deal???

It it something to do with the app restart process?

Code is:

public projectx()
{
    Thread.CurrentThread.CurrentCulture = new CultureInfo(Properties.Settings.Default.Language);
    Thread.CurrentThread.CurrentUICulture = new CultureInfo(Properties.Settings.Default.Language);
    InitializeComponent();
}







private void germanToolStripMenuItem_Click(object sender, EventArgs e)
{
    if (MessageBox.Show("Restart required. Proceed?", "Application Language Change", MessageBoxButtons.YesNo) == DialogResult.Yes)
    {
        Properties.Settings.Default.Language = "de-DE";
        Properties.Settings.Default.Save();
        Application.Exit();
        // Restart the app passing "/restart [processId]" as cmd line args
        Process.Start(Application.ExecutablePath, "/restart" + Process.GetCurrentProcess().Id);
    }
}

推荐答案

你可以重启德语按钮点击,也许是属性对象你如果没有在重新启动后保留值的地方更新语言字段。你应该在保存后检查。



一般来说,我不明白为什么你要求以这种方式重新启动以改变语言,有很多更简单的方法来实现地方和文化。



干杯,

江户
You can restarting on the "german" button click, perhaps the Properties object you have there does not update the Language field in a place that keeps the value for after the restart. You should check after the save.

Generally speaking I don''t understand why on earth you would require a restart in that manner for changing the language, there are far simpler ways to accomplish locality and culture.

Cheers,
Edo


这篇关于Visual Studio改变应用文化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆