ttag-org / ttag

:orange_book: simple approach for javascript localization
https://ttag.js.org/
MIT License
345 stars 43 forks source link

special characters #178

Open benmonro opened 5 years ago

benmonro commented 5 years ago

We are refactoring our existing code to use ttag. We have some JSX that looks like this:

<span className={styles.calloutText}>Hello,&nbsp;</span>

then we change this to use ttag: <span className={styles.calloutText}>{t`Hello,&nbsp;`}</span>

when we run our tests (which use jest snapshots), the test fails because of the non matching snapshot.
image

note, some of our code have these types of characters interspersed inside the text, so we can't just remove it. like the word you&apos;re for example, which also fails for similar reasons.

Was hoping you could provide some advice on how to solve this problem?

AlexMost commented 5 years ago

Need to check that. ttag has a default behaviour that strips spaces - https://ttag.js.org/docs/library-api.html#setdedent. Try to use that setting for the test environment, let me know if that works.

setDedent setting was implementing for the multiline strings - https://ttag.js.org/docs/multiline-strings.html

benmonro commented 5 years ago

Yeah I tried dedent but it didn't seem to affect it