Skip to content

Instantly share code, notes, and snippets.

@jacob-jonkman
Last active February 8, 2019 15:48
Show Gist options
  • Save jacob-jonkman/9a3f230f787e3f4af5d707e6dbf2b8e0 to your computer and use it in GitHub Desktop.
Save jacob-jonkman/9a3f230f787e3f4af5d707e6dbf2b8e0 to your computer and use it in GitHub Desktop.
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