I am creating an ASP.NET web application in C#, and have to localize the application into English and French. I have created two resources files: App_GlobalResources\\Resources.resx and App_GlobalResources\\Resources.fr.resx containing the english and french content.
When I run the application with my browser set to French (fr_FR), the french content is correctly displayed in the markup.
Within the code-behind, when I access values from the resources, it returns the default english values only. eg
this.CompanyName.Text = string.Format(App_GlobalResources.Resources.CompanyLocationsFormat, companyName);
Debugging the app shows that the CurrentCulture and CurrentUICulture are both correctly set to fr_FR.
Can anyone explain how I can get the code-behind to use the culturally-appropriate resource file?
Many thanks
(C#, ASP.NET 3.5 SP1, Visual Studio 2008, IE 8.0.7600)
Are you certain that this specific resource (CompanyLocationsFormat) exists in the french resources file? If a resource is missing, it will fall back to the default one.
在web.config的<system.web>
部分中是否有此功能?
<globalization culture="auto" uiCulture="auto" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.