In grid.component.html
<ejs-grid id="Grid" [dataSource]="gridData" allowPaging="true" >
<e-columns>
<e-column field="OrderID" [isPrimaryKey]="true" headerText="{{ 'Value' | translate }}"></e-column>
<e-column field="Freight" headerText="Freight" ></e-column>
</e-columns>
</ejs-grid>
In grid.component.ts
import { Component } from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
@Component({
selector: 'app-root',
templateUrl: '. /grid.component.html',
})
export class GridComponent {
constructor(translate: TranslateService) {
translate.addLangs(['en', 'fr']) // tells the service which languages are available for translation
translate.setDefaultLang('en'); // allows to specify set of translation to use in case there are missing translation for current language
translate.use('fr');// tells the service which is current language
}
}
In assets/i18n/en.json
{
"Value": "Order ID!"
}
In assets/i18n/fr.json
{
"Value": "numéro de commande!"
}
|
<div>
<ejs-grid #grid [toolbar]='toolbar' [dataSource]="dataSource">
<e-columns>
. . .
</e-columns>
</ejs-grid>
</div>
<ng-template #toolbar1>
<button class="btn btn-secondary btn-toolbar">{{ 'All' | translate }}</button>
</ng-template>
|
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent implements OnInit {
@ViewChild("toolbar1")
public toolbar1: any;
constructor(private translate: TranslateService) {
translate.addLangs(['en', 'fr']) // tells the service which languages are available for translation
translate.use('fr');// tells the service which is current language
}
ngOnInit() {
this.toolbar = [
{ template: this.toolbar1, id: 'selectall' },
. . .
];
}
} |