2013-02-08 44 views
0

我使用http://jamuhl.github.com/i18next/node/這工作正常,但對於我似乎無法解決的一個問題如何解決它。i18next段落時使用nodejs

這個生命的是,我有這個translation.json文件在我/locales/dev/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標籤,看文檔http://i18next.com/pages/sample.html專門設置內部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") 

,這工程確定,對於小的數據集,但它可以例如,如果你有很多段落,會變得無聊。

回答

0

我這樣做,它的工作原理,雖然你可以看到在頁面加載初始<p>的,然後段落顯示。你可以看到它http://blade.eu01.aws.af.cm/

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

當您已經在服務器上設置翻譯內容時,爲什麼要添加data-i8n屬性(僅適用於客戶端翻譯)? – jamuhl 2013-02-12 09:14:20

+0

不應該是'p(data-i18n =「[html] welcome」)!= t(「welcome」)'所以段落標籤不會在服務器端逃脫? – jamuhl 2013-02-12 09:15:16

+0

我試過這個,但我得到兩個段落顯示兩次 – khinester 2013-02-12 21:52:37

0

奇蹟,但應該不會是像

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

至少在玉石它會是這樣設置轉義內容。

我會使用純節省內容的節點刀片提供的降價過濾器。

0

我看着你的頁面。它確實增加了兩個段落。一個是p(data-i18n =「...」),另一個是p!= t(「welcome」)。對我來說,這似乎是與刀片模板引擎有關的問題。我會在那裏開一個問題。

+0

我最初使用節點刀片來編譯頁面,然後我在客戶端使用jQuery來切換語言,而不是用/?lang = fr-FR重新加載頁面。可能混合兩者? 'p!= t(「welcome」)'在節點刀片上工作良好,但是當使用jQuery切換器時它不會更改語言,所以我不確定這是否是節點刀片的問題! – khinester 2013-02-18 21:50:16