Skip to content

Commit 75eb88f

Browse files
committed
translate conditional rendering
1 parent a695ec5 commit 75eb88f

File tree

2 files changed

+37
-38
lines changed

2 files changed

+37
-38
lines changed

glossary.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@
6060
| modifier | مُعدِّل |
6161
| tick | نبضة |
6262
| unwrap | فك |
63+
| lazy | خامل |

src/guide/essentials/conditional.md

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Conditional Rendering {#conditional-rendering}
1+
# التصيير الشرطي {#conditional-rendering}
22

33
<div class="options-api">
44
<VueSchoolLink href="https://vueschool.io/lessons/conditional-rendering-in-vue-3" title="Free Vue.js Conditional Rendering Lesson"/>
@@ -15,103 +15,101 @@ const awesome = ref(true)
1515

1616
## `v-if` {#v-if}
1717

18-
The directive `v-if` is used to conditionally render a block. The block will only be rendered if the directive's expression returns a truthy value.
18+
السمة الموجهة `v-if` تستخدم لتصيير شرطي لكتلة من الشيفرة. سيتم تصيير الكتلة فقط إذا كان تعبير السمة الموجهة يعيد قيمة صحيحة.
1919

2020
```vue-html
21-
<h1 v-if="awesome">Vue is awesome!</h1>
21+
<h1 v-if="awesome">Vue رائعة!</h1>
2222
```
2323

2424
## `v-else` {#v-else}
2525

26-
You can use the `v-else` directive to indicate an "else block" for `v-if`:
26+
تستطيع استخدام السمة الموجهة `v-else` لتحديد "كتلة else" لـ `v-if`:
2727

2828
```vue-html
29-
<button @click="awesome = !awesome">Toggle</button>
29+
<button @click="awesome = !awesome">تبديل</button>
3030
31-
<h1 v-if="awesome">Vue is awesome!</h1>
32-
<h1 v-else>Oh no 😢</h1>
31+
<h1 v-if="awesome">Vue رائعة!</h1>
32+
<h1 v-else>أوه لا 😢</h1>
3333
```
3434

3535
<div class="demo">
36-
<button @click="awesome = !awesome">Toggle</button>
37-
<h1 v-if="awesome">Vue is awesome!</h1>
38-
<h1 v-else>Oh no 😢</h1>
36+
<button @click="awesome = !awesome">تبديل</button>
37+
<h1 v-if="awesome">Vue رائعة!</h1>
38+
<h1 v-else>أوه لا 😢</h1>
3939
</div>
4040

4141
<div class="composition-api">
4242

43-
[Try it in the Playground](https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHNjcmlwdCBzZXR1cD5cbmltcG9ydCB7IHJlZiB9IGZyb20gJ3Z1ZSdcblxuY29uc3QgYXdlc29tZSA9IHJlZih0cnVlKVxuPC9zY3JpcHQ+XG5cbjx0ZW1wbGF0ZT5cbiAgPGJ1dHRvbiBAY2xpY2s9XCJhd2Vzb21lID0gIWF3ZXNvbWVcIj50b2dnbGU8L2J1dHRvbj5cblxuXHQ8aDEgdi1pZj1cImF3ZXNvbWVcIj5WdWUgaXMgYXdlc29tZSE8L2gxPlxuXHQ8aDEgdi1lbHNlPk9oIG5vIPCfmKI8L2gxPlxuPC90ZW1wbGF0ZT4iLCJpbXBvcnQtbWFwLmpzb24iOiJ7XG4gIFwiaW1wb3J0c1wiOiB7XG4gICAgXCJ2dWVcIjogXCJodHRwczovL3NmYy52dWVqcy5vcmcvdnVlLnJ1bnRpbWUuZXNtLWJyb3dzZXIuanNcIlxuICB9XG59In0=)
43+
[اختبرها في حقل التجارب](https://sfc.vuejs.org/#eNp9kE1OwzAQha8y9aYgNbG6rdIKLsHKmzZMaEr8o7GTLqLsKoE4ATskkCiwQSy5iXMLjoDTFIpAYjfz/N5n+9Xs1Ji4KpFNWGJTyo0Di640M6FyaTQ5qIEwgwYy0hKGwToUSqhUK+tgvkarJcK08xw5KvFYqIT3oIAIi0NpirnDsCWL0jmt4CQt8vRyKtghPtiPgs38i3/yr+1Nu0l4H+hByzFUUZ4dYsF7ViL4N7/1j/7dPw8Svhx39+ysWFic+Yf2ur2CduO38HF3e//l4N/PYiPWfzSScxOvrFahilooALE/sIJNYKd0Wiig2wVbOmfshHObpV2BKxtruuBhiqlULpcYo5XRgvTaIgWwYKMfDB7ECikiVOdISP8xf1n/cDtsI1TDmk8rYa1q)
4444

4545
</div>
4646
<div class="options-api">
4747

48-
[Try it in the Playground](https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHNjcmlwdD5cbmV4cG9ydCBkZWZhdWx0IHtcbiAgZGF0YSgpIHtcbiAgXHRyZXR1cm4ge1xuXHQgICAgYXdlc29tZTogdHJ1ZVxuICBcdH1cblx0fVxufVxuPC9zY3JpcHQ+XG5cbjx0ZW1wbGF0ZT5cbiAgPGJ1dHRvbiBAY2xpY2s9XCJhd2Vzb21lID0gIWF3ZXNvbWVcIj50b2dnbGU8L2J1dHRvbj5cblxuXHQ8aDEgdi1pZj1cImF3ZXNvbWVcIj5WdWUgaXMgYXdlc29tZSE8L2gxPlxuXHQ8aDEgdi1lbHNlPk9oIG5vIPCfmKI8L2gxPlxuPC90ZW1wbGF0ZT4iLCJpbXBvcnQtbWFwLmpzb24iOiJ7XG4gIFwiaW1wb3J0c1wiOiB7XG4gICAgXCJ2dWVcIjogXCJodHRwczovL3NmYy52dWVqcy5vcmcvdnVlLnJ1bnRpbWUuZXNtLWJyb3dzZXIuanNcIlxuICB9XG59In0=)
48+
[اختبرها في حقل التجارب](https://sfc.vuejs.org/#eNp9kNFKwzAUhl/lLFcKa8NuSzf0JbzKTded2c42DclJJ4zdDRSfwDtBwak34qVvkr6Fj2BCyxwKhhDOn/Ofj+TfsHOl4tYiS1hqcl0qmgmJ16rRBAtcZrYi2AgJsMgoOznta0EayWoZlCDwK1ujaWpMgLTF3rINPX/4nfID2gvCWlUZoVcA6dwSNRLO8qrMr6aCDSSYwmgoBZu5N/fi3ru7bpfyfqAfLibQRuXyZ8x7LyyC+3B79+w+3eso5cXkyIyVwZl76m67G+h2bg9fD/ePgyflh6exMSvrEEJUZypemUb6gPq/Dw0jWNKnEe58gkELVhApk3BulnmIdWXiRl9yX8XaSiprjNHU0Vw3a4PagwUbHzG4v2xRRxrlAjXq/5i/rH+4ARviZ9tvaiizdw==)
4949

5050
</div>
5151

52-
A `v-else` element must immediately follow a `v-if` or a `v-else-if` element - otherwise it will not be recognized.
53-
52+
السمة `v-else` يجب أن تتبعها السمة الموجهة `v-if` أو السمة الموجهة `v-else-if` - وإلا فلن يتم التعرف عليها.
5453
## `v-else-if` {#v-else-if}
55-
56-
The `v-else-if`, as the name suggests, serves as an "else if block" for `v-if`. It can also be chained multiple times:
54+
الموجهة `v-else-if`، كما يشير الاسم، تعمل ككتلة "else if" لـ `v-if`. يمكن استخدامها أيضًا بشكل متسلسل عدة مرات:
5755

5856
```vue-html
5957
<div v-if="type === 'A'">
60-
A
58+
أ
6159
</div>
6260
<div v-else-if="type === 'B'">
63-
B
61+
ب
6462
</div>
6563
<div v-else-if="type === 'C'">
66-
C
64+
ج
6765
</div>
6866
<div v-else>
69-
Not A/B/C
67+
غير ذلك...
7068
</div>
7169
```
7270

7371
Similar to `v-else`, a `v-else-if` element must immediately follow a `v-if` or a `v-else-if` element.
7472

75-
## `v-if` on `<template>` {#v-if-on-template}
73+
## `v-if` على `<template>` {#v-if-on-template}
7674

7775
Because `v-if` is a directive, it has to be attached to a single element. But what if we want to toggle more than one element? In this case we can use `v-if` on a `<template>` element, which serves as an invisible wrapper. The final rendered result will not include the `<template>` element.
7876

7977
```vue-html
8078
<template v-if="ok">
81-
<h1>Title</h1>
82-
<p>Paragraph 1</p>
83-
<p>Paragraph 2</p>
79+
<h1>العنوان</h1>
80+
<p>الفقرة 1</p>
81+
<p>الفقرة 2</p>
8482
</template>
8583
```
8684

87-
`v-else` and `v-else-if` can also be used on `<template>`.
85+
`v-else` و `v-else-if` يمكن استخدامها أيضًا على `<template>`.
8886

8987
## `v-show` {#v-show}
9088

91-
Another option for conditionally displaying an element is the `v-show` directive. The usage is largely the same:
89+
خيار آخر لعرض العنصر بشكل شرطي هو السمة `v-show`. الاستخدام مثل `v-if` هو نفسه إلى حد كبير:
9290

9391
```vue-html
94-
<h1 v-show="ok">Hello!</h1>
92+
<h1 v-show="ok">السلام عليكم</h1>
9593
```
9694

97-
The difference is that an element with `v-show` will always be rendered and remain in the DOM; `v-show` only toggles the `display` CSS property of the element.
95+
الفرق هو أن العنصر مع `v-show` سيُصيَّر دائمًا و يبقى موجودا في DOM؛ `v-show` يقوم فقط بتبديل خاصية `display` في الـCSS للعنصر.
9896

99-
`v-show` doesn't support the `<template>` element, nor does it work with `v-else`.
97+
`v-show` لا تدعم العنصر `<template>`، ولا يعمل أيضا مع `v-else`.
10098

101-
## `v-if` vs. `v-show` {#v-if-vs-v-show}
99+
## `v-if` مقابل `v-show` {#v-if-vs-v-show}
102100

103-
`v-if` is "real" conditional rendering because it ensures that event listeners and child components inside the conditional block are properly destroyed and re-created during toggles.
101+
`v-if` هو تصيير شرطي "حقيقي" لأنه يضمن أن مستمعي الأحداث والمكونات الفرعية داخل الكتلة الشرطية تُدمر وتُعاد إنشاؤها بشكل صحيح أثناء التبديلات.
104102

105-
`v-if` is also **lazy**: if the condition is false on initial render, it will not do anything - the conditional block won't be rendered until the condition becomes true for the first time.
103+
`v-if` هي أيضا سمة "خاملة": إذا كان الشرط غير مستوفى (false) عند التصيير الأولي، فلن تقوم بأي شيء - لن يتم تصيير الكتلة الشرطية حتى يصبح الشرط مستوفى (true) للمرة الأولى.
106104

107-
In comparison, `v-show` is much simpler - the element is always rendered regardless of initial condition, with CSS-based toggling.
105+
بالمقارنة ، `v-show` تعتبر أبسط - يتم دائمًا تصيير العنصر بغض النظر عن الشرط الأولي، بالاستناد على التبديل المبني على CSS.
108106

109-
Generally speaking, `v-if` has higher toggle costs while `v-show` has higher initial render costs. So prefer `v-show` if you need to toggle something very often, and prefer `v-if` if the condition is unlikely to change at runtime.
107+
بشكل عام، `v-if` لديها تكاليف تبديل أعلى بينما `v-show` لديها تكاليف تصيير أولية أعلى. لذلك، استخدم `v-show` إذا كنت بحاجة إلى التبديل على عنصر معين بشكل متكرر جدًا، و `v-if` إذا كان الشرط غير مرجح أن يتغير في وقت التشغيل.
110108

111-
## `v-if` with `v-for` {#v-if-with-v-for}
109+
## `v-if` مع `v-for` {#v-if-with-v-for}
112110

113-
::: warning Note
114-
It's **not** recommended to use `v-if` and `v-for` on the same element due to implicit precedence. Refer to [style guide](/style-guide/rules-essential.html#avoid-v-if-with-v-for) for details.
111+
::: warning ملاحظة
112+
**لا** يُوصى باستخدام `v-if` و `v-for` على نفس العنصر بسبب الأولوية الضمنية لـ`v-if`. اطلع على [دليل الأسلوب](/style-guide/rules-essential.html#avoid-v-if-with-v-for) للحصول على التفاصيل.
115113
:::
116114

117-
When `v-if` and `v-for` are both used on the same element, `v-if` will be evaluated first. See the [list rendering guide](list#v-for-with-v-if) for details.
115+
عندما تكون `v-if` و `v-for` مستخدمتان على نفس العنصر، ستُقيَّم `v-if` أولا. اطلع على [دليل تصيير القوائم](list#v-for-with-v-if) للحصول على التفاصيل.

0 commit comments

Comments
 (0)