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

Not working with already interpolated strings and translateParams directive #253

Open djechelon opened 2 years ago

djechelon commented 2 years ago

I am new to ngx-translate, so please forgive if I am making some mistakes.

I have to internationalize a parametric string that is interpolated

<div [ngClass]="numberFilterActive !== 0 ? 'col-2' : 'col-7'" class="margin-auto label-12-b">{{lengthPlanning}} Results

I wanted to use translateParams from the ngx-translate project and changed into this

<div [ngClass]="numberFilterActive !== 0 ? 'col-2' : 'col-7'" class="margin-auto label-12-b" translate translateParams="{length: lengthPlanning}">{{lengthPlanning}} Results

But ng-translate-extract could not extract this into a key.

I found a workaround, by defining a non-interpolated key

<div [ngClass]="numberFilterActive !== 0 ? 'col-2' : 'col-7'" class="margin-auto label-12-b" translate translateParams="{length: lengthPlanning}">No. Results

But I don't know if this is wanted or undocumented.

Thanks for support