2

In a forthcoming .Net CMS, we will have several language-specific *.resx files.

The CMS will give users the ability to define new labels and fields. These labels can be presented in any language available in the system, i.e. 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.

ElHaix
  • 12,846
  • 27
  • 115
  • 203
  • 1
    XML is possibly the worst possible format for a database. A CMS needs a database, don't cut that corner. – Hans Passant Jun 18 '16 at 14:11
  • If dynamic language support is one of the main features of your cms, take full control over it and don't rely on resource files. Make it a first class citizen in your code (database/services). resx or i18n/gettext are better suited for static translations. – Remco Ros Jun 18 '16 at 18:10

1 Answers1

0

You can achieve that by using the ResourceWriter class:

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

Avi K.
  • 1,734
  • 2
  • 18
  • 28
  • Wouldn't you have to recompile the solution after adding a new key/value pair to make use of the new resx entry? – ElHaix Jun 18 '16 at 14:48
  • You can achieve that without recomilation but it will have other side effects. Check this: http://stackoverflow.com/questions/11544027/edit-asp-net-mvc-3-resx-files-in-deployment-server-without-recompiling. I guess you should use the database solution. – Avi K. Jun 18 '16 at 15:00