Transloco: How could I wrap the transloco pipe or rename it?

Created on 13 Dec 2019  路  2Comments  路  Source: ngneat/transloco

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[x] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

To translate in templates I have to use the transloco pipe. Is there any possible way to rename or wrap it around my own pipe like as follows?

import { Pipe } from '@angular/core'
import { TranslocoPipe } from '@ngneat/transloco'

@Pipe({
  name: 'translate'
})
export class TranslatePipe extends TranslocoPipe {}

This is a way people found out to rename external pipes: https://stackoverflow.com/questions/52470434/using-a-pipe-under-a-different-name. However when I try it stops working.

Cheers on the library, best library for translations in Angular right now! ;)

Expected behavior

I should be able to extend TranslocoPipe with a custom pipe and it should still work, or be able to wrap it.

Most helpful comment

@Pipe({
  name: 'translate',
  pure: false
})
export class TranslatePipe extends TranslocoPipe {}

I wouldn't recommend doing this. Some devtools rely on this name.

All 2 comments

@Pipe({
  name: 'translate',
  pure: false
})
export class TranslatePipe extends TranslocoPipe {}

I wouldn't recommend doing this. Some devtools rely on this name.

Thanks! That's what I was looking for.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gernsdorfer picture gernsdorfer  路  4Comments

philjones88 picture philjones88  路  6Comments

maxime1992 picture maxime1992  路  4Comments

flgraveline picture flgraveline  路  7Comments

mickz18 picture mickz18  路  3Comments