From 0fa039a7e0d837e8db8060364ed1d68d5a09e6fb Mon Sep 17 00:00:00 2001 From: Shane Date: Fri, 25 Jul 2025 12:44:22 -0700 Subject: [PATCH] Escape any potential <0> tags from i18n arguments --- libs/components/src/i18n/i18n.component.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libs/components/src/i18n/i18n.component.ts b/libs/components/src/i18n/i18n.component.ts index 11540f686ca..7b3957bca48 100644 --- a/libs/components/src/i18n/i18n.component.ts +++ b/libs/components/src/i18n/i18n.component.ts @@ -59,10 +59,26 @@ export class I18nComponent { */ args = input<(string | number)[]>([]); + /** + * Escapes any <0> like tags that may be present in the arguments to + * prevent breaking the template rendering. + */ + escapeArgs(args: (string | number)[]): (string | number)[] { + return args.map((arg) => { + if (typeof arg === "string") { + return arg.replace(/<\/?\d+>/g, (tag) => tag.replace(//g, ">")); + } + return arg.toString(); + }); + } + private tagTemplates = contentChildren(I18nPartDirective, { read: TemplateRef }); private translatedText = computed(() => { - const translatedText = this.i18nService.t(this.translationKey(), ...this.args()); + const translatedText = this.i18nService.t( + this.translationKey(), + ...this.escapeArgs(this.args()), + ); return this.parseTranslatedString(translatedText); });