File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -238,7 +238,7 @@ export default function ({ types: t }) {
238238 . buildCodeFrameError ( "Only strings are supported as comments." )
239239 }
240240
241- props [ key . name ] = value . value
241+ props [ key . name ] = value . value || t . isTemplateLiteral ( value ) && value ?. quasis [ 0 ] ?. value ?. cooked || ``
242242 } )
243243
244244 collectMessage ( path , file , props )
Original file line number Diff line number Diff line change @@ -16,6 +16,24 @@ Object {
1616
1717exports [` @lingui/babel-plugin-extract-messages should extract all messages from JS files (macros) 1` ] = `
1818Object {
19+ : Object {
20+ extractedComments: Array [],
21+ origin: Array [
22+ Array [
23+ js - with - macros .js ,
24+ 30 ,
25+ ],
26+ ],
27+ },
28+ Backtick : Object {
29+ extractedComments: Array [],
30+ origin: Array [
31+ Array [
32+ js - with - macros .js ,
33+ 24 ,
34+ ],
35+ ],
36+ },
1937 Description : Object {
2038 extractedComments: Array [
2139 description ,
Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ const withTId = t({
2121 message : "Message with id some"
2222} )
2323
24+ const withTIdBacktick = t ( {
25+ id : `Backtick`
26+ } )
27+
2428const id = 'message id'
2529
2630const withUnknownId = t ( {
Original file line number Diff line number Diff line change @@ -162,6 +162,20 @@ export default [
162162 });
163163 ` ,
164164 } ,
165+ {
166+ name : "Support id in template literal" ,
167+ input : `
168+ import { t } from '@lingui/macro'
169+ const msg = t({ id: \`msgId\` })
170+ ` ,
171+ expected : `import { i18n } from "@lingui/core";
172+ const msg =
173+ i18n._(/*i18n*/
174+ {
175+ id: \`msgId\`
176+ });
177+ ` ,
178+ } ,
165179 {
166180 name : "Newlines after continuation character are removed" ,
167181 filename : "js-t-continuation-character.js" ,
You can’t perform that action at this time.
0 commit comments