diff --git a/CHANGELOG.md b/CHANGELOG.md index 2241ef9eb..940093881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Set up the language localization for the static portfolio analysis rule: _Asset Class Cluster Risks_ (Equity) - Set up the language localization for the static portfolio analysis rule: _Asset Class Cluster Risks_ (Fixed Income) +- Set up the language localization for the static portfolio analysis rule: _Currency Cluster Risks_ (Investment) +- Set up the language localization for the static portfolio analysis rule: _Currency Cluster Risks_ (Investment: Base Currency) ### Changed diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 6a580f42f..fc125656b 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -1300,11 +1300,15 @@ export class PortfolioService { [ new CurrencyClusterRiskBaseCurrencyCurrentInvestment( this.exchangeRateDataService, - Object.values(holdings) + this.i18nService, + Object.values(holdings), + userSettings.language ), new CurrencyClusterRiskCurrentInvestment( this.exchangeRateDataService, - Object.values(holdings) + this.i18nService, + Object.values(holdings), + userSettings.language ) ], userSettings diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.ts index 161d490d7..749904803 100644 --- a/apps/api/src/app/user/user.service.ts +++ b/apps/api/src/app/user/user.service.ts @@ -285,11 +285,15 @@ export class UserService { ).getSettings(user.Settings.settings), CurrencyClusterRiskBaseCurrencyCurrentInvestment: new CurrencyClusterRiskBaseCurrencyCurrentInvestment( + undefined, + undefined, undefined, undefined ).getSettings(user.Settings.settings), CurrencyClusterRiskCurrentInvestment: new CurrencyClusterRiskCurrentInvestment( + undefined, + undefined, undefined, undefined ).getSettings(user.Settings.settings), diff --git a/apps/api/src/models/rules/currency-cluster-risk/base-currency-current-investment.ts b/apps/api/src/models/rules/currency-cluster-risk/base-currency-current-investment.ts index 6de686a9e..0bf93e9b9 100644 --- a/apps/api/src/models/rules/currency-cluster-risk/base-currency-current-investment.ts +++ b/apps/api/src/models/rules/currency-cluster-risk/base-currency-current-investment.ts @@ -1,6 +1,7 @@ import { RuleSettings } from '@ghostfolio/api/models/interfaces/rule-settings.interface'; import { Rule } from '@ghostfolio/api/models/rule'; import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; +import { I18nService } from '@ghostfolio/api/services/i18n/i18n.service'; import { PortfolioPosition, UserSettings } from '@ghostfolio/common/interfaces'; export class CurrencyClusterRiskBaseCurrencyCurrentInvestment extends Rule { @@ -8,10 +9,13 @@ export class CurrencyClusterRiskBaseCurrencyCurrentInvestment extends Rule { @@ -8,10 +9,13 @@ export class CurrencyClusterRiskCurrentInvestment extends Rule { public constructor( protected exchangeRateDataService: ExchangeRateDataService, - holdings: PortfolioPosition[] + private i18nService: I18nService, + holdings: PortfolioPosition[], + languageCode: string ) { super(exchangeRateDataService, { - key: CurrencyClusterRiskCurrentInvestment.name + key: CurrencyClusterRiskCurrentInvestment.name, + languageCode }); this.holdings = holdings; @@ -41,21 +45,29 @@ export class CurrencyClusterRiskCurrentInvestment extends Rule { if (maxValueRatio > ruleSettings.thresholdMax) { return { - evaluation: `Over ${ - ruleSettings.thresholdMax * 100 - }% of your current investment is in ${maxItem.groupKey} (${( - maxValueRatio * 100 - ).toPrecision(3)}%)`, + evaluation: this.i18nService.getTranslation({ + id: 'rule.currencyClusterRiskCurrentInvestment.false', + languageCode: this.getLanguageCode(), + placeholders: { + currency: maxItem.groupKey as string, + maxValueRatio: (maxValueRatio * 100).toPrecision(3), + thresholdMax: ruleSettings.thresholdMax * 100 + } + }), value: false }; } return { - evaluation: `The major part of your current investment is in ${ - maxItem?.groupKey ?? ruleSettings.baseCurrency - } (${(maxValueRatio * 100).toPrecision(3)}%) and does not exceed ${ - ruleSettings.thresholdMax * 100 - }%`, + evaluation: this.i18nService.getTranslation({ + id: 'rule.currencyClusterRiskCurrentInvestment.true', + languageCode: this.getLanguageCode(), + placeholders: { + currency: maxItem.groupKey as string, + maxValueRatio: (maxValueRatio * 100).toPrecision(3), + thresholdMax: ruleSettings.thresholdMax * 100 + } + }), value: true }; } @@ -73,7 +85,10 @@ export class CurrencyClusterRiskCurrentInvestment extends Rule { } public getName() { - return 'Investment'; + return this.i18nService.getTranslation({ + id: 'rule.currencyClusterRiskCurrentInvestment', + languageCode: this.getLanguageCode() + }); } public getSettings({ baseCurrency, xRayRules }: UserSettings): Settings { diff --git a/apps/client/src/app/pages/i18n/i18n-page.html b/apps/client/src/app/pages/i18n/i18n-page.html index 6ffd5b011..232dabba3 100644 --- a/apps/client/src/app/pages/i18n/i18n-page.html +++ b/apps/client/src/app/pages/i18n/i18n-page.html @@ -57,6 +57,27 @@ (${fixedIncomeValueRatio}%) is within the range of ${thresholdMin}% and ${thresholdMax}% +
  • + Investment: Base Currency +
  • +
  • + The major part of your current investment is not in your base currency + (${baseCurrencyValueRatio}% in ${baseCurrency}) +
  • +
  • + The major part of your current investment is in your base currency + (${baseCurrencyValueRatio}% in ${baseCurrency}) +
  • +
  • Investment
  • +
  • + Over ${thresholdMax}% of your current investment is in + ${currency} (${maxValueRatio}%) +
  • +
  • + The major part of your current investment is in ${currency} + (${maxValueRatio}%) and does not exceed + ${thresholdMax}% +
  • Emergency Fund: Set up
  • No emergency fund has been set up