Skip to content

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

Merged
tricoder42 merged 1 commit into
lingui:masterfrom
Nodge:fix-macro-select
Oct 15, 2018
Merged

fix: macros generates invalid ICU message for nested selects#365
tricoder42 merged 1 commit into
lingui:masterfrom
Nodge:fix-macro-select

Conversation

@Nodge

@Nodge Nodge commented Oct 14, 2018

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Oct 15, 2018

Copy link
Copy Markdown

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
Copy Markdown
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