From 7a77f54e50146b05bea62934f417016bbd81b794 Mon Sep 17 00:00:00 2001
From: Amir Pourmand
Date: Thu, 18 Sep 2025 02:34:22 +0330
Subject: [PATCH] fix(i18n): Add RTL Detection based on Config Set Language
(#2100)
* Add rtl automatic detection to base.scss
* Implement RTL support for Arabic and Persian locales and update HTML direction attribute in renderPage component
* Update HTML direction attribute in renderPage component to prioritize frontmatter dir value
* Refactor renderPage component to simplify HTML direction attribute assignment by removing frontmatter dir fallback
---
quartz/components/renderPage.tsx | 3 ++-
quartz/i18n/locales/ar-SA.ts | 1 +
quartz/i18n/locales/definition.ts | 1 +
quartz/i18n/locales/fa-IR.ts | 1 +
4 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/quartz/components/renderPage.tsx b/quartz/components/renderPage.tsx
index e43189dc..3ebfe487 100644
--- a/quartz/components/renderPage.tsx
+++ b/quartz/components/renderPage.tsx
@@ -231,8 +231,9 @@ export function renderPage(
)
const lang = componentData.fileData.frontmatter?.lang ?? cfg.locale?.split("-")[0] ?? "en"
+ const direction = i18n(cfg.locale).direction ?? "ltr"
const doc = (
-
+
diff --git a/quartz/i18n/locales/ar-SA.ts b/quartz/i18n/locales/ar-SA.ts
index a1979def..9c5c8ade 100644
--- a/quartz/i18n/locales/ar-SA.ts
+++ b/quartz/i18n/locales/ar-SA.ts
@@ -5,6 +5,7 @@ export default {
title: "غير معنون",
description: "لم يتم تقديم أي وصف",
},
+ direction: "rtl" as const,
components: {
callout: {
note: "ملاحظة",
diff --git a/quartz/i18n/locales/definition.ts b/quartz/i18n/locales/definition.ts
index ee1649ab..f22538fc 100644
--- a/quartz/i18n/locales/definition.ts
+++ b/quartz/i18n/locales/definition.ts
@@ -21,6 +21,7 @@ export interface Translation {
title: string
description: string
}
+ direction?: "ltr" | "rtl"
components: {
callout: CalloutTranslation
backlinks: {
diff --git a/quartz/i18n/locales/fa-IR.ts b/quartz/i18n/locales/fa-IR.ts
index 0300174f..ccb996fa 100644
--- a/quartz/i18n/locales/fa-IR.ts
+++ b/quartz/i18n/locales/fa-IR.ts
@@ -5,6 +5,7 @@ export default {
title: "بدون عنوان",
description: "توضیح خاصی اضافه نشده است",
},
+ direction: "rtl" as const,
components: {
callout: {
note: "یادداشت",