Skip to content

The open alternative to Salesforce, designed for AI.

fix(i18n): repair backslash-escaped tags in Crowdin inline code (#24674)

Abdul Rahmanbb4469747870
diff --git a/packages/twenty-utils/crowdin-normalizer/rules/__tests__/escaped-inline-code-tags.rule.spec.ts b/packages/twenty-utils/crowdin-normalizer/rules/__tests__/escaped-inline-code-tags.rule.spec.ts
index 7b448f29f44..de5dd75bc5e 100644
--- a/packages/twenty-utils/crowdin-normalizer/rules/__tests__/escaped-inline-code-tags.rule.spec.ts
+++ b/packages/twenty-utils/crowdin-normalizer/rules/__tests__/escaped-inline-code-tags.rule.spec.ts
@@ -29,6 +29,34 @@ describe('ESCAPED_INLINE_CODE_TAGS_RULE', () => {
expect(sourceFilter?.('Escape a literal < in prose')).toBe(false);
});
+ it('repairs a backslash-escaped tag inside an inline-code span', () => {
+ const translationText =
+ 'Ouvrez `https://\\<your-workspace-subdomain>.withtwenty.com`';
+
+ expect(detect(translationText)).toBe(true);
+ expect(fix(translationText)).toBe(
+ 'Ouvrez `https://<your-workspace-subdomain>.withtwenty.com`',
+ );
+ });
+
+ it('repairs several backslash-escaped tags in one span', () => {
+ expect(fix('Utilisez `\\<server-url>/s/\\<path>` ici')).toBe(
+ 'Utilisez `<server-url>/s/<path>` ici',
+ );
+ });
+
+ it('leaves backslash-escaped angle brackets outside inline code untouched', () => {
+ expect(fix('Gardez `\\<path>` mais laissez \\<literal> en prose')).toBe(
+ 'Gardez `<path>` mais laissez \\<literal> en prose',
+ );
+ });
+
+ it('is idempotent for backslash escapes', () => {
+ const once = fix('Utilisez `\\<path>` et `\\<name>`');
+
+ expect(fix(once)).toBe(once);
+ });
+
it('is idempotent', () => {
const once = fix('Remplacez `&lt;path&gt;` par `&lt;autre&gt;`');
diff --git a/packages/twenty-utils/crowdin-normalizer/rules/escaped-inline-code-tags.rule.ts b/packages/twenty-utils/crowdin-normalizer/rules/escaped-inline-code-tags.rule.ts
index 4b76ca9c8f1..39e99e36aad 100644
--- a/packages/twenty-utils/crowdin-normalizer/rules/escaped-inline-code-tags.rule.ts
+++ b/packages/twenty-utils/crowdin-normalizer/rules/escaped-inline-code-tags.rule.ts
@@ -1,7 +1,9 @@
import { type NormalizationRule } from '../types/normalization-rule.type';
const INLINE_CODE_SPAN_REGEX = /`[^`\n]+`/g;
-const ESCAPED_TAG_REGEX = /&lt;|&gt;|&#0*60;|&#0*62;|&#x0*3c;|&#x0*3e;/i;
+
+const ESCAPED_TAG_REGEX =
+ /&lt;|&gt;|&#0*60;|&#0*62;|&#x0*3c;|&#x0*3e;|\\<|\\>/i;
function inlineCodeSpans(text: string): string[] {
return text.match(INLINE_CODE_SPAN_REGEX) ?? [];
@@ -23,7 +25,9 @@ function unescapeTagsInInlineCode(text: string): string {
.replace(/&lt;/gi, '<')
.replace(/&gt;/gi, '>')
.replace(/&#0*60;|&#x0*3c;/gi, '<')
- .replace(/&#0*62;|&#x0*3e;/gi, '>'),
+ .replace(/&#0*62;|&#x0*3e;/gi, '>')
+ .replace(/\\</g, '<')
+ .replace(/\\>/g, '>'),
);
}