如何在l20n.js

时间:2017-07-01 08:41:20

标签: javascript l20n

我对l20n.js有点问题,我的字符串中的HTML总是被转义:/。

我像这样使用l20n:

<div class="col-twelve" data-l10n-id="intro-text">
    <h5>my <span style="color: whitesmoke">Title</span></h5>
    <h1>Bienvenue <span class="title-separator"></span> Welcome <span class="title-separator"></span> Willkommen</h1>
    <h5>Intro</h5>
</div>

在我的fr.ftl:

intro-text = 
    |   <h5>Mon <span style="color: whitesmoke">Titre</span></h5>
    |    <h1>Bienvenue <span class="title-separator"></span> Welcome <span class="title-separator"></span> Willkommen</h1>
    |   <h5>texte intro</h5>

但是,l20n.js会像这样渲染文字:

<div class="col-twelve" data-l10n-id="intro-text">
  |   Mon titre
  |   Bienvenue  Welcome  Willkommen
  |   texte intro
</div>

我已经完成了一些搜索

  • 在l20n修补程序中:http://l20n.github.io/tinker/我们可以选中/取消选中一个复选框以转义html,但我没有在API中找到此选项:/。

所以,我有点失落。

你知道吗?或任何其他javascript框架轻松做翻译? (我需要:单独的locales文件,没有后端只有ngninx,易于读/写为无IT的翻译)

谢谢。

1 个答案:

答案 0 :(得分:1)

嗯,所以昨天不起作用......今天它的工作......

我刚刚改变了我的ftl:

intro-text = 
|   <h5>Mon <span style="color: whitesmoke">Titre</span></h5>
|    <h1>Bienvenue <span class="title-separator"></span> Welcome <span class="title-separator"></span> Willkommen</h1>
|   <h5>texte intro</h5>

到:

intro-text = 
 <h5>Mon <span style="color: whitesmoke">Titre</span></h5>
 <h1>Bienvenue <span class="title-separator"></span> Welcome <span class="title-separator"></span> Willkommen</h1>
 <h5>texte intro</h5>

也许ftl在文本之前只需要一个空格:/。