import { Injector , Pipe , PipeTransform } from '@angular/core' ; import { AppConsts } from '@shared/AppConsts' ; import { LocalizationService } from 'abp-ng2-module' ; @ Pipe ( { name : 'localize' } ) export class LocalizePipe implements PipeTransform { localizationSourceName = AppConsts . localization . defaultLocalizationSourceName ; localization : LocalizationService ; constructor ( injector ) { this . localization = injector . get ( LocalizationService ) ; } l ( key , ... args ) { args . unshift ( key ) ; args . unshift ( this . localizationSourceName ) ; return this . ls . apply ( this , args ) ; } ls ( sourcename , key , ... args ) { let localizedText = this . localization . localize ( key , sourcename ) ; if ( ! localizedText ) { localizedText = key ; } if ( ! args || ! args . length ) { return localizedText ; } args . unshift ( localizedText ) ; return abp . utils . formatString . apply ( this , args ) ; } transform ( key , ... args ) { return this . l ( key , args ) ; } }