ngx-translate-arraydeprecated

ngx-translate extension to translate multiple values at once

Usage no npm install needed!

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

README

ngx-translate-array

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-array --save

Usage

Import TranslateArrayModule.

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

Use translateArray 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 | translateArray).join(' | ') }}

License

MIT © b4rd