node.js: is there no way to put HTML into i18n-node JSON translation files? -


The question says all this. If I put HTML directly (directly into a JSON-formatted) in a translation file like this:

  "test_html": "& lt; a href = 'http: //stackoverflow.com/' Click on & gt; & lt; / a & gt; ",   

I get this in my HTML:

  Click & amp; Amp; Lt; A href = & amp; # 39; Http: //stackoverflow.com/& # 39; & Amp; Gt; Here & amp; Lt; / A & amp; Gt;   

I also tried to combine in my translation file:

  "test_html_placeholder": "click on% s to% s", < / code>  

In my HTML with:

    

But similar results are available.

The only thing that I can get to work for is this constraint:

  "test_html_pre": "click", "test_html_link": "here" , "Test_html_post": ".",   

with:

   & Lt; / A & gt; & Lt;% = __ ('test_html_post') & gt%;   

But it is not nearly as cumbersome that it is not nearly worth it, and in addition in some words the word order will force me to put some empty string in my translation files, which i18n -node doesn 'It seems as if the name of the key is exited while facing this blank string.

I also tried to use "\" as the escape character in front of the symbols, but I got an invalid JSON error when I raised the sails (restart the server).

Any thoughts, executive? I'm using sails.js, it was not my decision, but I stuck with it and it comes with i18n-node. Considering the use of another library like this day on this project, is not completely out of the question.

Whether to include (html-) code in language files:

Try using

  & lt;% - __ ('& lt; A href = "#" & gt; Click & lt; / a & gt;')% & gt; ; Instead of   
  & lt;% = __ ('& lt; a href = "#" & gt; & lt; / a & gt;') pre> 

%> In an ez (Pal default template engine)

a '& lt;% =' will escape any HTML tag while '& lt;% -' keeps output without touching it . I'm pretty sure that you will find unnecessary HTML in your .json files, I18n does not make any changes other than JSON.stringify () , but to prevent almost all the template engine xssi by default the strings Avoid it.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -