PolymerElements / app-localize-behavior

Polymer behaviour to help internationalize your application
48 stars 55 forks source link

New lines in resource string #50

Closed ndvalkov closed 8 years ago

ndvalkov commented 8 years ago

How do you process a longer JSON string with new lines in it? <br/> gets escapes, \n or \\n\\n do nothing or break, tried <pre> to wrap the localize placeholder, didn't work either. Only way I see is to split the resource into smaller ones, which is not quite OK.

notwaldorf commented 8 years ago

I'm not sure that's possible in the underlying format.js library we're using, since the behaviour is just marshalling attributes to them. Does your example work there?

ndvalkov commented 8 years ago

No idea. I need it for just a couple of text blocks and it's an informal project, so I'll just split into separate resources for the paragraphs. Thanks.

JosefJezek commented 8 years ago

@ndvalkov You need use innerHTML of element.

gaxolio commented 8 years ago

@JosefJezek , how can I use innerHTML if I need to localize into :

[[localize('xyz')]] works when I put in content something like: aaa
bbb does not works if I put in content [[localize('xyz')]]. It display "aaa
bbb". Thanks
JosefJezek commented 8 years ago

@gaxolio Please post better example of issue...

gaxolio commented 8 years ago

@JosefJezek, here a better example: this is from "locales.json" , "en" section "tooltipXyz": "<br />Bytes added/removed from ingress to egress. <br />Ingress UNI Pop: -4. <br />Egress MPLS (Remote) with 1 label: +4",

this code inside the tag show 3 lines when the mouse is hover. `


Bytes added/removed from ingress to egress.
Ingress UNI Pop: -4.
Egress MPLS (Remote) with 1 label: +4",

this code instead, show the string with the BR tag included.

[[localize('tooltipXyz')]]

"
Bytes added/removed from ingress to egress.
Ingress UNI Pop: -4.
Egress MPLS (Remote) with 1 label: +4"," ` I hope I was clear. Sergio

JosefJezek commented 8 years ago

<paper-tooltip for="ingressEgressProcessing"><s-html html="[[localize('tooltipXyz')]]"></s-html></paper-tooltip>

https://github.com/StartPolymer/s-html

bower i StartPolymer/s-html -S

gaxolio commented 8 years ago

@JosefJezek . Many thanks for your help. It works!.

Sinjins commented 8 years ago

Excellent @JosefJezek. Another thanks.

notwaldorf commented 8 years ago

Closing this, as this seems to be resolved? Let me know if I misunderstood and I'll reopen it