import { MatPaginatorIntl, MatPaginatorModule } from '@angular/material/paginator';
import { getSpanishPaginatorIntl } from '....../spanish-paginator-intl';providers: [
{ provide: MatPaginatorIntl, useValue: getSpanishPaginatorIntl() }
]import { MatPaginatorIntl } from '@angular/material/paginator';const spanishRangeLabel = (page: number, pageSize: number, length: number): string => {
// Check data length
if (length === 0 || pageSize === 0) {
return `0 de ${length}`;
}
// Get max length
length = Math.max(length, 0);
// Set start index
const startIndex = page * pageSize;
// If the start index exceeds the list length, do not try and fix the end index to the end.
const endIndex = startIndex < length ?
Math.min(startIndex + pageSize, length) :
startIndex + pageSize;
// Return range
return `${startIndex + 1} - ${endIndex} de ${length}`;
};/**
* Get translated paginator text
*
* @export
*/
export function getSpanishPaginatorIntl(): MatPaginatorIntl {
// Create a new instance of MatPaginator
const paginatorIntl = new MatPaginatorIntl();
// Text translation for each element in the paginator
paginatorIntl.firstPageLabel = 'Primera página';
paginatorIntl.itemsPerPageLabel = 'Elementos por página:';
paginatorIntl.nextPageLabel = 'Página siguiente';
paginatorIntl.previousPageLabel = 'Página anterior';
paginatorIntl.lastPageLabel = 'Última página';
paginatorIntl.getRangeLabel = spanishRangeLabel;
// Return MatPaginator translated
return paginatorIntl;
}Thanks my friend , its easy to implement , tooo easy .
Creating gist for translate mat-paginator