C#的本地化和卫星程序集 [英] Localization and Satellite Assemblies with C#

查看:80
本文介绍了C#的本地化和卫星程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我用一种形式(Form1)设置了解决方案.我有一个形式为(textBox1)的文本框.我在解决方案中有一个文件夹,可以进行卫星装配(de-DE).我已按照以下方式运行resgen:
resgen Form1.resx de-DE \ Form1.de-DE.resx
这是将表单资源文件复制到该文件夹​​中.
我从那里再次运行resgen来创建.resources文件,并从该文件中运行程序集链接器.我正在尝试让程序根据位于de-DE的CurrentCulture设置从de-DE文件夹中提取资源.但是,我对此一无所知.有什么想法吗?



I have my solution set up with one form (Form1). I have one text box in the form (textBox1). I have a folder in the Solution for the satellite assembly to go (de-DE). I have run the resgen as follows:
resgen Form1.resx de-DE\Form1.de-DE.resx
this is to duplicate the form resource file into that folder.
I have run the resgen again from there to create the .resources file and from that run the assembly linker. I am trying to get the program to pull the resources from the de-DE folder based on the CurrentCulture setting being at de-DE. But I am not getting anywhere with it. Any thoughts?

推荐答案

您不需要从身边拉任何东西.看看这些文章,看看如何在本地化中处理事物.它基于当前的简单线程.
使用附属程序集本地化Windows应用程序 [ ASP.NET 2.0中神秘化的全球化和本地化 [
You don''t need to pull anything from your side. Have a look at these articles to see how things are handled in localization. It''s simple current thread based.
Localizing a Windows Application with Satellite Assemblies[^]
Globalization and localization demystified in ASP.NET 2.0[^]


尝试一下:
Try this:
public static void SetCulture(string culture)
{
    try
    {
        Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture);
    }
    catch
    {
        Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
    }
}


只需提供 culture ="de-DE" .


Just give culture = "de-DE".


这篇关于C#的本地化和卫星程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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