This is what I have derived from the video.
- This only applies for Framework 2.0 and above (not applicable for Framework 1.1).
- We need to override the InitializeCulture in the page class (or codebehind class).
The resulting html tag will be as follows:
<asp:Label ID="lblMessage" runat="server"
Text="<%$ Resources:LocalizedText, Msg1 %>"></asp:Label>
For example if the ClassKey is "LocalizedText", then the resx files will be:
LocalizedText.fr.resx for French
LocalizedText.ms.resx for Malay
LocalizedText.resx for the default.
In the above example the files should all be placed in App_GlobalResources under the application folder (just like there is a bin under the application folder).
As for the resource entry, this is a sample of the resource file entry interface in Visual Studio:
This is a sample of the overridden method:
Protected Overrides Sub InitializeCulture()
Dim lang As String = Request("Language1")
If lang IsNot Nothing Or lang <> "" Then
Thread.CurrentThread.CurrentUICulture = New CultureInfo(lang)
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang)
In the above example, I used the dropdownlist similar to the video:
<asp:DropDownList ID="Language1" runat="server" AutoPostBack="True">
However, given the logic, we can also use a url parameter, radio button etc to identify the language.
To deployment, it will be like normal with the additional App_GlobalResources folder to copy.
This was the key thing I was looking for. In majority of the examples I saw, the language is automatically detected based on the browser setting. This will not work if the users are sharing a public computer to access the site.