简体   繁体   English

如何在不重新编译的情况下将键/值添加到语言(* .resx)文件中?

[英]How to add key/values to language (*.resx) files without having to re-compile?

In a forthcoming .Net CMS, we will have several language-specific *.resx files. 在即将发布的.Net CMS中,我们将有几个特定于语言的* .resx文件。

The CMS will give users the ability to define new labels and fields. CMS将使用户能够定义新的标签和字段。 These labels can be presented in any language available in the system, ie English and French. 这些标签可以系统中可用的任何语言(即英语和法语)显示。

When users define new labels, they will require new key values. 用户定义新标签时,他们将需要新的键值。 I am currently leaning toward using *.resx files but not sure how to accomplish adding new key/values at runtime without having to recompile. 我目前倾向于使用* .resx文件,但不确定如何在运行时完成添加新键/值而不必重新编译。

You can achieve that by using the ResourceWriter class: 您可以通过使用ResourceWriter类来实现:

IResourceWriter resWriter = new ResourceWriter("myResources.resources");
resWriter.AddResource("DemoString", "My String");

Hava a look at: 哈瓦看看:

https://msdn.microsoft.com/en-us/library/system.resources.resourcewriter.aspx https://msdn.microsoft.com/en-us/library/w3ywst3t(v=vs.110).aspx https://msdn.microsoft.com/zh-CN/library/system.resources.resourcewriter.aspx https://msdn.microsoft.com/en-us/library/w3ywst3t(v=vs.110).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM