Last post Nov 15, 2007 03:49 AM by Fredrik N
Nov 15, 2007 03:41 AM|djroadstar|LINK
I want for a website create mail templates and a layout template (Maybe common master page ?).
But the website is multi language, so I want to localize the mail messages. Has anyone an idea how this is possible.
Nov 15, 2007 03:49 AM|Fredrik N|LINK
You can use the Localization support shipped with .Net 2.0.
Take a look at the following post:
Add a resource file to your project. Add the mail messaage to the resource files.
MyResource.en-US.resx (the resource fil for US)
MyResource.sv.SE.resx (the rosource file for Swedish)
The .resx file is an XML based file where you use a key and a resource value for the key. The key is used to locate your resource value.
If you have added a key to the resource files you can easy access it from your code by writing:
string emailMessage = Resources.MyResource.EmailMessage;
Resources.<resource class/filename>.<resource key>
the EmailMessage in the example is the key for the resource. Microsorft uses a build provider which will take your resource file and created a typed class, which you can access from the Resources.
Based on the current Threads UICulture settings, the right resource value from a resource file will be returned.