【问题标题】:How to localize text with including Html.ActionLink如何本地化包含 Html.ActionLink 的文本
【发布时间】:2012-04-11 08:32:49
【问题描述】:

我有这样的文本要本地化

<p>Please enter your user name and password. @Html.ActionLink(@Resources.Register, "Register") if you don't have an account. </p>

文本中经常有一个 ActionLink。

我可以为整个 ActionLink 使用类似 {0} 的东西吗

@string.Format(Resources.LogOn_Enter_Message, Html.ActionLink(@Resources.Register, "Register"))

(这不起作用,因为链接变成了字符串)
还是我必须将段落分成两部分?

【问题讨论】:

    标签: c# asp.net asp.net-mvc-3 razor localization


    【解决方案1】:

    你应该这样做:

    @Html.Raw(string.Format(Resources.LogOn_Enter_Message, Html.ActionLink(@Resources.Register, "Register")))
    

    并存储您的本地化字符串:

     <p>Please enter your user name and password. {0} if you don't have an account. </p>
    

    【讨论】:

    • Gaaah 我是如此接近 :-) 谢谢。
    猜你喜欢
    • 1970-01-01
    • 2013-11-12
    • 2020-06-11
    • 1970-01-01
    • 1970-01-01
    • 2019-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多