A client wants to be able to add any language to the multilingual MVC-based site I'm currently building.
They would be responsible for providing the translations themselves and while the process doesn't need to be enabled through a GUI it needs to be simple enough, so recompiling the project is a no-go. Editing text files (possibly XMLs) is OK.
Using a semicolon-separated list of language codes in the Web.config
file (for example: en-US;de-GE
and so forth) and using RESX
files inside the App_GlobalResources
folder I am able to satisfy the conditions... at least as long as the resources are used inside the Razor pages or MVC controllers.
There is a problem, however - any attempt to use the resources in MVC view model classes (such as the Display
attribute or the Compare
attribute) throws an error:
System.InvalidOperationException: Cannot retrieve property 'Name' because localization failed. Type '[Resource Type Here]' is not public or does not contain a public static string property with the name '[Resource Name Here]'.
There are several questions dealing with this already on StackOverflow, but ALL of them revolve around turning the resource files from content files into embedded resources. While this might make the code function it's no good for me because the resources can no longer be edited by the client!
What else can I do in this case?