.NET already supports multiple resources across multiple cultures using a naming convention:
<default resource file name>.<culture>.resx
Essentially, as Josh pointed out, VS2008 creates a secure, secure wrapper to access these resources.
However, the VS UI provides a minimal bear of what you can do.
If you are creating a new resource file, which is called exactly the same as the default, add culture information before resx. (NOTE: You will need to create it somewhere else and then copy it to the magic properties folder.)
Then your application will, if you apply the culture to the thread accessing the resource, pull the correct string from certain resources.
For instance:
// Using the default culture string s = Resources.Error1Msg; Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-CO"); // Using the specific culture specified as above: s = Resources.Error1Msg;
If you need to parameterize your message, use string.Format to parameterize the output.
One caveat is to try to archive your application tiers so that your exceptions carry a rich payload (to describe the error) instead of relying solely on text.
Thus, your presentation level can provide the best user interface experience that can use the payload.
NTN
Philip
source share