File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
1818 KeyedRead ,
1919 ASTWithSource ,
2020 ParenthesizedExpression ,
21+ TemplateLiteral ,
2122} from '@angular/compiler' ;
2223
2324import { getAST , getNodesFromSwitchBlockTmpl } from '../utils/ast-helpers.js' ;
@@ -230,6 +231,10 @@ export class PipeParser implements ParserInterface {
230231 return this . getTranslatablesFromAsts ( [ ast . expression ] ) ;
231232 }
232233
234+ if ( ast instanceof TemplateLiteral ) {
235+ return this . getTranslatablesFromAsts ( ast . expressions ) ;
236+ }
237+
233238 return [ ] ;
234239 }
235240
Original file line number Diff line number Diff line change @@ -334,6 +334,12 @@ describe('PipeParser', () => {
334334 expect ( multipleConditionKeys ) . to . deep . equal ( [ 'translation.key' ] ) ;
335335 } ) ;
336336
337+ it ( 'should extract key from translate pipe inside template literals' , ( ) => {
338+ const contents = "<div>{{ `${'translation.key' | translate}, ${'another.key' | translate}` }}</div>" ;
339+ const keys = parser . extract ( contents , templateFilename ) . keys ( ) ;
340+ expect ( keys ) . to . deep . equal ( [ 'translation.key' , 'another.key' ] ) ;
341+ } ) ;
342+
337343 it ( 'should not extract empty strings as keys' , ( ) => {
338344 const contents = `<div>{{ '' | translate }}</div>` ;
339345 const keys = parser . extract ( contents , templateFilename ) . keys ( ) ;
You can’t perform that action at this time.
0 commit comments