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. 76
      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() {

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

@ -128,50 +128,40 @@
@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> <span class="font-weight-bold"
<ng-container>&nbsp;</ng-container> ><gf-value
<ng-container i18n>this is projected to increase to</ng-container> class="d-inline-block"
<ng-container>&nbsp;</ng-container> [isCurrency]="true"
<span class="font-weight-bold" [locale]="user?.settings?.locale"
><gf-value [unit]="user?.settings?.baseCurrency"
class="d-inline-block" [value]="withdrawalRatePerYearProjected?.toNumber()"
[isCurrency]="true" />
[locale]="user?.settings?.locale" per year</span
[unit]="user?.settings?.baseCurrency" >
[value]="withdrawalRatePerYearProjected?.toNumber()" or
/> <span class="font-weight-bold"
<ng-container>&nbsp;</ng-container> ><gf-value
<ng-container i18n>per year</ng-container></span class="d-inline-block"
> [isCurrency]="true"
<ng-container>&nbsp;</ng-container> [locale]="user?.settings?.locale"
<ng-container i18n>or</ng-container> [unit]="user?.settings?.baseCurrency"
<ng-container>&nbsp;</ng-container> [value]="withdrawalRatePerMonthProjected?.toNumber()"
<span class="font-weight-bold" />
><gf-value per month</span
class="d-inline-block" >, assuming a
[isCurrency]="true" <span class="font-weight-bold"
[locale]="user?.settings?.locale" ><gf-value
[unit]="user?.settings?.baseCurrency" class="d-inline-block"
[value]="withdrawalRatePerMonthProjected?.toNumber()" [isPercent]="true"
/> [locale]="user?.settings?.locale"
<ng-container>&nbsp;</ng-container> [precision]="2"
<ng-container i18n>per month</ng-container></span [value]="user?.settings?.annualInterestRate / 100"
/></span>
annual interest rate.</ng-container
> >
<ng-container i18n>, assuming a</ng-container>
<ng-container>&nbsp;</ng-container>
<span class="font-weight-bold"
><gf-value
class="d-inline-block"
[isPercent]="true"
[locale]="user?.settings?.locale"
[precision]="2"
[value]="user?.settings?.annualInterestRate / 100"
/></span>
<ng-container>&nbsp;</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