简体   繁体   English

本地化不适用于ASPX页中的所有标记/标签

[英]Localization not working for all the Markup / Tags in ASPX page

While localizing the Content for an ASPX page through Visual studio and selecting the Option: "Generate Local Resources " the text is not getting localized for all HTMLs. 通过Visual Studio本地化ASPX页面的内容并选择选项:“生成本地资源”时,不会针对所有HTML本地化文本。 FOr example, There are <p> tags and other server control tags like Label. 例如,有<p>标签和其他服务器控制标签,如Label。

<p>Carrying out Localization on my First Website </p>
<asp:Label runat="server" ID="label1"></asp:label>

After selecting the Option: "Generate Local Resources " from "Tools" menu, below is what seen in markup: 从“工具”菜单中选择选项:“生成本地资源”后,下面是标记中显示的内容:

<p>Carrying out Localization on my First Website </p>
<asp:Label runat="server" ID="label1" meta:resourcekey="labelResource1"></asp:label>

How can I localize the content placed inside <p> tags or any <h1> , <h2> tags ? 如何本地化<p>标记或任何<h1><h2>标记内的内容?

This link provides an answer to your question on how to localize content placed inside html tags. 该链接为您有关如何本地化html标记中的内容的问题提供了答案。 You can store it in resource file and use it in html mark up as <%=Resources.WebResources.YourText%> as described there by VinayC where Resources.WebResources is strongly typed resource class generated by Visual Studio resource generator.Please let me know if this answers your question. 您可以将其存储在资源文件中并以html格式使用,标记为<%= Resources.WebResources.YourText%>(如VinayC所述),其中Resources.WebResources是Visual Studio资源生成器生成的强类型资源类。请让我知道如果这回答了您的问题。

The control that needs to be localized will have to run serverside. 需要本地化的控件必须在服务器端运行。

You could place a <asp:Label/> or <asp:Panel/> inside the HTML <p> . 您可以在HTML <p>内放置<asp:Label/><asp:Panel/> <p> A label will render to a <span/> , and a panel will render to a <div/> . 标签将呈现为<span/> ,面板将呈现为<div/>

It is also possible to run the p at serverside : <p runat="server" id="p1"></p> . 也可以在服务器端运行p: <p runat="server" id="p1"></p>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM