Skip to content

The strings are not extracted from a Pipe who extends of Translate pipe #218

@mberthouzoz

Description

@mberthouzoz

Environment

Angular: 8.2.14
ngx-translate-extract: 5.0.1 and 7.0.3

Description

I'm trying to extract the string from a Pipe. This Pipe extends from TranslatePipe.

Code

import { DatePipe } from '@angular/common';
import { ChangeDetectorRef, Pipe, PipeTransform } from '@angular/core';
import { TranslatePipe, TranslateService } from '@ngx-translate/core';

@Pipe({
  name: 'containerStatusLabel',
  pure: false
})
export class StatusLabelPipe extends TranslatePipe implements PipeTransform {
  constructor(
    private translateService: TranslateService,
    private changeDetectorRef: ChangeDetectorRef
  ) {
    super(translateService, changeDetectorRef);
  }

  transform(status: string, args?: string): string {
    switch (status) {
      case 'DELIVERED':
        return super.transform('Delivered');
      case 'SHIPPED':
        return super.transform('Shipped');
      case 'IN STOCK':
        return super.transform('In stock');
      case 'CANCELLED':
        return super.transform('Cancelled');
      case 'CREATED':
        return super.transform('Created');
      default:
        return '';
    }
  }
}

How to reproduce

ngx-translate-extract -f pot -i ./src -o ./i18n/template2.pot

Result

The strings( 'Delivered', 'Shipped', ...) are not extracted. I don't see these strings in the pot file.

Expected

The strings should be present in the pot file.


Someone has the same error or has an idea how to get the strings in the pot file without using a marker?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions