formatjs / formatjs-old

The monorepo home to all of the FormatJS related libraries.
https://formatjs.io/
156 stars 53 forks source link

Values placed in ' ' are not replaced #210

Closed luciaam closed 4 years ago

luciaam commented 4 years ago

Which package? intl-messageformat

Describe the bug Messages with values placed in ' ' misinterpreted.

To Reproduce Steps to reproduce the behavior:

  1. Define a message with a placeholder within '' i.e.: var msg = new IntlMessageFormat('My name is \'{name}\'.', 'en-US');
  2. Try to format it with a name var output = msg.format({name: "Eric"});
  3. See the output: console.log(output); // => "My name is {name}."

Expected behavior The expected output would be "My name is 'Eric'."

Desktop (please complete the following information):

longlho commented 4 years ago

ICU message format uses apostrophe to escape so you need to double apostrophe ('') to get the character to show up.

On Thu, Oct 3, 2019 at 2:44 AM luci notifications@github.com wrote:

Which package? intl-messageformat

Describe the bug Messages with values placed in ' ' misinterpreted.

To Reproduce Steps to reproduce the behavior:

  1. Define a message with a placeholder within '' i.e.: var msg = new IntlMessageFormat('My name is \'{name}\'.', 'en-US');
  2. Try to format it with a name var output = msg.format({name: "Eric"});
  3. See the output: console.log(output); // => "My name is {name}."

Expected behavior The expected output would be "My name is 'Eric'."

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: N/A
  • Version Node.js v10.15.3

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/formatjs/formatjs/issues/210?email_source=notifications&email_token=AABQM33V5RWYJ52KGINAH7DQMWIGLA5CNFSM4I47DBO2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HPKEISQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AABQM33LOUSFOQ2EYGMGU6LQMWIGLANCNFSM4I47DBOQ .

longlho commented 4 years ago

Example: https://codesandbox.io/s/react-intl-test-jznj1

luciaam commented 4 years ago

Thanks for the hint