Skip to content

Commit 7a77f54

Browse files
authored
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
1 parent 03ccac2 commit 7a77f54

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

quartz/components/renderPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ export function renderPage(
231231
)
232232

233233
const lang = componentData.fileData.frontmatter?.lang ?? cfg.locale?.split("-")[0] ?? "en"
234+
const direction = i18n(cfg.locale).direction ?? "ltr"
234235
const doc = (
235-
<html lang={lang}>
236+
<html lang={lang} dir={direction}>
236237
<Head {...componentData} />
237238
<body data-slug={slug}>
238239
<div id="quartz-root" class="page">

quartz/i18n/locales/ar-SA.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default {
55
title: "غير معنون",
66
description: "لم يتم تقديم أي وصف",
77
},
8+
direction: "rtl" as const,
89
components: {
910
callout: {
1011
note: "ملاحظة",

quartz/i18n/locales/definition.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface Translation {
2121
title: string
2222
description: string
2323
}
24+
direction?: "ltr" | "rtl"
2425
components: {
2526
callout: CalloutTranslation
2627
backlinks: {

quartz/i18n/locales/fa-IR.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default {
55
title: "بدون عنوان",
66
description: "توضیح خاصی اضافه نشده است",
77
},
8+
direction: "rtl" as const,
89
components: {
910
callout: {
1011
note: "یادداشت",

0 commit comments

Comments
 (0)