【发布时间】: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