paginator lokalisiert

main
Said Gedik 2024-07-31 14:48:13 +02:00
parent a478738fa9
commit d0e777e0a6
3 changed files with 35 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import {MatButtonModule } from '@angular/material/button';
import {AppRoutingModule } from './app-routing.module';
import {AppComponent } from './app.component';
import {GanttModule, EditService, ToolbarService, SelectionService } from '@syncfusion/ej2-angular-gantt';
import {MatPaginatorModule} from '@angular/material/paginator';
import {MatPaginatorIntl, MatPaginatorModule} from '@angular/material/paginator';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import {VirtualScrollService } from '@syncfusion/ej2-angular-gantt';
import {SortService } from '@syncfusion/ej2-angular-gantt';
@ -41,6 +41,7 @@ import { RenamePresetDialogComponent } from './rename-preset-dialog/rename-prese
import { DeletePresetDialogComponent } from './delete-preset-dialog/delete-preset-dialog.component';
import { SavePresetUnderDialogComponent } from './save-preset-under-dialog/save-preset-under-dialog.component';
import {MatBadgeModule} from '@angular/material/badge';
import { CustomPaginatorIntl } from './custom-paginator-intl.service';
@ -96,7 +97,8 @@ import {MatBadgeModule} from '@angular/material/badge';
SelectionService,
VirtualScrollService,
SortService,
FilterService
FilterService,
{ provide: MatPaginatorIntl, useClass: CustomPaginatorIntl },
],
bootstrap: [AppComponent]
})

View File

@ -0,0 +1,28 @@
import { Injectable } from '@angular/core';
import { MatPaginatorIntl } from '@angular/material/paginator';
import { LanguageService } from './language.service';
@Injectable()
export class CustomPaginatorIntl extends MatPaginatorIntl {
constructor(private languageService: LanguageService) {
super();
this.getAndInitTranslations();
this.languageService.languageChangeEmitter.subscribe(() => {
this.translateLabels();
});
}
getAndInitTranslations() {
this.itemsPerPageLabel = this.languageService.language === 'DE' ? 'Elemente pro Seite:' : 'Items per page:';
this.nextPageLabel = this.languageService.language === 'DE' ? 'Nächste Seite' : 'Next page';
this.previousPageLabel = this.languageService.language === 'DE' ? 'Vorherige Seite' : 'Previous page';
this.firstPageLabel = this.languageService.language === 'DE' ? 'Erste Seite' : 'First page';
this.lastPageLabel = this.languageService.language === 'DE' ? 'Letzte Seite' : 'Last page';
}
// Update translations on language change
translateLabels() {
this.getAndInitTranslations();
this.changes.next(); // Notify paginator to update labels
}
}

View File

@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Injectable, EventEmitter } from '@angular/core';
@Injectable({
providedIn: 'root'
@ -13,6 +13,7 @@ export class LanguageService {
public language: string = 'DE';
public languages: string[] = ['DE', 'EN'];
public languageChangeEmitter: EventEmitter<string> = new EventEmitter<string>();
public deMap: Map<string, string> = new Map<string, string>();
public enMap: Map<string, string> = new Map<string, string>();
public lMap: Map<string, string> = new Map<string, string>();
@ -244,6 +245,7 @@ export class LanguageService {
this.language = 'EN';
this.lMap = this.enMap;
}
this.languageChangeEmitter.emit(this.language); // Emit language change
}
/**