Skip to content

Commit 48656e7

Browse files
committed
Translating Strings to Arabic
1 parent 67d1152 commit 48656e7

8 files changed

Lines changed: 237 additions & 267 deletions

File tree

1-js/05-data-types/03-string/1-ucfirst/solution.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
We can't "replace" the first character, because strings in JavaScript are immutable.
2-
3-
But we can make a new string based on the existing one, with the uppercased first character:
1+
لا يمكننا استبدال الحرف الأول، لأن النصوص في JavaScript غير قابلة للتعديل. لكن، يمكننا إنشاء نص جديد وفقًا للنص الموجود، مع تكبير الحرف الأول:
42

53
```js
64
let newStr = str[0].toUpperCase() + str.slice(1);
75
```
86

9-
There's a small problem though. If `str` is empty, then `str[0]` is `undefined`, and as `undefined` doesn't have the `toUpperCase()` method, we'll get an error.
7+
لكن، يوجد مشكلة صغيرة، وهي إن كان `str` فارغًا، فسيصبح `str[0]` قيمة غير معرفة `undefined`، ولأن `undefined` لا يملك الدالة `toUpperCase()` فسيظهر خطأ.
108

11-
There are two variants here:
9+
يوجد طريقتين بديلتين هنا:
10+
1- استخدام `str.charAt(0)‎`، لأنها تُرجِع نصًا دائمًا (ربما نصًا فارغًا).
11+
2- إضافة اختبار في حال كان النص فارغًا.
1212

13-
1. Use `str.charAt(0)`, as it always returns a string (maybe empty).
14-
2. Add a test for an empty string.
13+
هنا الخيار الثاني:
1514

16-
Here's the 2nd variant:
1715

1816
```js run demo
1917
function ucFirst(str) {

1-js/05-data-types/03-string/1-ucfirst/task.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 5
22

33
---
44

5-
# Uppercase the first character
5+
### حول الحرف الأول إلى حرف كبير
66

7-
Write a function `ucFirst(str)` that returns the string `str` with the uppercased first character, for instance:
7+
اكتب دالة باسم `ucFirst(str)` تُرجِع النص `str` مع تكبير أول حرف فيه، مثلًا:
88

99
```js
1010
ucFirst("john") == "John";

1-js/05-data-types/03-string/2-check-spam/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
To make the search case-insensitive, let's bring the string to lower case and then search:
1+
لجعل البحث غير حساس لحالة الأحرف، نحوِّل النص إلى أحرف صغيرة ومن ثم نبحث فيه على النص المطلوب:
22

33
```js run demo
44
function checkSpam(str) {

1-js/05-data-types/03-string/2-check-spam/task.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ importance: 5
22

33
---
44

5-
# Check for spam
5+
### فحص وجود شيء مزعج
66

7-
Write a function `checkSpam(str)` that returns `true` if `str` contains 'viagra' or 'XXX', otherwise `false`.
8-
9-
The function must be case-insensitive:
7+
اكتب دالة باسم `checkSpam(str)‎` تُرجِع `true` إن كان `str` يحوي 'viagra' أو 'XXX'، وإلا فتُرجِع `false`. يجب أن لا تكون الدالة حساسة لحالة الأحرف:
108

119
```js
1210
checkSpam('buy ViAgRA now') == true

1-js/05-data-types/03-string/3-truncate/solution.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
The maximal length must be `maxlength`, so we need to cut it a little shorter, to give space for the ellipsis.
2-
3-
Note that there is actually a single unicode character for an ellipsis. That's not three dots.
1+
الطول الكلي هو `maxlength`، لذا فإننا نحتاج لقص النص إلى أقصر من ذلك بقليل لإعطاء مساحة للنقط `"…"`. لاحظ أن هناك حرف يونيكود واحد للحرف `"…"`. وليست ثلاث نقاط.
42

53
```js run demo
64
function truncate(str, maxlength) {

1-js/05-data-types/03-string/3-truncate/task.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ importance: 5
22

33
---
44

5-
# Truncate the text
5+
### قص النص
66

7-
Create a function `truncate(str, maxlength)` that checks the length of the `str` and, if it exceeds `maxlength` -- replaces the end of `str` with the ellipsis character `"…"`, to make its length equal to `maxlength`.
8-
9-
The result of the function should be the truncated (if needed) string.
10-
11-
For instance:
7+
انشئ دالة باسم `truncate(str, maxlength)‎` تفحص طول النص `str` وتستبدل نهايته التي تتجاوز الحد `maxlength` بالرمز `"…"` لجعل طولها يساوي `maxlength` بالضبط. يجب أن تكون مخرجات الدالة النص المقصوص (في حال حدث ذلك). مثلًا:
128

139
```js
1410
truncate("What I'd like to tell on this topic is:", 20) = "What I'd like to te…"

1-js/05-data-types/03-string/4-extract-currency/task.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ importance: 4
22

33
---
44

5-
# Extract the money
5+
### استخراج المال
66

7-
We have a cost in the form `"$120"`. That is: the dollar sign goes first, and then the number.
8-
9-
Create a function `extractCurrencyValue(str)` that would extract the numeric value from such string and return it.
10-
11-
The example:
7+
لدينا قيمة بالشكل `"‎ $120"`، إذ علامة الدولار تأتي أولًا ومن ثم العدد. أنشِئ دالة باسم `extractCurrencyValue(str)‎ ` تستخرج القيمة العددية من نصوص مشابهة وإرجاعها. مثال:
128

139
```js
1410
alert( extractCurrencyValue('$120') === 120 ); // true

0 commit comments

Comments
 (0)