ngx-translate-all-pipe

ngx-translate extension to translate multiple values at once

Usage no npm install needed!

<script type="module">
  import ngxTranslateAllPipe from 'https://cdn.skypack.dev/ngx-translate-all-pipe';
</script>

README

ngx-translate-all-pipe

NPM version MIT License

A modification of ngx-translate's TranslatePipe that can provide multiple translations at once.

Installation

To install this library, run:

$ npm install ngx-translate-all-pipe --save

Usage

Import TranslateAllPipeModule.

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    TranslateModule.forRoot(),
    TranslateAllPipeModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {
}

Use the translateAll pipe in a template to translate an array of strings.

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  fruitKeys = ['APPLE', 'BANANA', 'ORANGE', 'PINEAPPLE'];

  constructor(translateService: TranslateService) {
    translateService.setDefaultLang('es');
  }
}

In app.component.html:

{{ (fruitKeys | translateAll).join(' | ') }}

License

MIT © b4rd