需要使用的ResourceManager +的GetString支持文化或者我可以只是在资源文件直接点? [英] Need to use ResourceManager + GetString to support cultures OR I can just point directly at the resource file?

查看:459
本文介绍了需要使用的ResourceManager +的GetString支持文化或者我可以只是在资源文件直接点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一些资源文件来保存字符串。我直接在像这样

  TestLocalResource.ThisMyTest 

现在,它似乎工作,但是这只是直接在默认的资源文件指向IE的RESX而不是RESX例如德国版?



我一定要使用资源管理器。如何在资源管理器知道当前的语言或事实上,你怎么设置呢?



这是我怎么会使用资源管理器?



  ResourceManager的resmgr =新的ResourceManager(MyApplication.MyResourceAssembly.GetExecutingAssembly()); 



任何帮助或建议将衷心感谢。



正如我所说调用这个真的很容易,但我不确定是否会考虑什么文化我在或其称为RESX(wihout任何语言)直接

  TestLocalResource.ThisMyTest 


解决方案

您不需要明确使用ResourceManager结果
看看这里:的 http://geekswithblogs.net/mapfel/archive/2008/11/01/126465.aspx 结果
要了解如何更改过程中使用的文化运行时,看到href=\"http://geekswithblogs.net/mapfel/archive/2008/11/01/126465.aspx#435744\" rel=\"nofollow\">中的链接第二个评论的

 开关(comboBox1.Text)
{
案中性:
Thread.CurrentThread .CurrentUICulture =新的CultureInfo();
中断;
案EN-GB:
Thread.CurrentThread.CurrentUICulture =新的CultureInfo(EN-GB);
中断;
案去-DE:
Thread.CurrentThread.CurrentUICulture =新的CultureInfo(去-DE);
中断;
}

串MessageText中= Messages.MsgSampleText;
MessageBox.Show(MessageText中);


I have create some resource files to hold strings. I am displaying a messagebox by pointing it directly at the resource file like so

TestLocalResource.ThisMyTest

Now it appears to work, but is this just pointing directly at the default resource files i.e. the Resx rather than German version of the resx for example?

Do i have to use the resource manager. How does the Resource Manager know the current language or indeed, how do you set it ?

This is how i would use Resource Manager?

ResourceManager resmgr = new ResourceManager("MyApplication.MyResource ", Assembly.GetExecutingAssembly()); 

Any help or advice would be gratefully appreciated.

As i say calling this is really easy but i am unsure if it takes into account what culture i am in or its called the RESX (wihout any language) directly

TestLocalResource.ThisMyTest

解决方案

You don't need to use the ResourceManager explicitly.
Have a look here: http://geekswithblogs.net/mapfel/archive/2008/11/01/126465.aspx
To learn how to change the culture to use during runtime, see the second comment in the link:

switch (comboBox1.Text)
{
    case "neutral":
        Thread.CurrentThread.CurrentUICulture = new CultureInfo("");
        break;
    case "en-GB":
        Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");
        break;
    case "de-DE":
        Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE");
        break;
}

string messageText = Messages.MsgSampleText;
MessageBox.Show(messageText); 

这篇关于需要使用的ResourceManager +的GetString支持文化或者我可以只是在资源文件直接点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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