biesbjerg / ngx-translate-extract

Extract translatable (using ngx-translate) strings and save as a JSON or Gettext pot file
MIT License
524 stars 196 forks source link

Find uses of translate pipe in pipe arguments. #243

Closed P4 closed 1 year ago

P4 commented 3 years ago

This changes PipeParser to consider arguments to translate pipe and other pipes in the search for translation keys.

Examples where key did not get extracted previously:

{{ 'value' | testPipe: ('test1' | translate) }} // finds nothing, misses 'test1' 
{{ 'Hello' | translate: {world: ('World' | translate)} }} // finds 'Hello', misses 'World'
{{ 'previewHeader' | translate:{filename: filename || ('video' | translate)} }} // finds 'previewHeader', misses 'video'

Note the nested usage of translate pipe in the last example.

expressionIsOrHasBindingPipe has been simplified and inlined into getTranslatablesFromAst, the case of 'key' | foo | ... | bar | translate is already correctly handled by another conditional branch of getTranslatablesFromAst and no longer needs special treatment.

Fixes part of #174 which involves pipe arguments (first example)