From 6ec2bb58334ca3014573c4cbd4834ee3a40afd9d Mon Sep 17 00:00:00 2001
From: "Mohammed A. H. Lubbad" <2379793+mlubbad@users.noreply.github.com>
Date: Sun, 22 Nov 2026 07:08:26 +0300
Subject: [PATCH] feat(i18n): add Arabic query synonym normalization and
RTL-safe HTML preview rendering (#586)
* feat(i18n): add Arabic query synonym normalization and RTL-safe HTML preview rendering
* fix(i18n): sync .claude assets, scope RTL letter-spacing, drop dead rtl_ready key, and add unit tests
Signed-off-by: Dr. Mohammed Lubbad
* fix(i18n): update runtimeFingerprint after rebasing onto main
Signed-off-by: Dr. Mohammed Lubbad
---------
Signed-off-by: Dr. Mohammed Lubbad
---
.claude/skills/ui-ux-pro-max/scripts/core.py | 36 +++++++++++++++++--
.../skills/ui-ux-pro-max/scripts/preview.py | 32 ++++++++++++-----
.../tests/fixtures/relevance-thresholds.json | 2 +-
.../scripts/tests/test_rtl_support.py | 35 ++++++++++++++++++
cli/assets/scripts/core.py | 36 +++++++++++++++++--
cli/assets/scripts/preview.py | 32 ++++++++++++-----
.../tests/fixtures/relevance-thresholds.json | 2 +-
cli/assets/scripts/tests/test_rtl_support.py | 35 ++++++++++++++++++
src/ui-ux-pro-max/scripts/core.py | 36 +++++++++++++++++--
src/ui-ux-pro-max/scripts/preview.py | 32 ++++++++++++-----
.../tests/fixtures/relevance-thresholds.json | 2 +-
.../scripts/tests/test_rtl_support.py | 35 ++++++++++++++++++
12 files changed, 282 insertions(+), 33 deletions(-)
diff --git a/.claude/skills/ui-ux-pro-max/scripts/core.py b/.claude/skills/ui-ux-pro-max/scripts/core.py
index 02a3eee..7509333 100644
--- a/.claude/skills/ui-ux-pro-max/scripts/core.py
+++ b/.claude/skills/ui-ux-pro-max/scripts/core.py
@@ -271,8 +271,40 @@ _SYNONYMS = {
"organisation": "organization",
"behaviour": "behavior",
"ux/ui": "ux ui",
+ # Arabic & MENA bilingual domain/style/product synonyms
+ "تداول": "trading crypto fintech",
+ "مالية": "fintech finance banking",
+ "مالي": "fintech finance banking",
+ "بنك": "banking fintech finance",
+ "مصرف": "banking fintech finance",
+ "ذكاء اصطناعي": "ai artificial intelligence",
+ "عيادة": "healthcare medical clinic",
+ "طبي": "healthcare medical clinic",
+ "طبية": "healthcare medical clinic",
+ "مستشفى": "healthcare hospital medical",
+ "متجر": "ecommerce store shopping",
+ "تجارة إلكترونية": "ecommerce shopping retail",
+ "لوحة تحكم": "dashboard analytics saas",
+ "تحليلات": "analytics dashboard data",
+ "عقارات": "real estate property",
+ "تعليم": "education learning course",
+ "أكاديمية": "education learning academy",
+ "تدريب": "education learning training",
+ "فندق": "hotel hospitality booking",
+ "سياحة": "travel hospitality booking",
+ "مطعم": "restaurant food delivery",
+ "أمن سيبراني": "cybersecurity security",
+ "ألعاب": "gaming game",
+ "معرض أعمال": "portfolio agency creative",
+ "داكن": "dark mode",
+ "مظلم": "dark mode",
+ "زجاجي": "glassmorphism glass",
+ "بسيط": "minimalism clean",
}
+# Arabic-scoped diacritics (harakat/tashkeel) and tatweel; no-op on non-Arabic text.
+_ARABIC_DIACRITICS_RE = re.compile(r"[\u0617-\u061A\u064B-\u0652\u0640]")
+
_SYNONYM_PATTERNS = [
(re.compile(r"(? str:
"""Render a dependency-free HTML page for the generated design system."""
project = design_system.get("project_name") or "Design system"
+ # Detect RTL preview via explicit direction/lang metadata or Arabic script in project_name.
+ is_arabic = bool(
+ design_system.get("direction") == "rtl"
+ or design_system.get("lang") == "ar"
+ or re.search(r"[\u0600-\u06FF]", str(project))
+ )
+ html_lang = "ar" if is_arabic else "en"
+ html_dir = ' dir="rtl"' if is_arabic else ""
+ eyebrow_spacing = "0" if is_arabic else "0.08em"
+ eyebrow_transform = "none" if is_arabic else "uppercase"
+ badge_spacing = "0" if is_arabic else "0.04em"
category = design_system.get("category") or ""
style = design_system.get("style") or {}
colors = design_system.get("colors") or {}
@@ -168,15 +179,17 @@ def format_preview_html(design_system: dict) -> str:
)
ratio_html = (
f'vs {_text(pair_label)} '
- f'{_text(pair_hex)}: {_text(_format_ratio(ratio))} '
- f'{_text(level)}
'
+ f'{_text(pair_hex)}: '
+ f'{_text(_format_ratio(ratio))} '
+ f'{_text(level)}
'
)
swatches.append(
f''
f''
f''
)
@@ -207,7 +220,7 @@ def format_preview_html(design_system: dict) -> str:
anti_html = "".join(anti_items)
return f"""
-
+
@@ -245,8 +258,8 @@ def format_preview_html(design_system: dict) -> str:
}}
.eyebrow {{
margin: 0 0 0.35rem;
- text-transform: uppercase;
- letter-spacing: 0.08em;
+ text-transform: {eyebrow_transform};
+ letter-spacing: {eyebrow_spacing};
font-size: 0.75rem;
color: {muted_fg};
}}
@@ -255,6 +268,9 @@ def format_preview_html(design_system: dict) -> str:
line-height: 1.2;
margin: 0 0 0.5rem;
}}
+ html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3, html[dir="rtl"] .specimen-heading {{
+ letter-spacing: 0;
+ }}
h1 {{ font-size: 2.25rem; }}
h2 {{ font-size: 1.5rem; }}
h3 {{ font-size: 1.2rem; }}
@@ -292,12 +308,12 @@ def format_preview_html(design_system: dict) -> str:
code {{ font-size: 0.85em; }}
.badge {{
display: inline-block;
- margin-left: 0.35rem;
+ margin-inline-start: 0.35rem;
padding: 0.05rem 0.4rem;
border-radius: 999px;
font-size: 0.75rem;
font-weight: 700;
- letter-spacing: 0.04em;
+ letter-spacing: {badge_spacing};
}}
.badge-aaa {{ background: {primary}; color: {on_primary}; }}
.badge-aa {{ background: {muted}; color: {muted_fg}; }}
diff --git a/.claude/skills/ui-ux-pro-max/scripts/tests/fixtures/relevance-thresholds.json b/.claude/skills/ui-ux-pro-max/scripts/tests/fixtures/relevance-thresholds.json
index 008ebb4..10ce849 100644
--- a/.claude/skills/ui-ux-pro-max/scripts/tests/fixtures/relevance-thresholds.json
+++ b/.claude/skills/ui-ux-pro-max/scripts/tests/fixtures/relevance-thresholds.json
@@ -2,7 +2,7 @@
"schemaVersion": 1,
"status": "provisional-baseline-regression-gate",
"baselineRevision": "97eb2a2",
- "runtimeFingerprint": "e074c9b35d8385e2fb8ce6ba42ac1f9d225c93a982c1dbfc55da9b18a3f1ac73",
+ "runtimeFingerprint": "6f50331454236ff817a9617fdabbf8393309276e3b98e0005c0e007ccc933dbd",
"oracleFingerprint": "02e7226428c64a995ec24ae104ce4d186f5f91bf0f062556e90ef9b0fcb6d67a",
"approvingMaintainer": "repository maintainer approved Phase 1 testing checkpoint; second judgment review remains required before final-target promotion",
"units": "All metrics are ratios in [0,1]. Precision treats missing ranks as non-relevant. Negative abstention is measured across the hard-negative by domain/stack cross-product.",
diff --git a/.claude/skills/ui-ux-pro-max/scripts/tests/test_rtl_support.py b/.claude/skills/ui-ux-pro-max/scripts/tests/test_rtl_support.py
index d013af8..09f1347 100644
--- a/.claude/skills/ui-ux-pro-max/scripts/tests/test_rtl_support.py
+++ b/.claude/skills/ui-ux-pro-max/scripts/tests/test_rtl_support.py
@@ -162,5 +162,40 @@ class RtlCliTest(unittest.TestCase):
self.assertIn("product", completed.stderr)
+class ArabicSynonymsAndRtlPreviewTest(unittest.TestCase):
+ def test_arabic_diacritics_and_tatweel_stripped_in_normalize(self):
+ from core import _normalize
+ norm = _normalize("مَـتْـجَـر ذَكَاء اصْطِنَاعِي دَاكِن")
+ self.assertIn("ecommerce", norm)
+ self.assertIn("artificial intelligence", norm)
+ self.assertIn("dark mode", norm)
+
+ def test_arabic_query_resolves_domain_and_style(self):
+ res_product = search("عيادة طبية", "product", 3)
+ self.assertGreater(res_product["count"], 0)
+ res_style = search("زجاجي داكن", "style", 3)
+ self.assertGreater(res_style["count"], 0)
+
+ def test_preview_html_arabic_rtl_and_ltr_scoping(self):
+ from preview import format_preview_html
+ ar_html = format_preview_html({
+ "project_name": "منصة التداول الذكي",
+ "category": "Fintech",
+ "colors": {"primary": "#1E40AF", "on_primary": "#FFFFFF"},
+ })
+ self.assertIn('', ar_html)
+ self.assertIn('html[dir="rtl"] h1, html[dir="rtl"] h2', ar_html)
+ self.assertIn('letter-spacing: 0;', ar_html)
+ self.assertIn('#1E40AF', ar_html)
+
+ en_html = format_preview_html({
+ "project_name": "Acme Dashboard",
+ "category": "SaaS",
+ "colors": {"primary": "#1E40AF", "on_primary": "#FFFFFF"},
+ })
+ self.assertIn('', en_html)
+ self.assertNotIn('dir="rtl">', en_html)
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/cli/assets/scripts/core.py b/cli/assets/scripts/core.py
index 02a3eee..7509333 100644
--- a/cli/assets/scripts/core.py
+++ b/cli/assets/scripts/core.py
@@ -271,8 +271,40 @@ _SYNONYMS = {
"organisation": "organization",
"behaviour": "behavior",
"ux/ui": "ux ui",
+ # Arabic & MENA bilingual domain/style/product synonyms
+ "تداول": "trading crypto fintech",
+ "مالية": "fintech finance banking",
+ "مالي": "fintech finance banking",
+ "بنك": "banking fintech finance",
+ "مصرف": "banking fintech finance",
+ "ذكاء اصطناعي": "ai artificial intelligence",
+ "عيادة": "healthcare medical clinic",
+ "طبي": "healthcare medical clinic",
+ "طبية": "healthcare medical clinic",
+ "مستشفى": "healthcare hospital medical",
+ "متجر": "ecommerce store shopping",
+ "تجارة إلكترونية": "ecommerce shopping retail",
+ "لوحة تحكم": "dashboard analytics saas",
+ "تحليلات": "analytics dashboard data",
+ "عقارات": "real estate property",
+ "تعليم": "education learning course",
+ "أكاديمية": "education learning academy",
+ "تدريب": "education learning training",
+ "فندق": "hotel hospitality booking",
+ "سياحة": "travel hospitality booking",
+ "مطعم": "restaurant food delivery",
+ "أمن سيبراني": "cybersecurity security",
+ "ألعاب": "gaming game",
+ "معرض أعمال": "portfolio agency creative",
+ "داكن": "dark mode",
+ "مظلم": "dark mode",
+ "زجاجي": "glassmorphism glass",
+ "بسيط": "minimalism clean",
}
+# Arabic-scoped diacritics (harakat/tashkeel) and tatweel; no-op on non-Arabic text.
+_ARABIC_DIACRITICS_RE = re.compile(r"[\u0617-\u061A\u064B-\u0652\u0640]")
+
_SYNONYM_PATTERNS = [
(re.compile(r"(? str:
"""Render a dependency-free HTML page for the generated design system."""
project = design_system.get("project_name") or "Design system"
+ # Detect RTL preview via explicit direction/lang metadata or Arabic script in project_name.
+ is_arabic = bool(
+ design_system.get("direction") == "rtl"
+ or design_system.get("lang") == "ar"
+ or re.search(r"[\u0600-\u06FF]", str(project))
+ )
+ html_lang = "ar" if is_arabic else "en"
+ html_dir = ' dir="rtl"' if is_arabic else ""
+ eyebrow_spacing = "0" if is_arabic else "0.08em"
+ eyebrow_transform = "none" if is_arabic else "uppercase"
+ badge_spacing = "0" if is_arabic else "0.04em"
category = design_system.get("category") or ""
style = design_system.get("style") or {}
colors = design_system.get("colors") or {}
@@ -168,15 +179,17 @@ def format_preview_html(design_system: dict) -> str:
)
ratio_html = (
f'vs {_text(pair_label)} '
- f'{_text(pair_hex)}: {_text(_format_ratio(ratio))} '
- f'{_text(level)}
'
+ f'{_text(pair_hex)}: '
+ f'{_text(_format_ratio(ratio))} '
+ f'{_text(level)}'
)
swatches.append(
f''
f''
f''
)
@@ -207,7 +220,7 @@ def format_preview_html(design_system: dict) -> str:
anti_html = "".join(anti_items)
return f"""
-
+
@@ -245,8 +258,8 @@ def format_preview_html(design_system: dict) -> str:
}}
.eyebrow {{
margin: 0 0 0.35rem;
- text-transform: uppercase;
- letter-spacing: 0.08em;
+ text-transform: {eyebrow_transform};
+ letter-spacing: {eyebrow_spacing};
font-size: 0.75rem;
color: {muted_fg};
}}
@@ -255,6 +268,9 @@ def format_preview_html(design_system: dict) -> str:
line-height: 1.2;
margin: 0 0 0.5rem;
}}
+ html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3, html[dir="rtl"] .specimen-heading {{
+ letter-spacing: 0;
+ }}
h1 {{ font-size: 2.25rem; }}
h2 {{ font-size: 1.5rem; }}
h3 {{ font-size: 1.2rem; }}
@@ -292,12 +308,12 @@ def format_preview_html(design_system: dict) -> str:
code {{ font-size: 0.85em; }}
.badge {{
display: inline-block;
- margin-left: 0.35rem;
+ margin-inline-start: 0.35rem;
padding: 0.05rem 0.4rem;
border-radius: 999px;
font-size: 0.75rem;
font-weight: 700;
- letter-spacing: 0.04em;
+ letter-spacing: {badge_spacing};
}}
.badge-aaa {{ background: {primary}; color: {on_primary}; }}
.badge-aa {{ background: {muted}; color: {muted_fg}; }}
diff --git a/cli/assets/scripts/tests/fixtures/relevance-thresholds.json b/cli/assets/scripts/tests/fixtures/relevance-thresholds.json
index 008ebb4..10ce849 100644
--- a/cli/assets/scripts/tests/fixtures/relevance-thresholds.json
+++ b/cli/assets/scripts/tests/fixtures/relevance-thresholds.json
@@ -2,7 +2,7 @@
"schemaVersion": 1,
"status": "provisional-baseline-regression-gate",
"baselineRevision": "97eb2a2",
- "runtimeFingerprint": "e074c9b35d8385e2fb8ce6ba42ac1f9d225c93a982c1dbfc55da9b18a3f1ac73",
+ "runtimeFingerprint": "6f50331454236ff817a9617fdabbf8393309276e3b98e0005c0e007ccc933dbd",
"oracleFingerprint": "02e7226428c64a995ec24ae104ce4d186f5f91bf0f062556e90ef9b0fcb6d67a",
"approvingMaintainer": "repository maintainer approved Phase 1 testing checkpoint; second judgment review remains required before final-target promotion",
"units": "All metrics are ratios in [0,1]. Precision treats missing ranks as non-relevant. Negative abstention is measured across the hard-negative by domain/stack cross-product.",
diff --git a/cli/assets/scripts/tests/test_rtl_support.py b/cli/assets/scripts/tests/test_rtl_support.py
index d013af8..09f1347 100644
--- a/cli/assets/scripts/tests/test_rtl_support.py
+++ b/cli/assets/scripts/tests/test_rtl_support.py
@@ -162,5 +162,40 @@ class RtlCliTest(unittest.TestCase):
self.assertIn("product", completed.stderr)
+class ArabicSynonymsAndRtlPreviewTest(unittest.TestCase):
+ def test_arabic_diacritics_and_tatweel_stripped_in_normalize(self):
+ from core import _normalize
+ norm = _normalize("مَـتْـجَـر ذَكَاء اصْطِنَاعِي دَاكِن")
+ self.assertIn("ecommerce", norm)
+ self.assertIn("artificial intelligence", norm)
+ self.assertIn("dark mode", norm)
+
+ def test_arabic_query_resolves_domain_and_style(self):
+ res_product = search("عيادة طبية", "product", 3)
+ self.assertGreater(res_product["count"], 0)
+ res_style = search("زجاجي داكن", "style", 3)
+ self.assertGreater(res_style["count"], 0)
+
+ def test_preview_html_arabic_rtl_and_ltr_scoping(self):
+ from preview import format_preview_html
+ ar_html = format_preview_html({
+ "project_name": "منصة التداول الذكي",
+ "category": "Fintech",
+ "colors": {"primary": "#1E40AF", "on_primary": "#FFFFFF"},
+ })
+ self.assertIn('', ar_html)
+ self.assertIn('html[dir="rtl"] h1, html[dir="rtl"] h2', ar_html)
+ self.assertIn('letter-spacing: 0;', ar_html)
+ self.assertIn('#1E40AF', ar_html)
+
+ en_html = format_preview_html({
+ "project_name": "Acme Dashboard",
+ "category": "SaaS",
+ "colors": {"primary": "#1E40AF", "on_primary": "#FFFFFF"},
+ })
+ self.assertIn('', en_html)
+ self.assertNotIn('dir="rtl">', en_html)
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/src/ui-ux-pro-max/scripts/core.py b/src/ui-ux-pro-max/scripts/core.py
index 02a3eee..7509333 100755
--- a/src/ui-ux-pro-max/scripts/core.py
+++ b/src/ui-ux-pro-max/scripts/core.py
@@ -271,8 +271,40 @@ _SYNONYMS = {
"organisation": "organization",
"behaviour": "behavior",
"ux/ui": "ux ui",
+ # Arabic & MENA bilingual domain/style/product synonyms
+ "تداول": "trading crypto fintech",
+ "مالية": "fintech finance banking",
+ "مالي": "fintech finance banking",
+ "بنك": "banking fintech finance",
+ "مصرف": "banking fintech finance",
+ "ذكاء اصطناعي": "ai artificial intelligence",
+ "عيادة": "healthcare medical clinic",
+ "طبي": "healthcare medical clinic",
+ "طبية": "healthcare medical clinic",
+ "مستشفى": "healthcare hospital medical",
+ "متجر": "ecommerce store shopping",
+ "تجارة إلكترونية": "ecommerce shopping retail",
+ "لوحة تحكم": "dashboard analytics saas",
+ "تحليلات": "analytics dashboard data",
+ "عقارات": "real estate property",
+ "تعليم": "education learning course",
+ "أكاديمية": "education learning academy",
+ "تدريب": "education learning training",
+ "فندق": "hotel hospitality booking",
+ "سياحة": "travel hospitality booking",
+ "مطعم": "restaurant food delivery",
+ "أمن سيبراني": "cybersecurity security",
+ "ألعاب": "gaming game",
+ "معرض أعمال": "portfolio agency creative",
+ "داكن": "dark mode",
+ "مظلم": "dark mode",
+ "زجاجي": "glassmorphism glass",
+ "بسيط": "minimalism clean",
}
+# Arabic-scoped diacritics (harakat/tashkeel) and tatweel; no-op on non-Arabic text.
+_ARABIC_DIACRITICS_RE = re.compile(r"[\u0617-\u061A\u064B-\u0652\u0640]")
+
_SYNONYM_PATTERNS = [
(re.compile(r"(? str:
"""Render a dependency-free HTML page for the generated design system."""
project = design_system.get("project_name") or "Design system"
+ # Detect RTL preview via explicit direction/lang metadata or Arabic script in project_name.
+ is_arabic = bool(
+ design_system.get("direction") == "rtl"
+ or design_system.get("lang") == "ar"
+ or re.search(r"[\u0600-\u06FF]", str(project))
+ )
+ html_lang = "ar" if is_arabic else "en"
+ html_dir = ' dir="rtl"' if is_arabic else ""
+ eyebrow_spacing = "0" if is_arabic else "0.08em"
+ eyebrow_transform = "none" if is_arabic else "uppercase"
+ badge_spacing = "0" if is_arabic else "0.04em"
category = design_system.get("category") or ""
style = design_system.get("style") or {}
colors = design_system.get("colors") or {}
@@ -168,15 +179,17 @@ def format_preview_html(design_system: dict) -> str:
)
ratio_html = (
f'vs {_text(pair_label)} '
- f'{_text(pair_hex)}: {_text(_format_ratio(ratio))} '
- f'{_text(level)}
'
+ f'{_text(pair_hex)}: '
+ f'{_text(_format_ratio(ratio))} '
+ f'{_text(level)}'
)
swatches.append(
f''
f''
f''
)
@@ -207,7 +220,7 @@ def format_preview_html(design_system: dict) -> str:
anti_html = "".join(anti_items)
return f"""
-
+
@@ -245,8 +258,8 @@ def format_preview_html(design_system: dict) -> str:
}}
.eyebrow {{
margin: 0 0 0.35rem;
- text-transform: uppercase;
- letter-spacing: 0.08em;
+ text-transform: {eyebrow_transform};
+ letter-spacing: {eyebrow_spacing};
font-size: 0.75rem;
color: {muted_fg};
}}
@@ -255,6 +268,9 @@ def format_preview_html(design_system: dict) -> str:
line-height: 1.2;
margin: 0 0 0.5rem;
}}
+ html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3, html[dir="rtl"] .specimen-heading {{
+ letter-spacing: 0;
+ }}
h1 {{ font-size: 2.25rem; }}
h2 {{ font-size: 1.5rem; }}
h3 {{ font-size: 1.2rem; }}
@@ -292,12 +308,12 @@ def format_preview_html(design_system: dict) -> str:
code {{ font-size: 0.85em; }}
.badge {{
display: inline-block;
- margin-left: 0.35rem;
+ margin-inline-start: 0.35rem;
padding: 0.05rem 0.4rem;
border-radius: 999px;
font-size: 0.75rem;
font-weight: 700;
- letter-spacing: 0.04em;
+ letter-spacing: {badge_spacing};
}}
.badge-aaa {{ background: {primary}; color: {on_primary}; }}
.badge-aa {{ background: {muted}; color: {muted_fg}; }}
diff --git a/src/ui-ux-pro-max/scripts/tests/fixtures/relevance-thresholds.json b/src/ui-ux-pro-max/scripts/tests/fixtures/relevance-thresholds.json
index 008ebb4..10ce849 100644
--- a/src/ui-ux-pro-max/scripts/tests/fixtures/relevance-thresholds.json
+++ b/src/ui-ux-pro-max/scripts/tests/fixtures/relevance-thresholds.json
@@ -2,7 +2,7 @@
"schemaVersion": 1,
"status": "provisional-baseline-regression-gate",
"baselineRevision": "97eb2a2",
- "runtimeFingerprint": "e074c9b35d8385e2fb8ce6ba42ac1f9d225c93a982c1dbfc55da9b18a3f1ac73",
+ "runtimeFingerprint": "6f50331454236ff817a9617fdabbf8393309276e3b98e0005c0e007ccc933dbd",
"oracleFingerprint": "02e7226428c64a995ec24ae104ce4d186f5f91bf0f062556e90ef9b0fcb6d67a",
"approvingMaintainer": "repository maintainer approved Phase 1 testing checkpoint; second judgment review remains required before final-target promotion",
"units": "All metrics are ratios in [0,1]. Precision treats missing ranks as non-relevant. Negative abstention is measured across the hard-negative by domain/stack cross-product.",
diff --git a/src/ui-ux-pro-max/scripts/tests/test_rtl_support.py b/src/ui-ux-pro-max/scripts/tests/test_rtl_support.py
index d013af8..09f1347 100644
--- a/src/ui-ux-pro-max/scripts/tests/test_rtl_support.py
+++ b/src/ui-ux-pro-max/scripts/tests/test_rtl_support.py
@@ -162,5 +162,40 @@ class RtlCliTest(unittest.TestCase):
self.assertIn("product", completed.stderr)
+class ArabicSynonymsAndRtlPreviewTest(unittest.TestCase):
+ def test_arabic_diacritics_and_tatweel_stripped_in_normalize(self):
+ from core import _normalize
+ norm = _normalize("مَـتْـجَـر ذَكَاء اصْطِنَاعِي دَاكِن")
+ self.assertIn("ecommerce", norm)
+ self.assertIn("artificial intelligence", norm)
+ self.assertIn("dark mode", norm)
+
+ def test_arabic_query_resolves_domain_and_style(self):
+ res_product = search("عيادة طبية", "product", 3)
+ self.assertGreater(res_product["count"], 0)
+ res_style = search("زجاجي داكن", "style", 3)
+ self.assertGreater(res_style["count"], 0)
+
+ def test_preview_html_arabic_rtl_and_ltr_scoping(self):
+ from preview import format_preview_html
+ ar_html = format_preview_html({
+ "project_name": "منصة التداول الذكي",
+ "category": "Fintech",
+ "colors": {"primary": "#1E40AF", "on_primary": "#FFFFFF"},
+ })
+ self.assertIn('', ar_html)
+ self.assertIn('html[dir="rtl"] h1, html[dir="rtl"] h2', ar_html)
+ self.assertIn('letter-spacing: 0;', ar_html)
+ self.assertIn('#1E40AF', ar_html)
+
+ en_html = format_preview_html({
+ "project_name": "Acme Dashboard",
+ "category": "SaaS",
+ "colors": {"primary": "#1E40AF", "on_primary": "#FFFFFF"},
+ })
+ self.assertIn('', en_html)
+ self.assertNotIn('dir="rtl">', en_html)
+
+
if __name__ == "__main__":
unittest.main()