I'm trying to use resource files in an ASP.NET Web Forms application (.NET 4.0). I'm using VS2012. I have the following files inside the App_GlobalResources
folder:
Address.resx
(default language, English)Address.ja-JP.resx
(Japanese)
The problem is when I'm trying to display the text in Japanese in an ASP.NET page (*.aspx file). If I use the following syntax everything works fine:
<%= Resources.Address.Street1 %>
But when I try to bind it to a property of an asp:Label
control the default text (English) is displayed instead of Japanese:
<asp:Label ID="lblStreet1" runat="server" Text='<%$ Resources:Address,Street1 %>'></asp:Label>
BTW culture is being set in session variables and then in the master page I have something like this:
Thread.CurrentThread.CurrentCulture = (CultureInfo) Session["ci"];
Thread.CurrentThread.CurrentUICulture = (CultureInfo) Session["uci"];
Also, I don't know if this is relevant or not but I generated the Address.ja-JP.resx
outside Visual Studio (using Notepad++) and then moved the file to the App_GlobalResources
folder and included the file in the solution.
Am I missing something here?
I was able to find a solution to my problem. In the code behind I had to override the InitializeCulture method, I did something like this: