首页 > 解决方案 > 我应该如何使用 transloco i18n(internationalization) 库更改 Material Table 标题以进行分页和页面范围、下一个、上一个按钮?

问题描述

想要使用 i18n 显示标题 上面是显示标题“每页项目”的图像

标签: angularangular-materialtransloco

解决方案


您需要使用MatPaginatorIntl接口并对其进行扩展。这是塞尔维亚标签的示例

export function getSerbianPaginatorIntl() {
  const paginatorIntl = new MatPaginatorIntl();

  paginatorIntl.itemsPerPageLabel = 'Stavki po strani:';
  paginatorIntl.nextPageLabel = 'Sledeca strana';
  paginatorIntl.previousPageLabel = 'Prethodna strana';
  paginatorIntl.getRangeLabel = serbianRangeLabel;

  return paginatorIntl;
}

此处的完整示例https://stackblitz.com/edit/angular-5mgfxh-cwgmym?file=app%2Fdutch-paginator-intl.ts


推荐阅读