Skip to content

Fix escaped backticks in macro-transformed template strings#477

Merged
tricoder42 merged 2 commits into
lingui:masterfrom
ackwell:fix-backticks
Mar 21, 2019
Merged

Fix escaped backticks in macro-transformed template strings#477
tricoder42 merged 2 commits into
lingui:masterfrom
ackwell:fix-backticks

Conversation

@ackwell

@ackwell ackwell commented Mar 20, 2019

Copy link
Copy Markdown

To use a literal backtick in a template string (such as for markdown code blocks), it needs to be escaped (const str = `\``;).

Unfortunately, this gets picked up as \\` due to value.raw, which ends up as a literal \` in the translation string.

In turn, this leads to final translation strings ending up with the literal \` , which is broken syntax, throwing a Error: Can't parse message. Please check correct syntax".

This PR provides a quick fix for the issue, allowing backticks to be used.

@codecov

codecov Bot commented Mar 21, 2019

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@0e673f5). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #477   +/-   ##
=========================================
  Coverage          ?   91.09%           
=========================================
  Files             ?       51           
  Lines             ?     1415           
  Branches          ?        0           
=========================================
  Hits              ?     1289           
  Misses            ?      126           
  Partials          ?        0
Impacted Files Coverage Δ
packages/macro/src/js.js 99.25% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e673f5...2fd1030. Read the comment docs.

1 similar comment
@codecov

codecov Bot commented Mar 21, 2019

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@0e673f5). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #477   +/-   ##
=========================================
  Coverage          ?   91.09%           
=========================================
  Files             ?       51           
  Lines             ?     1415           
  Branches          ?        0           
=========================================
  Hits              ?     1289           
  Misses            ?      126           
  Partials          ?        0
Impacted Files Coverage Δ
packages/macro/src/js.js 99.25% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e673f5...2fd1030. Read the comment docs.

@tricoder42 tricoder42 merged commit e1bfbf7 into lingui:master Mar 21, 2019
@tricoder42

Copy link
Copy Markdown
Contributor

It looks mostly harmless.

Good job! 👍

@ackwell ackwell deleted the fix-backticks branch March 22, 2019 01:10
@tricoder42

Copy link
Copy Markdown
Contributor

Released in v2.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants