huo*_*125 7 c# globalization embedded-resource
当我们想要为所有用户(说不同的语言)申请时,我们需要一种全球技术.
在C#中,我们使用ResourceManager如下:
using System;
using System.Reflection;
using System.Resources;
public class Example
{
public static void Main()
{
// Retrieve the resource.
ResourceManager rm = new ResourceManager("ExampleResources" ,
typeof(Example).Assembly);
string greeting = rm.GetString("Greeting");
Console.Write("Enter your name: ");
string name = Console.ReadLine();
Console.WriteLine("{0} {1}!", greeting, name);
}
}
// The example produces output similar to the following:
// Enter your name: John
// Hello John!
Run Code Online (Sandbox Code Playgroud)
程序集有两个或多个语言资源:
Assembly
| --Assembly.en-us.resx
| --Assembly.zh-cn.resx
然后我们通过更改线程cultureinfo来使用不同的资源来存档以更改资源.
如果应用程序有很多dll(汇编)文件.
我想为应用程序提供一个单点(一种语言的一个资源文件),
对我的想法有一个很好的解决方案吗?
在我更改View(例如,Winform或UserControl)Language以实现相应语言的不同UI之前.
只需使用您描述的方式在 C# 中构建国际化即可。但作为构建过程的最后一步,您可以运行Fody.Costura。
这将获取所有不同的 dll 并将它们打包到您的应用程序中,以便您只有一个包含所有内容的 .exe 文件。
好处是您可以按预期使用 C# 国际化框架,无需任何修改,但您仍然可以获得可以交付给客户的单个 exe。
| 归档时间: |
|
| 查看次数: |
2566 次 |
| 最近记录: |