全球化和句子中的链接 [英] Globalization and links in sentences
问题描述
我正在使用C#作为后端来全球化/本地化asp.net应用程序。我们正在将字符串提取到资源文件,并遇到了问题。我们试图将句子保持在一起,以便它们可以翻译,但链接不可能。例如:
I am working on globalizing/localizing an asp.net application with C# as the backend. We are in the process of extracting strings to a resource file, and have run into a problem. We are trying to keep sentences together so that they are translatable, but this is not possible with links. For Example:
<%= Strings.BeginningOfSentence %>
<asp:HyperLink id="exampleLink" runat="server"><%= Strings.MiddleOfSentence %></asp:HyperLink>
<%= Strings.EndOfSentence %>
字符串是资源文件。如果这是链接的正常html,我可以使用String.Format并将句子保持在一起,将html作为两个参数添加,但这在这里打破了它。如何使这项工作有任何想法?
Strings is the resource file. If this were normal html for the link, I could use String.Format and keep the sentence together, adding in the html as two parameters, but that breaks it here. Any ideas in how to make this work?
推荐答案
您不必使用HyperLink控件吗?如果需要动态链接,则可以将锚标记存储在参数化字符串中,并使用string.Format添加必要的属性值,如您所建议的那样。这样的事情:
You don't have to use a HyperLink control for this do you? If you need a dynamic link then you can store the anchor tag in a parameterised string and add the necessary attribute values using string.Format, like you suggested. Something like this:
代码:
myLiteral.Text = string.Format("{0} <a href=\"{1}\">{2}</a> {3}", Strings.BeginningOfSentence, myUrl, Strings.MiddleOfSentence, Strings.EndOfSentence);
ASPX:
<asp:Literal id="myLiteral" runat="server" />
这篇关于全球化和句子中的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!