Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: macros generates invalid ICU message for nested selects #365

Merged
merged 1 commit into from
Oct 15, 2018

Conversation

Nodge
Copy link
Contributor

@Nodge Nodge commented Oct 14, 2018

Babel macros generates invalid ICU messages for nested select/plural.

Example source code:

select('id', {
  value: "male",
  male: select({
    value: true,
    true: "He invites guests",
    other: "He does not invite guests"
  }),
  female: `She is ${gender}`,
  other: `They is ${gender}`
});

Expected message:

{0, select, male {{1, select, true {He invites guests} other {He does not invite guests}}} female {She is {gender}} other {They is {gender}}}

Actual message (missing brackets after male):

{0, select, male {1, select, true {He invites guests} other {He does not invite guests}} female {She is {gender}} other {They is {gender}}}

lingui complie throws error for this message:

Error: Can't parse message. Please check correct syntax: "{0, select, male {1, select, true {He invites guests} other {He does not invite guests}} female {She is {gender}} other {They is {gender}}}"

@tricoder42
Copy link
Contributor

Wow, good catch! I'm gonna release it tomorrow. Thank you very much!

@codecov
Copy link

codecov bot commented Oct 15, 2018

Codecov Report

Merging #365 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #365   +/-   ##
=======================================
  Coverage   95.86%   95.86%           
=======================================
  Files          49       49           
  Lines        1379     1379           
=======================================
  Hits         1322     1322           
  Misses         57       57
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 a9750ed...8fef269. Read the comment docs.

@tricoder42 tricoder42 merged commit 28aea44 into lingui:master Oct 15, 2018
@Nodge Nodge deleted the fix-macro-select branch October 15, 2018 17:48
@tricoder42
Copy link
Contributor

Released in v2.7.1

Photonios pushed a commit to SectorLabs/js-lingui that referenced this pull request Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants