繁体   English   中英

使用node.js时的i18next段落

[英]i18next paragraph when using nodejs

我正在使用http://jamuhl.github.com/i18next/node/ ,它工作正常,但对于一个我似乎无法解决的问题。

就是这样,我在/locales/dev/translation.json中有这个translation.json文件

{
  "tzm": "Chapters - Zeitgeist Movement"
  ,"welcome": [
    "<p>The Zeitgeist Movement is an explicitly non-violent, global sustainability advocacy group currently working in over 1000 Regional Chapters across 70 countries.</p>"
    ,"<p>The basic structure of The Movement consists of Chapters, Teams, Projects & Events. Overall, the Chapters are essentially what define the Movement and each Chapter works to not only spread awareness about the roots of our social problems today but also to express the logical, scientific solutions and methods we have at our disposal to update and correct the current social system and create a truly responsible, sustainable, peaceful, global society.</p>"
  ]

在我的刀片模板中,我具有以下内容:

div#page
   p=t("welcome")

问题是我得到了html标签,请查看专门设置内部html的文档http://i18next.com/pages/sample.html

使用i18next-node和显示段落部分的正确方法是什么,我以前做过的方法是:

  ,"welcome": {
    "p1":"The Zeitgeist Movement is an explicitly non-violent, global sustainability advocacy group currently working in over 1000 Regional Chapters across 70 countries."
    ,"p2":"The basic structure of The Movement consists of Chapters, Teams, Projects & Events. Overall, the Chapters are essentially what define the Movement and each Chapter works to not only spread awareness about the roots of our social problems today but also to express the logical, scientific solutions and methods we have at our disposal to update and correct the current social system and create a truly responsible, sustainable, peaceful, global society."
  }

然后我的page.blade模板如下所示:

div#page
   p=t("welcome.p1")
   p=t("welcome.p2")

对于少量数据,这可以正常工作,但是如果您有很多段落,可能会很无聊。

想知道,但不应该像

div#page
    p!=t("welcome")

至少在翡翠中,这样会设置未转义的内容。

我会使用node-blade随附的markdown过滤器来获取纯文本内容。

我做到了这一点,并且可以正常工作,尽管您可以在页面加载中看到初始的<p> ,然后显示段落。 您可以看到它http://blade.eu01.aws.af.cm/

p(data-i18n="[html]welcome")=t("welcome")

我看着你的页面。 它确实以这种方式添加了两个段落。 一个带有p(data-i18n =“ ...”),另一个带有p!= t(“ welcome”)。 对我来说,这似乎是与刀片模板引擎有关的问题。 我会在那里开一个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM