【问题标题】:node-localize : Save and render html syntax and tags information in translation filesnode-localize : 在翻译文件中保存和渲染 html 语法和标签信息
【发布时间】:2023-04-08 01:59:01
【问题描述】:

我正在将 Node.js 和 ExpressJS 与 node-Localize (https://github.com/AGROSICA/node-localize) 一起用于网站。

我有一个网页,其中包含由多个段落分隔的传记 (<p></p>)。

有没有办法在我的翻译文件中保存和呈现 html 语法和标签信息?

"Bio" : {
    "en-US" : "<p>A first paragraphe of information</p><p>And a second one</p>",
    "fr" : "<p>Un premier paragraphe d'information</p><p>Et un deuxième</p>"
}

/*And the html...*/
<%= translate("Bio")%>

因为我不想使用下面的语法

"BioParagraphe1" : {
    "en-US" : "A first paragraphe of information",
    "fr" : "Un premier paragraphe d'information"
},
"BioParagraphe2" : {
    "en-US" : "And a second one",
    "fr" : "Et un deuxième"
}

/*And the html...*/
<p>
    <%= translate("BioParagraphe1")%>
</p>
<p>
    <%= translate("BioParagraphe2")%>
</p>

【问题讨论】:

    标签: node.js express localization


    【解决方案1】:

    我找到了一个解决方案,我能够使用以下 sintax 从字符串中呈现我的 html 内容

    /*I'm using the "<%-" instead of the "<%=" */
    <%- translate("BioParagraphe1")%>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-09
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-11
      相关资源
      最近更新 更多