ng-matero/extensions

How To Change Language on Component mtxGrid

Closed this issue · 2 comments

Hi, I want to change the language for mtxGrid to German. If the table has no Records then it will display "No records found"

I found in '@ng-matero/extensions/fesm2022/mtxgrid.mjs' in Line 1021 the following code:
this.noResultText = this._defaultOptions?.noResultText ?? 'No records found';

The _defaultOptions is assigned in the constructor

I tried to add the translation to my app.config.ts with

{
      provide: MTX_GRID_DEFAULT_OPTIONS,
      useValue: {
        noResultText: 'Keine Ergebnisse gefunden'
      },
    } as MtxGridDefaultOptions,
but it gives me errors. Whats the best way to change the language?

Fixed it with:

export const appConfig: ApplicationConfig = {
  providers: [
    //other providers...

    {
      provide: MTX_GRID_DEFAULT_OPTIONS,
      useValue: {
        noResultText: 'Keine Ergebnisse gefunden',
      },
    },

  //...
  ]
};

But is this the correct way of specifying the language? An en-US.json file for grid or other components would be great. How would you do it @nzbin ?

It's not specify the language, it's set the default option. You can translate in the component prop.

<mtx-grid [noResultText]="'text' | translate" />