开发者

ASP.NET localization of text with embedded link...and the link is a server control

开发者 https://www.devze.com 2022-12-22 03:52 出处:网络
I\'m working on internationalizing and localizing an ASP.NET app, and I\'m running into problems with cases where string literals are mixed with markup.Like this example:

I'm working on internationalizing and localizing an ASP.NET app, and I'm running into problems with cases where string literals are mixed with markup. Like this example:

Acme Carpet Retailers <a href="#" class="link" id="ssoLoginUrl" 
    runat="server">click here</a> to log开发者_Go百科 into the site.

For most string literals I'm using the Localize control. I can embed this in a Localize control, tags and all, but the problem is then the link isn't a server control anymore. (It's referenced on the page by its ID.)

I can't really split up the strings ("Acme Carpet Retailers", "click here", etc.) because the word order could be different in a different language.

I've seen several suggestions on how to do this, but they all assume that the text with embedded link is assigned in code, not in markup, and that it's not a server control.

Any advice on how to localize this successfully?


Can't you do just:

<%= String.Format(Resources.MyResource.mydata, 
"<a href=""#"" class=""link"" id=""ssoLoginUrl"" runat=""server"">",
"</a>"
) %>

Then I would have the resource mydata defined as: "{0}click here{1} to log into the site."


If the word order could be different in a different language, you have no choice but to localize the entire text (tag included) inside the resx.

But, of course, if this is too troublesome, you can change the app to make the text more structured:

Acme Carpet Retailers <a href="#" class="link" id="ssoLoginUrl" 
runat="server">(Log in here)</a>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号