本地化 html 静态文本
可能的重复:
asp.net 内嵌标记中的全球化差异
我在 MSDN 上阅读了有关本地化的内容静态文本和本地化控件,但我仍然不明白:我应该如何本地化例如 html 表的静态文本?
<table>
<tr>
<td>
<%=Resources.Resource1.String1 %>
</td>
</tr>
<tr>
<td>
<%=Resources.Resource1.String2 %>
</td>
</tr>
</table>
或者
<table>
<tr>
<td>
<asp:Localize ID="Column1" runat="server" Text="<%$ Resources: Resource1, String1 %>" />
</td>
</tr>
<tr>
<td>
<asp:Localize ID="Column2" runat="server" Text="<%$ Resources: Resource1, String2 %>" />
</td>
</tr>
</table>
第一个显然更具可读性,我不需要在运行时更改翻译。也许它与第二个相比有一些缺点?我对我的愚蠢问题感到抱歉,但我想确保我选择的方式会更可取且可维护。
Possible Duplicate:
asp.net globalization difference in inline tags
I read on MSDN about localization of static text and Localize control but I still don't understand: how should I localize for example a html table's static text?
<table>
<tr>
<td>
<%=Resources.Resource1.String1 %>
</td>
</tr>
<tr>
<td>
<%=Resources.Resource1.String2 %>
</td>
</tr>
</table>
or
<table>
<tr>
<td>
<asp:Localize ID="Column1" runat="server" Text="<%$ Resources: Resource1, String1 %>" />
</td>
</tr>
<tr>
<td>
<asp:Localize ID="Column2" runat="server" Text="<%$ Resources: Resource1, String2 %>" />
</td>
</tr>
</table>
The first is obviously is more readable and I don't need to change translations on runtime. Maybe it has some disadvantages vs second? I'm sorry for my stupid question but I want to be sure that way which I'll select will be more preferable and maintainable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您展示的示例实际上没有任何区别。第一个将更容易编码 - 您将看到 IntelliSense(代码完成)提示。
就我个人而言,我更喜欢隐式本地化,因为它会给你默认值我觉得代码不那么混乱:
此外,我发现 App_LocalResources 是本地化 Asp.Net 应用程序的更好方法 - 您需要将翻译拆分为多个 .resx 文件,这在大型代码库中可能更容易维护(例如,使用 翻译记忆库 软件;成本应该更低)。
有关隐式本地化的更多信息,请参阅我的之前的回答。
The examples you showed do not really make any difference. The first one will be easier to code - you will see IntelliSense (code completion) hint.
Personally I prefer Implicit Localization for it will give you defaults and I feel the code is less cluttered:
Also, I find App_LocalResources to be a better way for Localizing Asp.Net applications - you would need to split your translation into several .resx files, which might be just easier to maintain in large code base (for example it would be easier to use Translation Memory software; it should cost less).
For more information on Implicit Localization, see my previous answer.
第二个将为您提供一个控件,您可以从代码中引用其 ID 以动态更改。第一个没有这个能力。例如:
The second one will give you a Control whose ID you can reference from code to change on the fly. The first one does not have this ability. For example: