Skip to content

Commit

Permalink
Cleanup language functionality (#4522)
Browse files Browse the repository at this point in the history
  • Loading branch information
luisa-beerboom authored Jan 9, 2025
1 parent 21aabc6 commit a661546
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 9 deletions.
5 changes: 1 addition & 4 deletions client/src/app/gateways/repositories/base-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { auditTime, BehaviorSubject, filter, Observable, Subject, Subscription }
import { HasSequentialNumber, Identifiable } from 'src/app/domain/interfaces';
import { OnAfterAppsLoaded } from 'src/app/infrastructure/definitions/hooks/after-apps-loaded';
import { ListUpdateData } from 'src/app/infrastructure/utils';
import { getIntlCollatorForLang } from 'src/app/infrastructure/utils';
import { Deferred } from 'src/app/infrastructure/utils/promises';
import { OsSortProperty } from 'src/app/site/base/base-sort.service';
import { SortListService } from 'src/app/ui/modules/list';
Expand Down Expand Up @@ -32,10 +33,6 @@ export function canPerformListUpdates(repo: any): repo is CanPerformListUpdates<
return repo.listUpdate && typeof repo.listUpdate === `function`;
}

export function getIntlCollatorForLang(lang: string): Intl.Collator {
return new Intl.Collator(lang === `1337` ? `en` : lang);
}

enum PipelineActionType {
General = `general`,
Resort = `resort`,
Expand Down
4 changes: 4 additions & 0 deletions client/src/app/infrastructure/utils/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,7 @@ export function findIndexInSortedArray<T>(array: T[], toFind: T, compareFn: (a:
}
return -1;
}

export function getIntlCollatorForLang(lang: string, options?: Intl.CollatorOptions): Intl.Collator {
return new Intl.Collator(lang === `1337` ? `en` : lang, options);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Directive, inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Displayable, Identifiable } from 'src/app/domain/interfaces';
import { getIntlCollatorForLang } from 'src/app/infrastructure/utils';
import { SortService } from 'src/app/ui/modules/list/definitions/sort-service';

import { OsSortProperty } from './os-sort';
Expand Down Expand Up @@ -28,7 +29,7 @@ export abstract class BaseSortService<T extends Identifiable & Displayable> impl
protected translate = inject(TranslateService);

public constructor() {
this.intl = new Intl.Collator(this.translate.currentLang, {
this.intl = getIntlCollatorForLang(this.translate.currentLang, {
numeric: true,
ignorePunctuation: true,
sensitivity: `base`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class AccountButtonComponent extends BaseUiComponent implements OnInit {
}

protected override cleanSubscriptions(): void {
this._langTriggerSubscription.unsubscribe();
this._langTriggerSubscription?.unsubscribe();
super.cleanSubscriptions();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class PruningTranslationLoader implements TranslateLoader {
]).pipe(
map(([t, ct]) => {
if (ct) {
ct = Object.entries(ct).mapToObject(([key, val]) => ({ [this.t1337(key)]: this.t1337(val) }));
for (const k of Object.keys(t)) {
t[k] = ct[t[k]] || t[k];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { getIntlCollatorForLang } from 'src/app/infrastructure/utils';
import { BaseMotionSlideComponent } from 'src/app/site/pages/meetings/modules/projector/modules/slides/components/motions/base/base-motion-slide';
import { SlideData } from 'src/app/site/pages/meetings/pages/projectors/definitions';
import { MeetingSettingsService } from 'src/app/site/pages/meetings/services/meeting-settings.service';
Expand Down Expand Up @@ -91,7 +92,7 @@ export class MotionBlockSlideComponent extends BaseMotionSlideComponent<MotionBl

public constructor(private meetingSettingsService: MeetingSettingsService) {
super();
this.languageCollator = new Intl.Collator(this.translate.currentLang);
this.languageCollator = getIntlCollatorForLang(this.translate.currentLang);

this.meetingSettingsService
.get(`motions_block_slide_columns`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { TranslateService } from '@ngx-translate/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { Id } from 'src/app/domain/definitions/key-types';
import { Mediafile } from 'src/app/domain/models/mediafiles/mediafile';
import { getIntlCollatorForLang } from 'src/app/gateways/repositories/base-repository';
import { getIntlCollatorForLang } from 'src/app/infrastructure/utils';
import { infoDialogSettings } from 'src/app/infrastructure/utils/dialog-settings';
import { ViewMediafile, ViewMeetingMediafile } from 'src/app/site/pages/meetings/pages/mediafiles';
import { MediafileControllerService } from 'src/app/site/pages/meetings/pages/mediafiles/services/mediafile-controller.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@

<!-- Filter button -->
@if (hasFilters) {
<button mat-button (click)="filterMenu.opened ? filterMenu.close() : filterMenu.open()">
<button
mat-button
style="width: max-content"
(click)="filterMenu.opened ? filterMenu.close() : filterMenu.open()"
>
<mat-icon
matBadgeColor="accent"
matBadgeSize="small"
Expand Down

0 comments on commit a661546

Please sign in to comment.