Skip to content

Commit 5eb1ec1

Browse files
Ghislain BeaulacGhislain Beaulac
Ghislain Beaulac
authored and
Ghislain Beaulac
committed
feat(translate): make ngx-translate optional in all necessary Editors
1 parent 86b1214 commit 5eb1ec1

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/app/modules/angular-slickgrid/editors/dateEditor.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,9 @@ export class DateEditor implements Editor {
8888

8989
getCurrentLocale(columnDef: Column, gridOptions: GridOption) {
9090
const options = gridOptions || columnDef.params || {};
91-
if (options.i18n && options.i18n instanceof TranslateService) {
91+
if (options && options.i18n instanceof TranslateService) {
9292
return options.i18n.currentLang;
9393
}
94-
9594
return 'en';
9695
}
9796

src/app/modules/angular-slickgrid/editors/longTextEditor.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ export class LongTextEditor implements Editor {
3333
constructor(private args: any) {
3434
this.gridOptions = this.args.grid.getOptions() as GridOption;
3535
const options = this.gridOptions || this.args.column.params || {};
36-
this._translate = options.i18n;
36+
if (options && options.i18n instanceof TranslateService) {
37+
this._translate = options.i18n;
38+
}
3739

3840
this.init();
3941
}
@@ -61,8 +63,8 @@ export class LongTextEditor implements Editor {
6163
const columnId = this.columnDef && this.columnDef.id;
6264
const placeholder = this.columnEditor && this.columnEditor.placeholder || '';
6365
const title = this.columnEditor && this.columnEditor.title || '';
64-
const cancelText = this._translate && this._translate.instant('CANCEL') || Constants.TEXT_CANCEL;
65-
const saveText = this._translate && this._translate.instant('SAVE') || Constants.TEXT_SAVE;
66+
const cancelText = this._translate && this._translate.instant && this._translate.instant('CANCEL') || Constants.TEXT_CANCEL;
67+
const saveText = this._translate && this._translate.instant && this._translate.instant('SAVE') || Constants.TEXT_SAVE;
6668
const $container = $('body');
6769

6870
this.$wrapper = $(`<div class="slick-large-editor-text editor-${columnId}" />`).appendTo($container);

src/app/modules/angular-slickgrid/editors/selectEditor.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ export class SelectEditor implements Editor {
7777

7878
constructor(protected args: any, protected isMultipleSelect) {
7979
this.gridOptions = this.args.grid.getOptions() as GridOption;
80-
const gridOptions = this.gridOptions || this.args.column.params || {};
81-
this._translate = gridOptions.i18n;
80+
const options = this.gridOptions || this.args.column.params || {};
81+
if (options && options.i18n instanceof TranslateService) {
82+
this._translate = options.i18n;
83+
}
8284

8385
// provide the name attribute to the DOM element which will be needed to auto-adjust drop position (dropup / dropdown)
8486
const fieldId = this.columnDef && this.columnDef.id;

0 commit comments

Comments
 (0)