MVC3 的资源文件命名问题 - 无法自动生成隐藏代码
我有一个使用 Razor 的 MVC3 应用程序。我想将应用程序本地化为各种语言,因此我添加了 App_LocalResources 文件夹并添加了资源文件,如下所示:
Index_cshtml.en-US.resx
Index_cshtml.en-GB.resx
但是,当我将资源文件上的代码生成设置为公共时,代码文件已创建但为空。如果我将文件重命名为 Index_cshtml_en-GB.resx,它会自动正确生成后面的代码,因此看起来 MVC 无法处理其命名约定中的“.en-GB”或“.en-US”。然而,这并不是 ASP.NET 应用程序根据区域性集了解要使用哪个资源文件的关键方式。
我确实在 ASP.NET Webform 应用程序中使用过无数次,这对于 MVC 来说有什么不同吗?
I have an MVC3 application using Razor. I want to localise the application for various languages so I added a App_LocalResources folder and added a resource files as follows:
Index_cshtml.en-US.resx
Index_cshtml.en-GB.resx
However when I set the code generation on the resource files to public, the code file is created but is empty. If I rename the file to Index_cshtml_en-GB.resx it auto generates the code behind correctly so it looks as if MVC cannot handle the '.en-GB' or '.en-US' in its naming convention. However isn't that the key way an ASP.NET application knows which resource file to use based on the culture set.
I've certainly used this countless times in ASP.NET webform applications, is it different for MVC?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于此类问题,迭代方法可能效果最好。首先你可能想尝试(注意使用 . 而不是 _)
,一旦成功就尝试
For problems like this an iterative approach might work best. First you might want to try (note the use of . instead of _)
and once that's working then try