Skip to content

Commit 6059cf7

Browse files
committed
Translating managing state
- Sharing State Between Components - Preserving and Resetting State
1 parent c1170f5 commit 6059cf7

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/content/learn/managing-state.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ title: إدارة الحالة
2222

2323
## الاستجابة للمدخلات باستخدام الحالة {/*reacting-to-input-with-state*/}
2424

25-
باستخدام React، لن تستطيع تعديل واجهة المستخدم عن طريق الكود مباشرة. على سبيل المثال، لن تكتب أوامر مثل "عطل الزر"، "فعل الزر"، إلخ. بدلا عن ذلك، سوف تصف واجهة المستخدم التي تريد أن ترها للحالات المرئية من مكوناتك ("حالة ابتدائية"، "حالة كتابية"، "حالة ناجحة")، ومن بعدها تنشيط تغيرات الحالة بناءا على مدخل المستخدم. هذا مشابه لتصور المصممين عن واجهة المستخدم.
25+
باستخدام React، لن تستطيع تعديل واجهة المستخدم عن طريق الكود مباشرة. على سبيل المثال، لن تكتب أوامر مثل "عطل الزر"، "فعل الزر"، "أظهر رسالة النجاح"، إلخ. بدلا عن ذلك، سوف تصف واجهة المستخدم التي تريد أن ترها للحالات المرئية من مكوناتك ("حالة ابتدائية"، "حالة كتابية"، "حالة ناجحة")، ومن بعدها تنشيط تغيرات الحالة بناءا على مدخل المستخدم. هذا مشابه لتصور المصممين عن واجهة المستخدم.
2626

2727
هنا نموذج اختبار صمم باستخدام React. لاحظ كيف يستخدم متغير الحالة `status` لكي يحدد ما إذا سيفعل أم سيعطل زر الإرسال، وما إذا ستظهر رسالة نجاح بدلا عن ذلك.
2828

@@ -157,7 +157,7 @@ export default function Form() {
157157
/>
158158
</label>
159159
<p>
160-
تذكرتك سوف تسلم ل: <b>{fullName}</b>
160+
تذكرتك سوف تسلم لـ: <b>{fullName}</b>
161161
</p>
162162
</>
163163
);
@@ -209,7 +209,7 @@ export default function Form() {
209209
/>
210210
</label>
211211
<p>
212-
تذكرتك سوف تسلم ل: <b>{fullName}</b>
212+
تذكرتك سوف تسلم لـ: <b>{fullName}</b>
213213
</p>
214214
</>
215215
);
@@ -230,11 +230,11 @@ label { display: block; margin-bottom: 5px; }
230230

231231
</LearnMore>
232232

233-
## Sharing state between components {/*sharing-state-between-components*/}
233+
## مشاركة الحالة بين المكونات {/*sharing-state-between-components*/}
234234

235-
Sometimes, you want the state of two components to always change together. To do it, remove state from both of them, move it to their closest common parent, and then pass it down to them via props. This is known as "lifting state up", and it's one of the most common things you will do writing React code.
235+
أحيانا، أنت تريد الحالة ذات المكونين أن تتغير دائما مع بعضها البعض. لعمل ذلك، احذف حالة من كليهما، انقلها لأقرب مكون أب، وبعد ذلك مررها لأسفل باستخدام الخصائص. هذا ما يعرف بـ "رفع الحالة لمستوى أعلى"، وهو واحد من أكثر الأشياء شيوعا التي ستسعملها أثناء كتابتك لكود React.
236236

237-
In this example, only one panel should be active at a time. To achieve this, instead of keeping the active state inside each individual panel, the parent component holds the state and specifies the props for its children.
237+
في هذا المثال، في كل مرة يجب أن تكون قائمة واحدة فقط نشطة. لتحقيق ذلك، بدلا من حفظ الحالة النشطة داخل كل قائمة بمفردها، المكونّ الأب يحمل الحالة ويحدد الخصائص لمكوناته الأبناء.
238238

239239
<Sandpack>
240240

@@ -251,14 +251,14 @@ export default function Accordion() {
251251
isActive={activeIndex === 0}
252252
onShow={() => setActiveIndex(0)}
253253
>
254-
With a population of about 2 million, Almaty is Kazakhstan's largest city. From 1929 to 1997, it was its capital city.
254+
مع تعداد سكاني يقارب 2 مليون، Almaty هي أكبر مدينة بـ Kazakhstan. منذ 1929 إلى 1997 كانت هي العاصمة.
255255
</Panel>
256256
<Panel
257257
title="Etymology"
258258
isActive={activeIndex === 1}
259259
onShow={() => setActiveIndex(1)}
260260
>
261-
The name comes from <span lang="kk-KZ">алма</span>, the Kazakh word for "apple" and is often translated as "full of apples". In fact, the region surrounding Almaty is thought to be the ancestral home of the apple, and the wild <i lang="la">Malus sieversii</i> is considered a likely candidate for the ancestor of the modern domestic apple.
261+
الاسم مأخوذ من <span lang="kk-KZ">алма</span>، الكلمة الكازاخستانية التي تعني "تفاحة" وغالبا تترجم على أنها "مليئة بالتفاح". في الحقيقة، المنطقة المحيطة بـ Almaty تعتبر الموطن الأصلي للتفاحة، والنوع البريّ <i lang="la">Malus sieversii</i> يعتبر أقرب مرشح
262262
</Panel>
263263
</>
264264
);
@@ -277,7 +277,7 @@ function Panel({
277277
<p>{children}</p>
278278
) : (
279279
<button onClick={onShow}>
280-
Show
280+
أظهر
281281
</button>
282282
)}
283283
</section>
@@ -297,15 +297,15 @@ h3, p { margin: 5px 0px; }
297297

298298
<LearnMore path="/learn/sharing-state-between-components">
299299

300-
Read **[Sharing State Between Components](/learn/sharing-state-between-components)** to learn how to lift state up and keep components in sync.
300+
اقرأ **[مشاركة الحالة بين المكونات](/learn/sharing-state-between-components)** لتتعلم كيفية رفع الحالة لمستوى أعلى والحفاظ على المكونّات منسجمة.
301301

302302
</LearnMore>
303303

304-
## Preserving and resetting state {/*preserving-and-resetting-state*/}
304+
## حفظ وإعادة تعيين الحالة {/*preserving-and-resetting-state*/}
305305

306-
When you re-render a component, React needs to decide which parts of the tree to keep (and update), and which parts to discard or re-create from scratch. In most cases, React's automatic behavior works well enough. By default, React preserves the parts of the tree that "match up" with the previously rendered component tree.
306+
عمدما تعيد تصيير مكون، React تحتاج لتقرر أىّ أجزاء من الشجرة لتحفظها (وتحدثها)، وأيّ أجزاء لتلغيها أو تعيد إنشاءها من الصفر. في أغلب الحالات، التصرف التلقائي لـ React يعمل بشكل جيد كفاية. تلقائياـ React تحفظ الأجزاء من الشجرة التي "تتوافق" مع مكون الشجرة المصيير مسبقا.
307307

308-
However, sometimes this is not what you want. In this chat app, typing a message and then switching the recipient does not reset the input. This can make the user accidentally send a message to the wrong person:
308+
على كل حال، أحيانا هذا ما لا تريده أنت. في تطبيق المحادثة هذا، كتابة رسالة وتغيير الطرف المستقبل لا يعيد تعيين المدخل. هذا قد يجعل المستخدم يرسل رسالة بغير قصد للشخص الخطأ.
309309

310310
<Sandpack>
311311

@@ -368,11 +368,11 @@ export default function Chat({ contact }) {
368368
<section className="chat">
369369
<textarea
370370
value={text}
371-
placeholder={'Chat to ' + contact.name}
371+
placeholder={'تحدث مع ' + contact.name}
372372
onChange={e => setText(e.target.value)}
373373
/>
374374
<br />
375-
<button>Send to {contact.email}</button>
375+
<button>أرسل لـ {contact.email}</button>
376376
</section>
377377
);
378378
}
@@ -400,7 +400,7 @@ textarea {
400400

401401
</Sandpack>
402402

403-
React lets you override the default behavior, and *force* a component to reset its state by passing it a different `key`, like `<Chat key={email} />`. This tells React that if the recipient is different, it should be considered a *different* `Chat` component that needs to be re-created from scratch with the new data (and UI like inputs). Now switching between the recipients resets the input field--even though you render the same component.
403+
React تعطيك القدرة على تجاوز السلوك الافتراضي، و*تفرض* على المكون إعادة تعيين حالته عن طريق تمرير `key` مختلف لها، مثل `<Chat key={email} />`. هذا يخبر React أن الطرف المستقبل مختلف، ومن الواجب تعيين مكون `Chat` *مختلف* يكون بحاجة إلى إعادة الإنشاء من الصفر ببايانات جديدة (وواجهة مستخدم مثل المدخلات). الآن الانتقال بين المستقبلين يعيد تعيين حقل الإدخال--حتى بالرغم من أنك تعيد تصيير نفس المكون.
404404

405405
<Sandpack>
406406

@@ -463,11 +463,11 @@ export default function Chat({ contact }) {
463463
<section className="chat">
464464
<textarea
465465
value={text}
466-
placeholder={'Chat to ' + contact.name}
466+
placeholder={'تحدث مع ' + contact.name}
467467
onChange={e => setText(e.target.value)}
468468
/>
469469
<br />
470-
<button>Send to {contact.email}</button>
470+
<button>أرسل لـ {contact.email}</button>
471471
</section>
472472
);
473473
}
@@ -497,7 +497,7 @@ textarea {
497497

498498
<LearnMore path="/learn/preserving-and-resetting-state">
499499

500-
Read **[Preserving and Resetting State](/learn/preserving-and-resetting-state)** to learn the lifetime of state and how to control it.
500+
اقرأ **[حفظ وإعادة تعيين الحالة](/learn/preserving-and-resetting-state)** لتتعلم الحياة الزمنية للحالة وكيفية التحكم بها.
501501

502502
</LearnMore>
503503

0 commit comments

Comments
 (0)