在rails上使用带有许多html标记的i18n,哪种方法是正确的还是最好的



我有一个类似的代码需要添加到i18n中,我想知道哪种方法是最好/最安全的。现在我在i18n上按原样放置它,并在带有变量和html_safe的ruby代码上调用它,但我不知道这是否意味着任何安全隐患,我还想过将html标记作为i18n变量的参数传递

<p>Através dos princípios da<strong> economia colaborativa </strong> e do <strong>
<span id="yellow">poder da tecnologia</span></strong> nosso modelo de negócio
alia a <strong> <span id="green"> expertise do executive search </span></strong>
<strong><span id="red">, a </span></strong>importância das relações humanas <strong> e o<span id="blue">alcance das redes</span>

您可能希望为整件事提供本地化的片段(Rails指南:本地化视图(:

自己文件中的西班牙语版本

# marketing.es.erb
<p>Através dos princípios da<strong> economia colaborativa </strong> e do <strong>
<span id="yellow">poder da tecnologia</span></strong> nosso modelo de negócio
alia a <strong> <span id="green"> expertise do executive search </span></strong>
<strong><span id="red">, a </span></strong>importância das relações humanas <strong> e o<span id="blue">alcance das redes</span>

然后英文版

# marketing.en.erb
<p>Something<strong> in english</strong>...  <strong>
<span id="yellow">... </span></strong>

并自动包含正确的部分

(other content)
<%= render :marketing %>

最新更新