Skip to content

Commit 94f1c45

Browse files
authored
Merge pull request #1336 from phil-opp/ZAAFHachemrachid/main
Add Arabic translation
2 parents 0a9024f + 7095876 commit 94f1c45

File tree

4 files changed

+172
-1
lines changed

4 files changed

+172
-1
lines changed

blog/config.toml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ skip_anchor_prefixes = [
3434
subtitle = "Philipp Oppermann's blog"
3535
author = { name = "Philipp Oppermann" }
3636
default_language = "en"
37-
languages = ["en", "zh-CN", "zh-TW", "fr", "ja", "fa", "ru", "ko"]
37+
languages = ["en", "zh-CN", "zh-TW", "fr", "ja", "fa", "ru", "ko", "ar"]
3838

3939
[translations]
4040
lang_name = "English (original)"
@@ -231,3 +231,26 @@ support_me = """
231231
comment_note = """
232232
Do you have a problem, want to share feedback, or discuss further ideas? Feel free to leave a comment here! Please stick to English and follow Rust's <a href="https://www.rust-lang.org/policies/code-of-conduct">code of conduct</a>. This comment thread directly maps to a <a href="_discussion_url_"><em>discussion on GitHub</em></a>, so you can also comment there if you prefer.
233233
"""
234+
235+
[languages.ar]
236+
title = "Writing an OS in Rust"
237+
[languages.ar.translations]
238+
lang_name = "Arabic"
239+
toc = "Table of Contents"
240+
all_posts = "« All Posts"
241+
comments = "Comments"
242+
comments_notice = "Please leave your comments in English if possible."
243+
readmore = "read&nbsp;more&nbsp;»"
244+
not_translated = "(This post is not translated yet.)"
245+
translated_content = "Translated Content:"
246+
translated_content_notice = "This is a community translation of the <strong><a href=\"_original.permalink_\">_original.title_</a></strong> post. It might be incomplete, outdated or contain errors. Please report any issues!"
247+
translated_by = "Translation by"
248+
translation_contributors = "With contributions from"
249+
word_separator = "and"
250+
support_me = """
251+
<h2>Support Me</h2>
252+
<p>Creating and maintaining this blog and the associated libraries is a lot of work, but I really enjoy doing it. By supporting me, you allow me to invest more time in new content, new features, and continuous maintenance. The best way to support me is to <a href="https://github.com/sponsors/phil-opp"><em>sponsor me on GitHub</em></a>. Thank you!</p>
253+
"""
254+
comment_note = """
255+
Do you have a problem, want to share feedback, or discuss further ideas? Feel free to leave a comment here! Please stick to English and follow Rust's <a href="https://www.rust-lang.org/policies/code-of-conduct">code of conduct</a>. This comment thread directly maps to a <a href="_discussion_url_"><em>discussion on GitHub</em></a>, so you can also comment there if you prefer.
256+
"""

blog/content/_index.ar.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
+++
2+
template = "edition-2/index.html"
3+
+++
4+
5+
6+
<h1 style="visibility: hidden; height: 0px; margin: 0px; padding: 0px;">كتابة نظام تشغيل بلغة Rust </h1>
7+
<div class="front-page-introduction">
8+
9+
تنشئ سلسلة المدونات هذه نظام تشغيل صغير بلغة البرمجة [Rust ](https://www.rust-lang.org/). كل منشور هو عبارة عن برنامج تعليمي صغير ويتضمن كل الشيفرة المطلوبة، لذا يمكنك المتابعة إذا أردت. الكود المصدري متاح أيضًا في مستودع [Github ](https://github.com/phil-opp/blog_os) المقابل.
10+
11+
آخر منشور: <!-- latest-post -->
12+
</div>
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
+++
2+
title = "A Freestanding Rust Binary"
3+
weight = 1
4+
path = "ar/freestanding-rust-binary"
5+
date = 2018-02-10
6+
7+
[extra]
8+
# Please update this when updating the translation
9+
translation_based_on_commit = "087a464ed77361cff6c459fb42fc655cb9eacbea"
10+
# GitHub usernames of the people that translated this post
11+
translators = ["ZAAFHachemrachid"]
12+
+++
13+
14+
تتمثل الخطوة الأولى في إنشاء نواة نظام التشغيل الخاصة بنا في إنشاء ملف Rust قابل للتنفيذ لا يربط المكتبة القياسية. هذا يجعل من الممكن تشغيل شيفرة Rust على [bare metal] دون نظام تشغيل أساسي.
15+
16+
[bare metal]: https://en.wikipedia.org/wiki/Bare_machine
17+
<!-- more -->
18+
19+
تم تطوير هذه المدونة بشكل مفتوح على [GitHub]. إذا كان لديك أي مشاكل أو أسئلة، يرجى فتح مشكلة هناك. يمكنك أيضًا ترك تعليقات [في الأسفل]. يمكن العثور على الشيفرة المصدرية الكاملة لهذا المنشور في فرع [post-01][post branch].
20+
21+
22+
[GitHub]: https://github.com/phil-opp/blog_os
23+
[at the bottom]: #comments
24+
<!-- fix for zola anchor checker (target is in template): <a id="comments"> -->
25+
[post branch]: https://github.com/phil-opp/blog_os/tree/post-01
26+
<!-- toc -->
27+
28+
29+
## مقدمة
30+
لكتابة نواة نظام تشغيل، نحتاج إلى شيفرة لا تعتمد على أي ميزات نظام تشغيل. هذا يعني أنه لا يمكننا استخدام سلاسل الرسائل(threads) أو الملفات(File System) أو Heap ram أو الشبكة أو الأرقام العشوائية أو الإخراج القياسي(I/O) أو أي ميزات أخرى تتطلب تجريدات نظام التشغيل أو أجهزة معينة. وهذا منطقي، لأننا نحاول كتابة نظام التشغيل الخاص بنا (OS) وبرامج التشغيل الخاصة بنا (drivers).
31+
32+
هذا يعني أنه لا يمكننا استخدام معظم [Rust standard library]، ولكن هناك الكثير من ميزات Rust التي _يمكننا استخدامها. على سبيل المثال، يمكننا استخدام [iterators] و [closures] و [pattern matching] و [option] و [اresult] و [string formatting] وبالطبع [ownership system]. هذه الميزات تجعل من الممكن كتابة نواة بطريقة معبرة جدًا وعالية المستوى دون القلق بشأن [undefined behavior] أو [memory safety].
33+
34+
35+
[option]: https://doc.rust-lang.org/core/option/
36+
[result]:https://doc.rust-lang.org/core/result/
37+
[Rust standard library]: https://doc.rust-lang.org/std/
38+
[iterators]: https://doc.rust-lang.org/book/ch13-02-iterators.html
39+
[closures]: https://doc.rust-lang.org/book/ch13-01-closures.html
40+
[pattern matching]: https://doc.rust-lang.org/book/ch06-00-enums.html
41+
[string formatting]: https://doc.rust-lang.org/core/macro.write.html
42+
[ownership system]: https://doc.rust-lang.org/book/ch04-00-understanding-ownership.html
43+
[undefined behavior]: https://www.nayuki.io/page/undefined-behavior-in-c-and-cplusplus-programs
44+
[memory safety]: https://tonyarcieri.com/it-s-time-for-a-memory-safety-intervention
45+
46+
47+
من أجل إنشاء نواة نظام تشغيل في Rust، نحتاج إلى إنشاء ملف قابل للتنفيذ يمكن تشغيله بدون نظام تشغيل أساسي. غالبًا ما يُطلق على هذا الملف القابل للتنفيذ اسم الملف القابل للتنفيذ ”القائم بذاته“ أو ”المعدني العاري“.
48+
49+
يصف هذا المنشور الخطوات اللازمة لإنشاء ثنائي Rust قائم بذاته ويشرح سبب الحاجة إلى هذه الخطوات. إذا كنت مهتمًا بمثال بسيط فقط، يمكنك **[الانتقال إلى الملخص] (#ملخص)**.
50+
51+
52+
53+
## تعطيل المكتبة القياسية
54+
بشكل افتراضي، تربط جميع صناديق Rust [standard library]، والتي تعتمد على نظام التشغيل لميزات (مثل threads, files, or networking). كما أنها تعتمد أيضًا على مكتبة C القياسية 'libc'، والتي تتفاعل بشكل وثيق مع خدمات نظام التشغيل. نظرًا لأن خطتنا هي كتابة نظام تشغيل، لا يمكننا استخدام أي مكتبات تعتمد على نظام التشغيل. لذا يجب علينا تعطيل التضمين التلقائي للمكتبة القياسية من خلال سمة [no_std].
55+
56+
57+
[standard library]: https://doc.rust-lang.org/std/
58+
[`no_std` attribute]: https://doc.rust-lang.org/1.30.0/book/first-edition/using-rust-without-the-standard-library.html
59+
60+
```
61+
cargo new blog_os --bin --edition 2018
62+
```
63+
64+
لقد أطلقتُ على المشروع اسم ”Blog_os“، ولكن بالطبع يمكنك اختيار اسمك الخاص. تُحدّد علامة ”bin“ أننا نريد إنشاء نسخة binary قابلة للتنفيذ (على عكس المكتبة) وتحدّد علامة ”--- Edition 2018“ أننا نريد استخدام [2018 edition] من Rust لصندوقنا. عندما نُشغّل الأمر، تُنشئ لنا الشحنة بنية الدليل التالية:
65+
66+
[2018 edition]: https://doc.rust-lang.org/nightly/edition-guide/rust-2018/index.html
67+
68+
```
69+
blog_os
70+
├── Cargo.toml
71+
└── src
72+
└── main.rs
73+
```
74+
يحتوي ملف 'Cargo.toml' على تكوين الصندوق، على سبيل المثال اسم الصندوق، والمؤلف، ورقم [semantic version]، والتبعيات. يحتوي الملف 'src/main.rs' على الوحدة النمطية الجذرية للصندوق والدالة 'الرئيسية'. يمكنك تجميع قفصك من خلال 'cargo build' ثم تشغيل الملف الثنائي 'blog_os' المجمّع في المجلد الفرعي 'target/debug'.
75+
76+
[semantic version]: https://semver.org/
77+
78+
### السمة 'no_std'
79+
80+
يربط صندوقنا الآن المكتبة القياسية ضمنيًا بالمكتبة القياسية. دعونا نحاول تعطيل ذلك بإضافة سمة [no_std]:
81+
82+
83+
```rust
84+
// main.rs
85+
86+
#![no_std]
87+
88+
fn main() {
89+
println!("Hello, world!");
90+
}
91+
```
92+
93+
عندما نحاول بناءه الآن (عن طريق تشغيل ”cargo build“)، يحدث الخطأ التالي:
94+
95+
```
96+
error: cannot find macro `println!` in this scope
97+
--> src/main.rs:4:5
98+
|
99+
4 | println!("Hello, world!");
100+
| ^^^^^^^
101+
```
102+
103+
والسبب في هذا الخطأ هو أن [`println` macro] هو جزء من المكتبة القياسية، والتي لم نعد نضمّنها. لذا لم يعد بإمكاننا طباعة الأشياء. هذا أمر منطقي، لأن 'println' يكتب إلى [standard output]، وهو واصف ملف خاص يوفره نظام التشغيل.
104+
105+
106+
[`println` macro]: https://doc.rust-lang.org/std/macro.println.html
107+
[standard output]: https://en.wikipedia.org/wiki/Standard_streams#Standard_output_.28stdout.29
108+
109+
لذا دعنا نحذف الطباعة ونحاول مرة أخرى بدالة رئيسية فارغة:
110+
111+
```rust
112+
// main.rs
113+
114+
#![no_std]
115+
116+
fn main() {}
117+
```
118+
119+
```
120+
> cargo build
121+
error: `#[panic_handler]` function required, but not found
122+
error: language item required, but not found: `eh_personality`
123+
```
124+
125+
126+
يفتقد بناء المترجمات البرمجية الآن إلى `#[panic_handler]` دالة و _language item_.
127+
128+
129+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
+++
2+
title = "Posts"
3+
sort_by = "weight"
4+
insert_anchor_links = "left"
5+
render = false
6+
page_template = "edition-2/page.html"
7+
+++

0 commit comments

Comments
 (0)