Browse Source

implements interpolation in i18n service

pull/4779/head
tobikugel 3 months ago
committed by Thomas Kaul
parent
commit
b40ad4362d
  1. 26
      apps/api/src/models/rules/fees/fee-ratio-initial-investment.ts
  2. 12
      apps/api/src/services/i18n/i18n.service.ts
  3. 16
      apps/client/src/locales/messages.de.xlf
  4. 16
      apps/client/src/locales/messages.fr.xlf
  5. 16
      apps/client/src/locales/messages.it.xlf
  6. 16
      apps/client/src/locales/messages.nl.xlf
  7. 16
      apps/client/src/locales/messages.pl.xlf
  8. 16
      apps/client/src/locales/messages.pt.xlf
  9. 16
      apps/client/src/locales/messages.tr.xlf
  10. 16
      apps/client/src/locales/messages.uk.xlf
  11. 14
      apps/client/src/locales/messages.xlf
  12. 16
      apps/client/src/locales/messages.zh.xlf

26
apps/api/src/models/rules/fees/fee-ratio-initial-investment.ts

@ -30,13 +30,14 @@ export class FeeRatioInitialInvestment extends Rule<Settings> {
: 0;
if (feeRatio > ruleSettings.thresholdMax) {
const evaluation = this.i18nService
.getTranslation({
const evaluation = this.i18nService.getTranslation({
id: 'rule.fee-ratio-initial-investment.exceed',
languageCode: DEFAULT_LANGUAGE_CODE
})
.replace('{thresholdMax}', (ruleSettings.thresholdMax * 100).toFixed(2))
.replace('{feeRatio}', (feeRatio * 100).toPrecision(3));
languageCode: DEFAULT_LANGUAGE_CODE,
placeholders: {
feeRatio: (ruleSettings.thresholdMax * 100).toFixed(2),
thresholdMax: (feeRatio * 100).toPrecision(3)
}
});
return {
evaluation,
@ -44,13 +45,14 @@ export class FeeRatioInitialInvestment extends Rule<Settings> {
};
}
const evaluation = this.i18nService
.getTranslation({
const evaluation = this.i18nService.getTranslation({
id: 'rule.fee-ratio-initial-investment.not-exceed',
languageCode: DEFAULT_LANGUAGE_CODE
})
.replace('{thresholdMax}', (ruleSettings.thresholdMax * 100).toFixed(2))
.replace('{feeRatio}', (feeRatio * 100).toPrecision(3));
languageCode: DEFAULT_LANGUAGE_CODE,
placeholders: {
feeRatio: (feeRatio * 100).toPrecision(3),
thresholdMax: (ruleSettings.thresholdMax * 100).toFixed(2)
}
});
return {
evaluation,

12
apps/api/src/services/i18n/i18n.service.ts

@ -15,10 +15,12 @@ export class I18nService {
public getTranslation({
id,
languageCode
languageCode,
placeholders
}: {
id: string;
languageCode: string;
placeholders?: Record<string, string | number>;
}): string {
const $ = this.translations[languageCode];
@ -26,7 +28,7 @@ export class I18nService {
Logger.warn(`Translation not found for locale '${languageCode}'`);
}
const translatedText = $(
let translatedText = $(
`trans-unit[id="${id}"] > ${
languageCode === DEFAULT_LANGUAGE_CODE ? 'source' : 'target'
}`
@ -38,6 +40,12 @@ export class I18nService {
);
}
if (placeholders) {
for (const [key, value] of Object.entries(placeholders)) {
translatedText = translatedText.replace(`{${key}}`, String(value));
}
}
return translatedText.trim();
}

16
apps/client/src/locales/messages.de.xlf

@ -7620,6 +7620,22 @@
<context context-type="linenumber">181</context>
</context-group>
</trans-unit>
<trans-unit id="3920411961658116502" datatype="html">
<source>Demo user account has been synced.</source>
<target state="new">Demo user account has been synced.</target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/components/admin-overview/admin-overview.component.ts</context>
<context context-type="linenumber">223</context>
</context-group>
</trans-unit>
<trans-unit id="18fe01d6ae816d6787148e59ea1a39d0bb542e24" datatype="html">
<source>Sync Demo User Account</source>
<target state="new">Sync Demo User Account</target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/components/admin-overview/admin-overview.html</context>
<context context-type="linenumber">181</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>

16
apps/client/src/locales/messages.fr.xlf

@ -7620,6 +7620,22 @@
<context context-type="linenumber">181</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.exceed" datatype="html">
<source> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">14</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.not-exceed" datatype="html">
<source> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">18</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>

16
apps/client/src/locales/messages.it.xlf

@ -7621,6 +7621,22 @@
<context context-type="linenumber">181</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.exceed" datatype="html">
<source> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">14</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.not-exceed" datatype="html">
<source> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">18</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>

16
apps/client/src/locales/messages.nl.xlf

@ -7620,6 +7620,22 @@
<context context-type="linenumber">181</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.exceed" datatype="html">
<source> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">14</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.not-exceed" datatype="html">
<source> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">18</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>

16
apps/client/src/locales/messages.pl.xlf

@ -7620,6 +7620,22 @@
<context context-type="linenumber">181</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.exceed" datatype="html">
<source> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">14</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.not-exceed" datatype="html">
<source> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">18</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>

16
apps/client/src/locales/messages.pt.xlf

@ -7620,6 +7620,22 @@
<context context-type="linenumber">181</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.exceed" datatype="html">
<source> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">14</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.not-exceed" datatype="html">
<source> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">18</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>

16
apps/client/src/locales/messages.tr.xlf

@ -7620,6 +7620,22 @@
<context context-type="linenumber">181</context>
</context-group>
</trans-unit>
<trans-unit id="3920411961658116502" datatype="html">
<source>Demo user account has been synced.</source>
<target state="new">Demo user account has been synced.</target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/components/admin-overview/admin-overview.component.ts</context>
<context context-type="linenumber">223</context>
</context-group>
</trans-unit>
<trans-unit id="18fe01d6ae816d6787148e59ea1a39d0bb542e24" datatype="html">
<source>Sync Demo User Account</source>
<target state="new">Sync Demo User Account</target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/components/admin-overview/admin-overview.html</context>
<context context-type="linenumber">181</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>

16
apps/client/src/locales/messages.uk.xlf

@ -7620,6 +7620,22 @@
<context context-type="linenumber">181</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.exceed" datatype="html">
<source> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">14</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.not-exceed" datatype="html">
<source> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">18</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>

14
apps/client/src/locales/messages.xlf

@ -6852,6 +6852,20 @@
<context context-type="linenumber">223</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.exceed" datatype="html">
<source> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">14</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.not-exceed" datatype="html">
<source> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">18</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>

16
apps/client/src/locales/messages.zh.xlf

@ -7621,6 +7621,22 @@
<context context-type="linenumber">181</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.exceed" datatype="html">
<source> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">14</context>
</context-group>
</trans-unit>
<trans-unit id="rule.fee-ratio-initial-investment.not-exceed" datatype="html">
<source> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </source>
<target state="new"> The fees do not exceed {thresholdMax}% of your initial investment ({feeRatio}%) </target>
<context-group purpose="location">
<context context-type="sourcefile">apps/client/src/app/pages/i18n/i18n-page.html</context>
<context context-type="linenumber">18</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>

Loading…
Cancel
Save