Skip to content

Paginator labels are not updated when the UI language changes #522

Open

Description

@jd-igf

Is this a regression?

No

Severity

⚪ Cosmetic – visual or non-functional issue

Please provide the branch(es) you discovered this issue in

v92

Environment Details

Edge on Windows 11, v9.2.2

Please provide a minimal set of steps to reproduce the issue

  1. Open any view containing a Material paginator (e.g. a data table).
  2. Change the UI language (or log out and log in with a different language).
  3. Observe that the paginator labels ("Entries per page", "First page", range text, etc.) are still shown in the old language.

Description

The custom Paginator (extends MatPaginatorIntl, in lds-replace/qbm shared code, branch v92) loads its translations only once in the constructor using translateService.get(...). Since get() emits a single value and completes, the paginator labels are never refreshed when:

  • the UI language is changed at runtime, or
  • a user logs out and logs in again with a different language.

The paginator then keeps showing the labels of the previously active language.

There are two root causes:

  1. translateService.get() is used instead of translateService.stream(), so onLangChange events are ignored.
  2. this.changes.next() is never called — MatPaginator only re-renders its labels when the changes subject of MatPaginatorIntl emits, so even updated properties would not become visible.

Describe what you expected to happen versus what actually happened

Paginator labels follow the currently active UI language.

Relevant logs or console output

Add a screenshot(s) if that helps illustrate the problem

No response

Suggested Fix

Replace the one-time get() subscriptions with a single stream() subscription and notify Material via changes.next():

export class Paginator extends MatPaginatorIntl {
  private rangeText = '';
  private rangeTextFallback = '';

  private readonly labels: { [property: string]: string } = {
    itemsPerPageLabel: '#LDS#Entries per page',
    firstPageLabel: '#LDS#First page',
    previousPageLabel: '#LDS#Previous page',
    nextPageLabel: '#LDS#Next page',
    lastPageLabel: '#LDS#Last page',
    rangeText: '#LDS#{0} - {1} of {2}',
    rangeTextFallback: '#LDS#0 of {0}',
  };

  private constructor(private translateService: TranslateService, private readonly ldsReplace: LdsReplacePipe) {
    super();

    this.translateService.stream(Object.values(this.labels))
      .subscribe((texts: { [key: string]: string }) => {
        Object.entries(this.labels).forEach(([property, key]) => this[property] = texts[key]);
        this.itemsPerPageLabel += ':';
        this.changes.next();
      });

    this.getRangeLabel = (page: number, pageSize: number, length: number) => {
      length = Math.max(length, 0);

      if (length === 0 || pageSize === 0) {
        return this.ldsReplace.transform(this.rangeTextFallback, length);
      }

      const startIndex = page * pageSize;
      const endIndex = startIndex < length ? Math.min(startIndex + pageSize, length) : startIndex + pageSize;

      return this.ldsReplace.transform(this.rangeText, startIndex + 1, endIndex, length);
    };
  }

  public static Create(translateService: TranslateService, ldsReplace: LdsReplacePipe): Paginator {
    return new Paginator(translateService, ldsReplace);
  }
}

Anything else?

No response

Before submitting...

  • I have searched for existing issues that match this one on github and on the community support page
  • I have included all necessary details to reproduce this issue

Activity

  1. github-actions commented on Oct 2, 2026

    @github-actions

    This issue has not seen any action for a while! Closing for now, but it can be reopened at a later date.

  2. asattler commented on Oct 3, 2026

    @asattler

    This issue should not be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions