Browse Source

implements interpolation in i18n service

pull/4835/head
tobikugel 3 months ago
parent
commit
1703922b5e
  1. 30
      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. 7641
      apps/client/src/locales/messages.es.xlf
  5. 16
      apps/client/src/locales/messages.fr.xlf
  6. 16
      apps/client/src/locales/messages.it.xlf
  7. 16
      apps/client/src/locales/messages.nl.xlf
  8. 16
      apps/client/src/locales/messages.pl.xlf
  9. 16
      apps/client/src/locales/messages.pt.xlf
  10. 16
      apps/client/src/locales/messages.tr.xlf
  11. 16
      apps/client/src/locales/messages.uk.xlf
  12. 14
      apps/client/src/locales/messages.xlf
  13. 16
      apps/client/src/locales/messages.zh.xlf

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

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

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

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

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

@ -7620,6 +7620,22 @@
<context context-type="linenumber">18</context> <context context-type="linenumber">18</context>
</context-group> </context-group>
</trans-unit> </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> </body>
</file> </file>
</xliff> </xliff>

7641
apps/client/src/locales/messages.es.xlf

File diff suppressed because it is too large

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

@ -7620,6 +7620,22 @@
<context context-type="linenumber">181</context> <context context-type="linenumber">181</context>
</context-group> </context-group>
</trans-unit> </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> </body>
</file> </file>
</xliff> </xliff>

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

@ -7621,6 +7621,22 @@
<context context-type="linenumber">181</context> <context context-type="linenumber">181</context>
</context-group> </context-group>
</trans-unit> </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> </body>
</file> </file>
</xliff> </xliff>

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

@ -7620,6 +7620,22 @@
<context context-type="linenumber">181</context> <context context-type="linenumber">181</context>
</context-group> </context-group>
</trans-unit> </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> </body>
</file> </file>
</xliff> </xliff>

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

@ -7620,6 +7620,22 @@
<context context-type="linenumber">181</context> <context context-type="linenumber">181</context>
</context-group> </context-group>
</trans-unit> </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> </body>
</file> </file>
</xliff> </xliff>

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

@ -7620,6 +7620,22 @@
<context context-type="linenumber">181</context> <context context-type="linenumber">181</context>
</context-group> </context-group>
</trans-unit> </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> </body>
</file> </file>
</xliff> </xliff>

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

@ -7620,6 +7620,22 @@
<context context-type="linenumber">18</context> <context context-type="linenumber">18</context>
</context-group> </context-group>
</trans-unit> </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> </body>
</file> </file>
</xliff> </xliff>

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

@ -7620,6 +7620,22 @@
<context context-type="linenumber">181</context> <context context-type="linenumber">181</context>
</context-group> </context-group>
</trans-unit> </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> </body>
</file> </file>
</xliff> </xliff>

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

@ -6852,6 +6852,20 @@
<context context-type="linenumber">223</context> <context context-type="linenumber">223</context>
</context-group> </context-group>
</trans-unit> </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> </body>
</file> </file>
</xliff> </xliff>

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

@ -7621,6 +7621,22 @@
<context context-type="linenumber">181</context> <context context-type="linenumber">181</context>
</context-group> </context-group>
</trans-unit> </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> </body>
</file> </file>
</xliff> </xliff>

Loading…
Cancel
Save