Visual Studio 本地化和表单:asp:button、asp:CheckBox 仅读取默认语言 .resx 文件
我使用 Visual Studio 2010 (VB)/asp.net 4.0 本地化了我的大部分网站。
一切进展顺利,但我正在尝试本地化 contactengineering.aspx。在这里,我有两个问题:asp:checkbox 和 asp:button。他们不读取 fr、de 和 es 文件 - 只读取默认的 contactengineering.aspx.resx,即 en。
我所做的就是在 VS 中创建资源文件(工具/生成本地资源),将其放入 App_LocalResources 目录中。谜底就在这里。我的 asp:label 也没有翻译。但我将此修复放入:
<h1><asp:Label ID="Label1" runat="server"
Text="<%$ Resources:LocalizedText, contacteng1 %>"></asp:Label></h1>
并且我将 contacteng1 的字符串放入我的根文件夹中的 App_GlobalResources 中,并将其本地化为所有语言。
问题在这里
同样,我的 asp:button 和 asp:checkbox 函数未本地化。他们从默认的 /App_LocalResources/contactengineering.aspx.resx 读取。我尝试了我想出的“修复”,将其移至 GlobalResources,但它不起作用。
这是我尝试本地化的代码:
<asp:CheckBox ID="CheckBoxCC" runat="server"
Text="does not matter what I put here"
meta:resourcekey="CheckBoxCCResource1" />
<br />
<br />
<asp:Button ID="SubmitForm" runat="server" OnClick="SubmitForm_Click"
Text="Submit Form" meta:resourcekey="SubmitFormResource1" />
除了此按钮和复选框之外,整个页面都已本地化。有人能告诉我我需要做什么吗?我真诚地感谢任何人在这方面可以向我提供的任何帮助。
I have localized most of my website, using Visual Studio 2010 (VB)/asp.net 4.0.
It's mostly going well, but I'm trying to localize contactengineering.aspx. Here, I have two issues: asp:checkbox and asp:button. They're not reading the fr, de, and es files -- only the default contactengineering.aspx.resx, which is en.
What I did was created the resource files in VS (tools/generate local resource), which put in a directory for App_LocalResources. Here's the mystery. My asp:label didn't translate either. But I put this fix in:
<h1><asp:Label ID="Label1" runat="server"
Text="<%$ Resources:LocalizedText, contacteng1 %>"></asp:Label></h1>
And I put a string for contacteng1 in my App_GlobalResources in my root folder, and it localized in all languages.
Here's the problem
Similarly, my asp:button and asp:checkbox functions aren't localizing. They're reading from the default /App_LocalResources/contactengineering.aspx.resx. I tried the "fix" I came up with, moving it to GlobalResources, but it doesn't work.
Here's my code that I'm trying to localize:
<asp:CheckBox ID="CheckBoxCC" runat="server"
Text="does not matter what I put here"
meta:resourcekey="CheckBoxCCResource1" />
<br />
<br />
<asp:Button ID="SubmitForm" runat="server" OnClick="SubmitForm_Click"
Text="Submit Form" meta:resourcekey="SubmitFormResource1" />
The entire page is localized except for this button and checkbox. Could anybody tell me what I need to do? I would sincerely appreciate any help anybody could offer me in this regard.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我刚刚通过反复试验找到的修复方法——现在已经研究了一段时间——以防有人遇到类似的问题。我不知道这是否正确或(推荐),但它确实有效。
我将: 替换
为:
并且将字符串 contacteng11 和 contacteng12 及其各自的值添加到我的 App_GlobalResources 目录中的每种语言 .resx 文件中。
Here's the fix I just found via trial and error -- been working on it for awhile now -- in case anybody has any similar issues. I don't know if this is proper or (recommended), but it's what worked.
I replaced:
with:
And I added the strings contacteng11 and contacteng12 and their respective values to each language .resx file in my App_GlobalResources directory.
如果您使用的是 Viual Studio,我通过查看网站的“属性窗口”并将“可本地化”属性从“默认”更改为“是”来解决了类似的问题。
If you're using Viual Studio, I fixed the similar problem I had by looking at the website's "Properties Window" and changing the "Localizable" property from "Default" to "Yes".