Back to all postsالعودة إلى كل المقالات
Getting started with a blog in two languagesالبدء بمدونة بلغتين
Publishedنُشر في · ، 2 min read١ د للقراءة
- welcome
- example
- ترحيب
- مثال
This is an example post. It lives in two files, content/posts/getting-started-with-two-languages.en.mdx and content/posts/getting-started-with-two-languages.ar.mdx. You can delete both or rewrite them.
Why two files
A reader sees the post in the language of the page and switches with one button, without a reload. Each language is written as its own text, so a sentence is never a word-for-word copy of the other one. Keep the same ideas and the same headings in the same order, and write each version the way a native reader would say it.
What you can use
Posts are written in MDX, which is plain Markdown with a few extras:
- bold and italic text
- links (opens in a new tab) to other pages
- numbered lists, quotes and code
A quote reads like this, with a coloured bar at the side. In Arabic the bar moves to the other side by itself.
export function add(a: number, b: number): number {
return a + b;
}
Code is always shown left to right, even inside an Arabic post.
Adding a post
Add two files next to these, with the same name and one of the endings .en.mdx and .ar.mdx. Give both the same date, and a title, summary and tags in the language of the file. If one of the two files is missing, the build stops and tells you which one to add.
هذا مقال تجريبي. يتكوّن من ملفين: content/posts/getting-started-with-two-languages.en.mdx وcontent/posts/getting-started-with-two-languages.ar.mdx. يمكنك حذفهما معًا أو إعادة كتابتهما.
لماذا ملفان
يقرأ الزائر المقال بلغة الصفحة، ويبدّل اللغة بزر واحد دون إعادة تحميل. كل لغة تُكتب نصًّا قائمًا بذاته، فلا تكون الجملة ترجمة حرفية للأخرى. احتفظ بالأفكار نفسها وبالعناوين نفسها بالترتيب نفسه، واكتب كل نسخة كما يقولها قارئ هذه اللغة.
ما الذي يمكنك استخدامه
تُكتب المقالات بصيغة MDX، وهي Markdown العادية مع بعض الإضافات:
- نص عريض ونص مائل
- روابط (يفتح في تبويب جديد) إلى صفحات أخرى
- قوائم مرقّمة واقتباسات وشيفرة برمجية
يظهر الاقتباس هكذا، مع شريط ملوّن على جانبه. في العربية ينتقل الشريط إلى الجانب الآخر من تلقاء نفسه.
export function add(a: number, b: number): number {
return a + b;
}
تُعرض الشيفرة دائمًا من اليسار إلى اليمين، حتى داخل مقال عربي.
إضافة مقال
أضف ملفين بجوار هذين، بالاسم نفسه وبأحد الامتدادين .en.mdx و.ar.mdx. اكتب فيهما التاريخ نفسه، وعنوانًا وملخصًا ووسومًا بلغة كل ملف. وإذا نقص أحد الملفين توقّف البناء وأخبرك بالملف الذي تضيفه.