【问题标题】:getting the CultureInfo from the existing ResourceSet从现有的 ResourceSet 中获取 CultureInfo
【发布时间】:2015-04-26 09:59:08
【问题描述】:

我有一个在我的代码中使用的资源集。一切正常,但因为我的一些用户使用 RTL,我需要知道哪个 ResourceSet 是活动的。 如果在此代码之后,我一定会很高兴:

CultureInfo ci = CultureInfo.GetCultureInfo(language);
Assembly localisationAssembly = Assembly.Load("Resources");
ResourceManager rm = new ResourceManager("Resources.MyResource", localisationAssembly);
ResourceSet rs = rm.GetResourceSet(ci, true, true);

我能做到:

CultureInfo ci2 = rs.GetCultureInfo();

【问题讨论】:

  • ResourceSet 不存储该信息,它是 ResourceManager 维护文化与其关联的 ResourceSet 之间的关联。不要丢失用于创建它的信息,请使用变量。目前尚不清楚您以后如何使用rs,但Dictionary<ResourceSet, CultureInfo> 将是一种简单的方法。
  • 我只使用 rs.GetString("KeyName")。谢谢你,我会寻找另一种方法
  • 好吧,那么你确实有 rs 并且字典可以是预言机。
  • 是的,我会按照你建议的方式使用它

标签: c# cultureinfo resourcemanager


【解决方案1】:

正如@Hans在评论中提到的那样,由于ResourceSet不存储信息,所以无法完成。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-18
    • 1970-01-01
    • 1970-01-01
    • 2010-12-02
    • 2011-05-11
    • 1970-01-01
    相关资源
    最近更新 更多