Last active
February 8, 2019 15:48
-
-
Save jacob-jonkman/9a3f230f787e3f4af5d707e6dbf2b8e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Pipe, PipeTransform } from '@angular/core'; | |
import { TranslateService } from './translate.service'; | |
@Pipe({ | |
name: 'translate' | |
}) | |
export class TranslatePipe implements PipeTransform { | |
constructor(private translateService: TranslateService) {} | |
/* Pipe which translates term to the specified language | |
* Parameter table specifies which table in the translations table should be used. */ | |
transform(term: string, language: string, table: string): Promise<string> { | |
if (!term || !language || !table) { | |
return Promise.resolve(''); | |
} | |
const formattedTerm = this.encodeAsFirebaseKey(term); | |
return this.translateService.translateFromEng(formattedTerm, language, table); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment