martinandert / react-translate-component

A component for React that utilizes the Counterpart module to provide multi-lingual/localized text content.
MIT License
322 stars 31 forks source link

Escape the % Character #40

Closed saczuac closed 6 years ago

saczuac commented 6 years ago

Hi!,

When the JSON string has a "%" character the translator fails, raise the following error in console:

Uncaught SyntaxError: [sprintf] unexpected placeholder.

example JSON translate:

{
  "fee": "The fee is 4%"
}
martinandert commented 6 years ago

I think you need two percent signs to escape the '%' character: "The fee is 4%%".

saczuac commented 6 years ago

Thanks! it was the solution