I have a ‘GUI Strings’ .resx file in my application that holds all the strings that I display. I can obviously access each string directly via Resources.Resource_GUI_Strings.CameraSettings_BrightnessLabel
But how do I list all the settings in the .resx file, as their (name, value) pair, is my only option using reflection?
I want to list all the pairs (i.e. CameraSettings_BrightnessLabel & ‘Brightness’) so that the user can edit the string for each item. This is so they can localise the GUI. I don’t want to fully internationalise the app, the requirements are only for the user to be able to do it themselves.
So I need to be able to read the pairs of values from the .resx file and then write them back if the users edits them.
Just to add I want to do this at runtime inside the application itself, so I can’t parse the .resx file on disk.
Normally I’d use the ResXResourceReader and ResXResourceWriter classes, but my guess is that your resx files will be locked at runtime. You may be better off storing the text in a database instead of resource files to get around this.
This answer shows how to make a custom resource provider / resource manager to store/edit resources in the database. Alternatively you could forgo the resource model altogether and roll your own solution.