jeresig / i18n-node-2

Lightweight simple translation module for node.js / express.js with dynamic json storage. Uses common __('...') syntax in app and templates.
MIT License
507 stars 79 forks source link

HTML character entities are not handled properly #95

Closed kdidenko closed 7 years ago

kdidenko commented 8 years ago

When using HTML character entities they are not displayed properly. For example: #{__("— or —")} is translated to: — or —

Is there any way to escape & so it will be converted to &? Then everything should work fine. It is very strange that only & is converted since when I'm using #{__("— or —")} the entity is not converted to — and is rendered in html as is.

gjuchault commented 8 years ago

Why don't you use UTF-8 files ? And do what you said: #{__("— or —")}

SamBellerose commented 7 years ago

@gjuchault Can you give more details on how I can use HTML in my json files ? I understand the UTF-8 files format, but how can I achieve this? Is there a config in i18n-2?

gjuchault commented 7 years ago

@SamBellerose You can use UTF-8 files directly and avoid thinking about encoding and HTML chars. Let's say you want the mdash character (—). Instead of

{ "foo": "—" }

Use

{ "foo": "—" }