C#创建了多语言设置 [英] C# Creating a setup for multi-language

查看:435
本文介绍了C#创建了多语言设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加使用下面的短文多国语言。



当您添加例如德语您将有以下文件:
formMain.resx
formMain.de-DE.resx
formMain.Designer.cs
formMain.cs



在第一个文件,你将拥有资源的中性语言,如字符串,图像..



所以,现在你还需要增加资源,在代码中使用的字符串。添加新的资源文件,并将其命名为formMain.Strings.resx
然后,我将进入的名称,值对每个应该翻译的字符串。当您添加资源文件,它会自动键入因为名字formMain.Strings.Designer.cs另一个文件自动在RESX设计师的每一个接近再生。



添加一个名为formMain.Strings.de-DE.resx其他资源。添加相同的名称关键的从以前的资源,只需更改与coresponding德语单词中的价值。现在从它会像这样源接入创建的资源



MessageBox.Show(formMain_Strings.SameStringName);



不过,我已经改变了我对泰语。当我运行我的应用程序VS一切正常。



然而,当我添加一个安装项目并安装客户端机器上也不会改变的语言泰国和只是不断为默认语言。



所以我加入了资源文件和TH-TH的DLL项目设置。我仍然得到同样的问题。

 包装文件'Lang.Strings.resx'... 
包装文件MultiLanguage.resources.dll'...
包装文件'MultiLanguage.exe'...
包装文件'Lang.Strings.th-TH.resx'...

因为一切都在Visual Studio中运行时工作正常。有什么我需要做的就是它一旦其被安装运行。所有属性每个我有保持默认的文件。



非常感谢,



=== ======

 静态无效的主要()
{
System.Threading.Thread。 CurrentThread.CurrentUICulture =
新System.Globalization.CultureInfo(TH-TH);

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(假);
Application.Run(新Form1中());
}


解决方案

我找到了答案



点击Solution Explorer中的安装项目,然后单击Add\Project Output\。从对话框中选择您要包括本地化(卫星)组装,然后选择本地化的资源项目。



文件夹中,我安装到,我有安装后本站第-TH文件夹,其中包括卫星组装。



谢谢,


I have added multi-language using the short article below.

When you add for example German language you will have these files: formMain.resx formMain.de-DE.resx formMain.Designer.cs formMain.cs

In first file you will have resources for neutral language, like strings, images, ..

So now you need to add also resources for strings used in code. Add a new resource file and name it formMain.Strings.resx Then i will enter name, value pair for every string that should be translated. When you add resource file then it is automatically typed because another file with name formMain.Strings.Designer.cs is automatically regenerated on every close of resx designer.

Add another resource with name formMain.Strings.de-DE.resx. Add the same Name key's from previous resource, and just change the Value with coresponding german words. Now to access created resource from the source it will be like this.

MessageBox.Show(formMain_Strings.SameStringName);

However, I have changed my to Thai language. Everything works fine when I run my app in VS.

However, as soon as I add a setup project and install on the clients machine it won't change the language to Thai and just keeps to the default language.

So I have added the resource files and the th-TH dll to the project setup. And I still get the same problem.

Packaging file 'Lang.Strings.resx'...
Packaging file 'MultiLanguage.resources.dll'...
Packaging file 'MultiLanguage.exe'...
Packaging file 'Lang.Strings.th-TH.resx'...

As everything works fine when running in visual studio. Is there something I need to do to get it to run once its been installed. All the properties for each of the file I have keep the default.

Many thanks,

=========

static void Main()
    {
        System.Threading.Thread.CurrentThread.CurrentUICulture = 
new System.Globalization.CultureInfo("th-TH");

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }

解决方案

I found the answer

Click the Setup Project in Solution Explorer and then click Add\Project Output\ . From dialog select the project for which you want to include localization (satelite) assemblies and then select Localized resources.

After the installation in the folder that I install to, I have the th-TH folder which includes the satellite assembly.

Thanks,

这篇关于C#创建了多语言设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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