SAP / spartacus

Spartacus is a lean, Angular-based JavaScript storefront for SAP Commerce Cloud that communicates exclusively through the Commerce REST API.
Apache License 2.0
744 stars 388 forks source link

translate service should be able to do bulk translations #10410

Open mrSingh007 opened 3 years ago

mrSingh007 commented 3 years ago

Currently if user want to have translation in component, he can only pass single key for translation:

this.translationService.translate( 'lorem.create').subscribe(res=>console.log(res)).unsubscribe();
this.translationService.translate( 'lorem.download').subscribe(res=>console.log(res)).unsubscribe();
this.translationService.translate( 'common.ok').subscribe(res=>console.log(res)).unsubscribe();

Describe the solution you'd like it should be possible to pass multi keys and get their values for example

trans= ['lorem.create','lorem.download','common.ok','common.cancel']
//now lets translate all these
this.translationService.translate(this.trans).subscribe(res=>console.log(res)).unsubscribe();

NGX translate use this multi key translation logic https://github.com/ngx-translate/core //method is 'get' here

tobi-or-not-tobi commented 3 years ago

hi @mrSingh007 thanks for the idea. Would you expect to pass in the same options for all keys in such a case? i.e.:

translate: (['first','second'],{foo: 'bar'})
mrSingh007 commented 3 years ago

@tobi-or-not-tobi would be nice Or just multi key translation without interpolation also ok.