Browse Source

Fix localization of FIRE page

pull/7401/head
Thomas Kaul 1 month ago
parent
commit
c31ce24f20
  1. 9
      apps/client/src/app/pages/portfolio/fire/fire-page.component.ts
  2. 28
      apps/client/src/app/pages/portfolio/fire/fire-page.html
  3. 13
      libs/common/src/lib/helper.ts
  4. 10
      libs/ui/src/lib/fire-calculator/fire-calculator.component.ts

9
apps/client/src/app/pages/portfolio/fire/fire-page.component.ts

@ -1,6 +1,7 @@
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service';
import { UserService } from '@ghostfolio/client/services/user/user.service'; import { UserService } from '@ghostfolio/client/services/user/user.service';
import { SubscriptionType } from '@ghostfolio/common/enums'; import { SubscriptionType } from '@ghostfolio/common/enums';
import { formatMonthAndYear } from '@ghostfolio/common/helper';
import { import {
FireCalculationCompleteEvent, FireCalculationCompleteEvent,
FireWealth, FireWealth,
@ -85,10 +86,10 @@ export class GfFirePageComponent implements OnInit {
return ''; return '';
} }
return new Intl.DateTimeFormat(this.user?.settings?.locale, { return formatMonthAndYear({
month: 'long', date: new Date(retirementDate),
year: 'numeric' locale: this.user?.settings?.locale
}).format(new Date(retirementDate)); });
} }
public ngOnInit() { public ngOnInit() {

28
apps/client/src/app/pages/portfolio/fire/fire-page.html

@ -128,13 +128,9 @@
@if (user?.settings?.isExperimentalFeatures) { @if (user?.settings?.isExperimentalFeatures) {
<div> <div>
<ng-container i18n>By</ng-container> <ng-container i18n
<ng-container>&nbsp;</ng-container> >By <span class="font-weight-bold">{{ retirementDateLabel }}</span
<span class="font-weight-bold">{{ retirementDateLabel }}</span> >, this is projected to increase to
<ng-container i18n="@@page.fire.projected.1">,</ng-container>
<ng-container>&nbsp;</ng-container>
<ng-container i18n>this is projected to increase to</ng-container>
<ng-container>&nbsp;</ng-container>
<span class="font-weight-bold" <span class="font-weight-bold"
><gf-value ><gf-value
class="d-inline-block" class="d-inline-block"
@ -143,12 +139,9 @@
[unit]="user?.settings?.baseCurrency" [unit]="user?.settings?.baseCurrency"
[value]="withdrawalRatePerYearProjected?.toNumber()" [value]="withdrawalRatePerYearProjected?.toNumber()"
/> />
<ng-container>&nbsp;</ng-container> per year</span
<ng-container i18n>per year</ng-container></span
> >
<ng-container>&nbsp;</ng-container> or
<ng-container i18n>or</ng-container>
<ng-container>&nbsp;</ng-container>
<span class="font-weight-bold" <span class="font-weight-bold"
><gf-value ><gf-value
class="d-inline-block" class="d-inline-block"
@ -157,11 +150,8 @@
[unit]="user?.settings?.baseCurrency" [unit]="user?.settings?.baseCurrency"
[value]="withdrawalRatePerMonthProjected?.toNumber()" [value]="withdrawalRatePerMonthProjected?.toNumber()"
/> />
<ng-container>&nbsp;</ng-container> per month</span
<ng-container i18n>per month</ng-container></span >, assuming a
>
<ng-container i18n>, assuming a</ng-container>
<ng-container>&nbsp;</ng-container>
<span class="font-weight-bold" <span class="font-weight-bold"
><gf-value ><gf-value
class="d-inline-block" class="d-inline-block"
@ -170,8 +160,8 @@
[precision]="2" [precision]="2"
[value]="user?.settings?.annualInterestRate / 100" [value]="user?.settings?.annualInterestRate / 100"
/></span> /></span>
<ng-container>&nbsp;</ng-container> annual interest rate.</ng-container
<ng-container i18n>annual interest rate</ng-container>. >
</div> </div>
} }
</div> </div>

13
libs/common/src/lib/helper.ts

@ -233,6 +233,19 @@ export function extractNumberFromString({
} }
} }
export function formatMonthAndYear({
date,
locale
}: {
date: Date;
locale?: string;
}) {
return new Intl.DateTimeFormat(locale, {
month: 'long',
year: 'numeric'
}).format(date);
}
export function getAllActivityTypes(): ActivityType[] { export function getAllActivityTypes(): ActivityType[] {
return Object.values(ActivityType); return Object.values(ActivityType);
} }

10
libs/ui/src/lib/fire-calculator/fire-calculator.component.ts

@ -3,7 +3,7 @@ import {
transformTickToAbbreviation transformTickToAbbreviation
} from '@ghostfolio/common/chart-helper'; } from '@ghostfolio/common/chart-helper';
import { primaryColorRgb } from '@ghostfolio/common/config'; import { primaryColorRgb } from '@ghostfolio/common/config';
import { getLocale } from '@ghostfolio/common/helper'; import { formatMonthAndYear, getLocale } from '@ghostfolio/common/helper';
import { FireCalculationCompleteEvent } from '@ghostfolio/common/interfaces'; import { FireCalculationCompleteEvent } from '@ghostfolio/common/interfaces';
import { ColorScheme } from '@ghostfolio/common/types'; import { ColorScheme } from '@ghostfolio/common/types';
@ -215,10 +215,10 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy {
return ''; return '';
} }
return new Intl.DateTimeFormat(this.locale, { return formatMonthAndYear({
month: 'long', date: retirementDate,
year: 'numeric' locale: this.locale
}).format(retirementDate); });
} }
public ngOnChanges() { public ngOnChanges() {

Loading…
Cancel
Save