diff --git a/packages/macro/src/js.js b/packages/macro/src/js.js index eebdcc478..c043c0e7f 100644 --- a/packages/macro/src/js.js +++ b/packages/macro/src/js.js @@ -117,7 +117,7 @@ export default function({ types: t }) { value = props.text } else if (t.isCallExpression(attr.value)) { props = transformMethod(attr.value, file, { ...props, text: "" }) - value = props.text + value = `{${props.text}}` } else { value = attr.value.value } diff --git a/packages/macro/test/fixtures/select/actual.js b/packages/macro/test/fixtures/select/actual.js index c014407ea..742d928eb 100644 --- a/packages/macro/test/fixtures/select/actual.js +++ b/packages/macro/test/fixtures/select/actual.js @@ -32,3 +32,14 @@ select('id', { female: `She is ${gender}`, other: `They is ${gender}` }); + +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}` +}); \ No newline at end of file diff --git a/packages/macro/test/fixtures/select/expected.js b/packages/macro/test/fixtures/select/expected.js index 61c8eb8d2..30869f432 100644 --- a/packages/macro/test/fixtures/select/expected.js +++ b/packages/macro/test/fixtures/select/expected.js @@ -1,5 +1,5 @@ ( /*i18n*/{ - id: "{gender, select, male {numOfGuests, plural, one {He invites one guest} other {He invites # guests}} female {She is {gender}} other {They is {gender}}}", + id: "{gender, select, male {{numOfGuests, plural, one {He invites one guest} other {He invites # guests}}} female {She is {gender}} other {They is {gender}}}", values: { gender: gender, numOfGuests: numOfGuests @@ -8,7 +8,7 @@ ( /*i18n*/{ id: "id", - defaults: "{0, select, male {1, plural, one {He invites one guest} other {He invites # guests}} female {She is {gender}} other {They is {gender}}}", + defaults: "{0, select, male {{1, plural, one {He invites one guest} other {He invites # guests}}} female {She is {gender}} other {They is {gender}}}", values: { 0: "male", 1: 42, @@ -18,10 +18,20 @@ /*i18n: description*/({ id: "id", - defaults: "{0, select, male {1, plural, one {He invites one guest} other {He invites # guests}} female {She is {gender}} other {They is {gender}}}", + defaults: "{0, select, male {{1, plural, one {He invites one guest} other {He invites # guests}}} female {She is {gender}} other {They is {gender}}}", values: { 0: "male", 1: 42, gender: gender } }); + +( /*i18n*/{ + id: "id", + defaults: "{0, select, male {{1, select, true {He invites guests} other {He does not invite guests}}} female {She is {gender}} other {They is {gender}}}", + values: { + 0: "male", + 1: true, + gender: gender + } +}); \ No newline at end of file