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
This commit is contained in:
@@ -231,8 +231,9 @@ export function renderPage(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const lang = componentData.fileData.frontmatter?.lang ?? cfg.locale?.split("-")[0] ?? "en"
|
const lang = componentData.fileData.frontmatter?.lang ?? cfg.locale?.split("-")[0] ?? "en"
|
||||||
|
const direction = i18n(cfg.locale).direction ?? "ltr"
|
||||||
const doc = (
|
const doc = (
|
||||||
<html lang={lang}>
|
<html lang={lang} dir={direction}>
|
||||||
<Head {...componentData} />
|
<Head {...componentData} />
|
||||||
<body data-slug={slug}>
|
<body data-slug={slug}>
|
||||||
<div id="quartz-root" class="page">
|
<div id="quartz-root" class="page">
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export default {
|
|||||||
title: "غير معنون",
|
title: "غير معنون",
|
||||||
description: "لم يتم تقديم أي وصف",
|
description: "لم يتم تقديم أي وصف",
|
||||||
},
|
},
|
||||||
|
direction: "rtl" as const,
|
||||||
components: {
|
components: {
|
||||||
callout: {
|
callout: {
|
||||||
note: "ملاحظة",
|
note: "ملاحظة",
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export interface Translation {
|
|||||||
title: string
|
title: string
|
||||||
description: string
|
description: string
|
||||||
}
|
}
|
||||||
|
direction?: "ltr" | "rtl"
|
||||||
components: {
|
components: {
|
||||||
callout: CalloutTranslation
|
callout: CalloutTranslation
|
||||||
backlinks: {
|
backlinks: {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export default {
|
|||||||
title: "بدون عنوان",
|
title: "بدون عنوان",
|
||||||
description: "توضیح خاصی اضافه نشده است",
|
description: "توضیح خاصی اضافه نشده است",
|
||||||
},
|
},
|
||||||
|
direction: "rtl" as const,
|
||||||
components: {
|
components: {
|
||||||
callout: {
|
callout: {
|
||||||
note: "یادداشت",
|
note: "یادداشت",
|
||||||
|
|||||||
Reference in New Issue
Block a user