gpt4 book ai didi

html - 在 Rails 翻译文件中使用 HTML

转载 作者:技术小花猫 更新时间:2023-10-29 11:38:14 26 4
gpt4 key购买 nike

我在我的 Rails 应用程序 (config/locale/[en|de].yml) 中有一些翻译,我在我的 View 中使用了它 <%=t "teasers.welcome" %> .示例:

teasers:
welcome: "<strong>Welcome</strong> to the Website ..."

在 Rails 2.3.8 中,这工作得很好,在 Rails 3 中,HTML 被转义并翻译成 &lt; ...如何防止这种形式的这种翻译并在我的翻译文件中使用 HTML,就像在 Rails 2.3.8 中一样?

最佳答案

除了使用 raw 之外,还有另一种未记录(但官方)的方法。所有以 _html 结尾的键都会自动呈现为未转义。

从中重命名 key

teasers:
welcome: "<strong>Welcome</strong> to the Website ..."

teasers:
welcome_html: "<strong>Welcome</strong> to the Website ..."

关于html - 在 Rails 翻译文件中使用 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3626038/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com