Open SamanthaAdrichem opened 5 days ago
It seems to be a bug when extending as an alias
So most likely a bug in https://github.com/phenomnomnominal/tsquery? Can someone check this? Because for me the service parser and how it gets to the ast-helpers and does the queries is a bit much. I found a work-around for now :) (add protected infront of the translateService in the extend as well)
Create a folder src in there create these 2 files
src/base.ts
import {Injectable} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
@Injectable()
export class Base {
constructor(
protected translateService: TranslateService
) {}
public getBase(): string {
return this.translateService.instant('test base');
}
}
src/base-extend.ts
import {Injectable} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
import {Base as CoreBase} from 'src/base';
@Injectable({providedIn: 'root'})
export class BaseExtend extends CoreBase {
constructor(
translateService: TranslateService
) {
super(translateService);
}
public getExtend(): string {
return this.translateService.instant('Extend string');
}
}
run the scanner
npx ngx-translate-extract --input src/base-extend.ts --format pot --output test.txt
result:
Enabled parsers:
- PipeParser
- DirectiveParser
- ServiceParser
- MarkerParser
Enabled post processors:
(none)
Compiler:
- PoCompiler
Extracting:
- src/base-extend.ts
translateService
Found 0 strings.
Saving:
- test.txt [MERGED]
Done.
Change base-extend.ts by removing the as alias
import {Injectable} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
import {Base} from 'src/base';
@Injectable({providedIn: 'root'})
export class BaseExtend extends Base {
constructor(
translateService: TranslateService
) {
super(translateService);
}
public getExtend(): string {
return this.translateService.instant('Extend string');
}
}
Run the scanner again
npx ngx-translate-extract --input src/base-extend.ts --format pot --output test.txt
Result:
Enabled parsers:
- PipeParser
- DirectiveParser
- ServiceParser
- MarkerParser
Enabled post processors:
(none)
Compiler:
- PoCompiler
Extracting:
- src/base-extend.ts
translateService
Found 1 strings.
Saving:
- test.txt [MERGED]
Done.
Nice find! 👍 I hope they fix it!
That's a very interesting corner case. I'll try to have a look
Not all translateService.instant translations are extracted
package.json
media.service.ts
core/media.service.ts
command
result: