{"id":327,"date":"2012-01-17T23:21:59","date_gmt":"2012-01-18T04:21:59","guid":{"rendered":"http:\/\/littlesvr.ca\/grumble\/?p=327"},"modified":"2012-12-05T00:49:44","modified_gmt":"2012-12-05T05:49:44","slug":"html-tags-inside-translated-strings","status":"publish","type":"post","link":"http:\/\/littlesvr.ca\/grumble\/2012\/01\/17\/html-tags-inside-translated-strings\/","title":{"rendered":"HTML tags inside translated strings"},"content":{"rendered":"<p>Here&#8217;s something not many people working with PO files have run into. What happens when your english\/translated string contains a &lt;b&gt; tag and you try to display that string on a webpage? Luckily I have one of those (in Asunder, where it&#8217;s actually a GTK formatting tag, not an HTML tag), so I ran into this problem already.<\/p>\n<p>Piece of cake to fix, PHP has a function called htmlspecialchars() which will escape the special-meaning characters such as &#8220;&lt;&#8221; in strings. I can use that function before sending my strings over as HTML.<\/p>\n<p>Now what happens if my PHP sends the browser not HTML but JSON, and I construct the page using the data in that JSON? Any guesses? Nothing happens. Because I create a DOM text node and put the string into there &#8211; it just shows up with the &#8220;&lt;&#8221; and &#8216;&#8221;&#8216; and all the other special chars.<\/p>\n<p>Cool.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s something not many people working with PO files have run into. What happens when your english\/translated string contains a &lt;b&gt; tag and you try to display that string on a webpage? Luckily I have one of those (in Asunder, where it&#8217;s actually a GTK formatting tag, not an HTML tag), so I ran into &hellip; <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-andrew","4":"post-327","6":"format-standard","7":"category-ostd","8":"category-safeforseneca"},"_links":{"self":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/327","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/comments?post=327"}],"version-history":[{"count":3,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/327\/revisions"}],"predecessor-version":[{"id":586,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/327\/revisions\/586"}],"wp:attachment":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/media?parent=327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/categories?post=327"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/tags?post=327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}