Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-mwesener committed Jul 7, 2023
2 parents 41fb332 + aa5ba96 commit 6956932
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Changed Layout in notification detailed view
- Changed request parameter for registerjob request to irs to match requirements of irs
- Migration of edc 0.4.1 endpoints and api flow
- fixed bug where language switcher did not update to the selected language

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { Location } from '@angular/common';
import { Component, Inject, OnDestroy } from '@angular/core';
import { ALL_KNOWN_LOCALES, KnownLocale } from '@core/i18n/global-i18n.providers';
import { I18NEXT_SERVICE, ITranslationService } from 'angular-i18next';
Expand All @@ -41,7 +42,7 @@ export class LanguageSelectorComponent implements OnDestroy {

public currentLocale: KnownLocale;

constructor(@Inject(I18NEXT_SERVICE) private readonly i18NextService: ITranslationService) {
constructor(@Inject(I18NEXT_SERVICE) private readonly i18NextService: ITranslationService, private readonly location: Location) {
const supportedLanguages = this.i18NextService.options.supportedLngs || [];

this.locales = (Object.entries(ALL_KNOWN_LOCALES) as [KnownLocale, string][])
Expand All @@ -63,5 +64,6 @@ export class LanguageSelectorComponent implements OnDestroy {

public handleClick(localeId: KnownLocale): void {
void this.i18NextService.changeLanguage(localeId);
this.location.historyGo(0);
}
}
3 changes: 3 additions & 0 deletions frontend/src/app/modules/shared/pipes/i18n.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import { I18NextPipe, PipeOptions } from 'angular-i18next';

// To make this pipe pure, reload the page after the language was changed.
// Keeping it "impure" leads to a lot of unnecessary renders

// Currently we use a workaround (in languageswitcher component) so that the whole page gets refreshed when the user
// is switching languages. This way we keep the performance and the pipe pure
@Pipe({ name: 'i18n', pure: true })
export class I18nPipe implements PipeTransform {
constructor(private readonly i18NextPipe: I18NextPipe) {}
Expand Down

0 comments on commit 6956932

Please sign in to comment.