简体   繁体   English

如何在C#中使用多语言

[英]How to use Multi language in C#

I'm trying to prepare an application with more languages available. 我正在尝试准备具有更多可用语言的应用程序。 I prepared the simplest example to learn it, I done a lot of tentative but I'm not able to do it. 我准备了最简单的示例来学习它,我做了很多尝试,但是我做不到。

CultureInfo cul = new CultureInfo("de-De");           
Resources.Culture = new System.Globalization.CultureInfo("de-De");

label1.Text = TestLanguages.Properties.Resources.Saluto;

In my application I have two resources different resources , one for Italian language, one for German. 在我的应用程序中,我有两种不同的资源,一种用于意大利语,一种用于德语。

  • Italian Resource : Saluto -> Ciao 意大利资源:Saluto-> Ciao
  • German Resource : Saluto -> Hallo 德语资源:萨卢托->哈洛

资源资源

But I can't use the German one. 但是我不能用德语。 How can I do it? 我该怎么做?

You have to change the UI culture of the currently executing thread. 您必须更改当前正在执行的线程的UI文化。

System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-De");
label1.Text = TestLanguages.Properties.Resources.Saluto;

See the documentation for Thread.CurrentUICulture 请参阅Thread.CurrentUICulture的文档

Gets or sets the current culture used by the Resource Manager to look up culture-specific resources at run time. 获取或设置资源管理器用于在运行时查找特定于文化的资源的当前区域性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM