Browse Source
Bugfix/localization of range label in paginator (#8449)
* Fix localization of range label
* Update changelog
main
Thomas Kaul
1 hour ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
54 additions and
0 deletions
-
CHANGELOG.md
-
apps/client/src/app/adapter/custom-paginator-intl.ts
-
apps/client/src/app/app.component.ts
-
apps/client/src/main.ts
|
|
|
@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
### Fixed |
|
|
|
|
|
|
|
- Fixed the duplicate data point of today in the chart of the holding detail dialog |
|
|
|
- Fixed the missing localization of the range label in the paginator |
|
|
|
- Fixed the requests of the twitter bot service with dummy credentials |
|
|
|
|
|
|
|
## 3.100.0 - 2026-11-15 |
|
|
|
|
|
|
|
@ -0,0 +1,44 @@ |
|
|
|
import { getLocale } from '@ghostfolio/common/helper'; |
|
|
|
|
|
|
|
import { Service } from '@angular/core'; |
|
|
|
import { MatPaginatorIntl } from '@angular/material/paginator'; |
|
|
|
|
|
|
|
@Service() |
|
|
|
export class CustomPaginatorIntl extends MatPaginatorIntl { |
|
|
|
private locale = getLocale(); |
|
|
|
|
|
|
|
/** |
|
|
|
* Formats the range label with the number format of the locale |
|
|
|
*/ |
|
|
|
public override getRangeLabel = ( |
|
|
|
page: number, |
|
|
|
pageSize: number, |
|
|
|
length: number |
|
|
|
) => { |
|
|
|
let range = this.formatNumber(0); |
|
|
|
|
|
|
|
if (length > 0 && pageSize > 0) { |
|
|
|
const startIndex = page * pageSize; |
|
|
|
|
|
|
|
const endIndex = |
|
|
|
startIndex < length |
|
|
|
? Math.min(startIndex + pageSize, length) |
|
|
|
: startIndex + pageSize; |
|
|
|
|
|
|
|
range = `${this.formatNumber(startIndex + 1)} – ${this.formatNumber(endIndex)}`; |
|
|
|
} |
|
|
|
|
|
|
|
const total = this.formatNumber(Math.max(length, 0)); |
|
|
|
|
|
|
|
return `${range} ${$localize`of`} ${total}`; |
|
|
|
}; |
|
|
|
|
|
|
|
public setLocale(aLocale: string) { |
|
|
|
this.locale = aLocale; |
|
|
|
this.changes.next(); |
|
|
|
} |
|
|
|
|
|
|
|
private formatNumber(aNumber: number) { |
|
|
|
return aNumber.toLocaleString(this.locale, { useGrouping: true }); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -42,6 +42,7 @@ import { openOutline } from 'ionicons/icons'; |
|
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
|
import { distinctUntilChanged, filter, map } from 'rxjs/operators'; |
|
|
|
|
|
|
|
import { CustomPaginatorIntl } from './adapter/custom-paginator-intl'; |
|
|
|
import { GfFooterComponent } from './components/footer/footer.component'; |
|
|
|
import { GfHeaderComponent } from './components/header/header.component'; |
|
|
|
import { GfHoldingDetailDialogComponent } from './components/holding-detail-dialog/holding-detail-dialog.component'; |
|
|
|
@ -85,6 +86,7 @@ export class GfAppComponent implements OnInit { |
|
|
|
ImpersonationStorageService |
|
|
|
); |
|
|
|
private readonly notificationService = inject(NotificationService); |
|
|
|
private readonly paginatorIntl = inject(CustomPaginatorIntl); |
|
|
|
private readonly route = inject(ActivatedRoute); |
|
|
|
private readonly router = inject(Router); |
|
|
|
private readonly title = inject(Title); |
|
|
|
@ -225,6 +227,7 @@ export class GfAppComponent implements OnInit { |
|
|
|
.subscribe((locale) => { |
|
|
|
if (locale) { |
|
|
|
this.dateAdapter.setLocale(locale); |
|
|
|
this.paginatorIntl.setLocale(locale); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
@ -18,6 +18,7 @@ import { |
|
|
|
MAT_DATE_FORMATS, |
|
|
|
MatNativeDateModule |
|
|
|
} from '@angular/material/core'; |
|
|
|
import { MatPaginatorIntl } from '@angular/material/paginator'; |
|
|
|
import { MatSnackBarModule } from '@angular/material/snack-bar'; |
|
|
|
import { MatTooltipModule } from '@angular/material/tooltip'; |
|
|
|
import { bootstrapApplication } from '@angular/platform-browser'; |
|
|
|
@ -28,6 +29,7 @@ import { provideMarkdown } from 'ngx-markdown'; |
|
|
|
import { provideNgxSkeletonLoader } from 'ngx-skeleton-loader'; |
|
|
|
|
|
|
|
import { CustomDateAdapter } from './app/adapter/custom-date-adapter'; |
|
|
|
import { CustomPaginatorIntl } from './app/adapter/custom-paginator-intl'; |
|
|
|
import { DateFormats } from './app/adapter/date-formats'; |
|
|
|
import { GfAppComponent } from './app/app.component'; |
|
|
|
import { routes } from './app/app.routes'; |
|
|
|
@ -93,6 +95,10 @@ import { environment } from './environments/environment'; |
|
|
|
provide: MAT_DATE_FORMATS, |
|
|
|
useValue: DateFormats |
|
|
|
}, |
|
|
|
{ |
|
|
|
provide: MatPaginatorIntl, |
|
|
|
useExisting: CustomPaginatorIntl |
|
|
|
}, |
|
|
|
{ |
|
|
|
provide: TitleStrategy, |
|
|
|
useClass: PageTitleStrategy |
|
|
|
|