From 604ba7f2d1e98acf8bb01e12eeae313805b3eab9 Mon Sep 17 00:00:00 2001 From: csehatt741 Date: Fri, 27 Jun 2025 16:13:47 +0200 Subject: [PATCH] CurrencyClusterRiskCurrentInvestment localized --- .../base-currency-current-investment.ts | 8 ++-- .../current-investment.ts | 41 +++++++++++++------ apps/client/src/app/pages/i18n/i18n-page.html | 10 +++++ 3 files changed, 42 insertions(+), 17 deletions(-) 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 94a5957f5..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 @@ -56,10 +56,10 @@ 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 90dc10b6e..232dabba3 100644 --- a/apps/client/src/app/pages/i18n/i18n-page.html +++ b/apps/client/src/app/pages/i18n/i18n-page.html @@ -68,6 +68,16 @@ 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