Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

These expressions are not detected #239

Open
gbshbrosjo opened this issue Jul 22, 2021 · 1 comment
Open

These expressions are not detected #239

gbshbrosjo opened this issue Jul 22, 2021 · 1 comment

Comments

@gbshbrosjo
Copy link

gbshbrosjo commented Jul 22, 2021

Hello Kim,
Thanks for ngx-translate-extract! Great Work!

While examining carefully we found out that these kinds of expressions are not detected and extracted:

  1. It would be nice if conditional (ternary) operators (using only strings in both cases) are supported. So we could write
    <p translate>{{ switch ? "Move up" : "Move down" }}</p> (currently not detected)
    instead of
    <p>{{ switch ? ("Move up" | translate) : ("Move down" | translate) }}</p> (detected)

  2. In this very special scenario ngx-translate-extract won't find the word "Cuckoo":
    demo.component.ts

import { Chart } from './chart.service';
import { TranslateService } from '@ngx-translate/core';

@Component({
  selector: 'app-demo',
  templateUrl: './demo.component.html',
  styleUrls: ['./demo.component.scss']
})
export class Demo {

  constructor(
    protected translate: TranslateService
  ) {  }
  
  public chart: Chart = new Chart({ translate: this.translate });
  
  public ngOnInit(): void {
    this.output = this.chart.getDescription();
  }
}

chart.service.ts

import { BaseComponent } from './base.component';

export class Chart extends BaseComponent {

  constructor({ ...param }) {
    super(param);
  }

  public getDescription() {
    return this.translate.instant("Cuckoo");
  }

}

base.component.ts

import { TranslateService } from '@ngx-translate/core';


export abstract class BaseComponent {
  protected translate: TranslateService;

  protected constructor({
    translate }: any) {
    this.translate = translate;
  }

}
@AmirSavand
Copy link

I guess this could work for a shorter version of what's working.

<p>{{ (switch ? "Move up" : "Move down") | translate }}</p>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants