Skip to content

Commit 4bcb88b

Browse files
committed
Translate "Modifying the document" page in french language
1 parent b1f87b3 commit 4bcb88b

File tree

21 files changed

+220
-220
lines changed

21 files changed

+220
-220
lines changed

2-ui/1-document/07-modifying-document/1-createtextnode-vs-innerhtml/solution.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Answer: **1 and 3**.
1+
Réponse : **1 et 3**.
22

3-
Both commands result in adding the `text` "as text" into the `elem`.
3+
Les deux commandes ont pour résultat d'ajouter le `texte` "en tant que texte" dans `elem`.
44

5-
Here's an example:
5+
Voici un exemple :
66

77
```html run height=80
88
<div id="elem1"></div>

2-ui/1-document/07-modifying-document/1-createtextnode-vs-innerhtml/task.md

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

55
# createTextNode vs innerHTML vs textContent
66

7-
We have an empty DOM element `elem` and a string `text`.
7+
Nous avons un élément DOM vide `elem` et une chaîne de caractères `text`.
88

9-
Which of these 3 commands do exactly the same?
9+
Lesquelles de ces 3 commandes font exactement la même chose ?
1010

1111
1. `elem.append(document.createTextNode(text))`
1212
2. `elem.innerHTML = text`

2-ui/1-document/07-modifying-document/10-clock-setinterval/solution.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
First, let's make HTML/CSS.
1+
Tout d'abord, créons notre HTML/CSS.
22

3-
Each component of the time would look great in its own `<span>`:
3+
Chaque composante du temps aurait fière allure dans son propre `<span>` :
44

55
```html
66
<div id="clock">
77
<span class="hour">hh</span>:<span class="min">mm</span>:<span class="sec">ss</span>
88
</div>
99
```
1010

11-
Also we'll need CSS to color them.
11+
Nous aurons également besoin de CSS pour les colorer.
1212

13-
The `update` function will refresh the clock, to be called by `setInterval` every second:
13+
La fonction `update` rafraîchira l'horloge, qui sera appelée par `setInterval` toutes les secondes :
1414

1515
```js
1616
function update() {
@@ -32,14 +32,14 @@ function update() {
3232
}
3333
```
3434

35-
In the line `(*)` we every time check the current date. The calls to `setInterval` are not reliable: they may happen with delays.
35+
Dans la ligne `(*)` nous vérifions à chaque fois la date actuelle. Les appels à `setInterval` ne sont pas fiables : ils peuvent survenir avec des retards.
3636

37-
The clock-managing functions:
37+
Les fonctions de gestion d'horloge :
3838

3939
```js
4040
let timerId;
4141

42-
function clockStart() { // run the clock
42+
function clockStart() { // exécute l'horloge
4343
timerId = setInterval(update, 1000);
4444
update(); // (*)
4545
}
@@ -50,4 +50,4 @@ function clockStop() {
5050
}
5151
```
5252

53-
Please note that the call to `update()` is not only scheduled in `clockStart()`, but immediately run in the line `(*)`. Otherwise the visitor would have to wait till the first execution of `setInterval`. And the clock would be empty till then.
53+
Veuillez noter que l'appel à `update()` est non seulement planifié dans `clockStart()`, mais s'exécute immédiatement dans la ligne `(*)`. Sinon, le visiteur devra attendre la première exécution de `setInterval`. Et l'horloge serait vide jusque-là.

2-ui/1-document/07-modifying-document/10-clock-setinterval/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ importance: 4
22

33
---
44

5-
# Colored clock with setInterval
5+
# Horloge colorée avec setInterval
66

7-
Create a colored clock like here:
7+
Créez une horloge colorée comme ici :
88

99
[iframe src="solution" height=60]
1010

11-
Use HTML/CSS for the styling, JavaScript only updates time in elements.
11+
Utilisez HTML/CSS pour le style, JavaScript ne met à jour que le temps dans les éléments.

2-ui/1-document/07-modifying-document/11-append-to-list/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
When we need to insert a piece of HTML somewhere, `insertAdjacentHTML` is the best fit.
2+
Lorsque nous devons insérer un morceau de HTML quelque part, `insertAdjacentHTML` est le meilleur choix.
33

4-
The solution:
4+
La solution :
55

66
```js
77
one.insertAdjacentHTML('afterend', '<li>2</li><li>3</li>');

2-ui/1-document/07-modifying-document/11-append-to-list/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-
# Insert the HTML in the list
5+
# Insérez le HTML dans la liste
66

7-
Write the code to insert `<li>2</li><li>3</li>` between two `<li>` here:
7+
Écrivez le code pour insérer `<li>2</li><li>3</li>` entre deux `<li>` ici :
88

99
```html
1010
<ul id="ul">
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The solution is short, yet may look a bit tricky, so here I provide it with extensive comments:
1+
La solution est courte, mais peut sembler un peu délicate, alors ici je la présente avec de nombreux commentaires :
22

33
```js
44
let sortedRows = Array.from(table.tBodies[0].rows) // 1
@@ -7,12 +7,12 @@ let sortedRows = Array.from(table.tBodies[0].rows) // 1
77
table.tBodies[0].append(...sortedRows); // (3)
88
```
99

10-
The step-by-step algorthm:
10+
L'algorithme pas à pas :
1111

12-
1. Get all `<tr>`, from `<tbody>`.
13-
2. Then sort them comparing by the content of the first `<td>` (the name field).
14-
3. Now insert nodes in the right order by `.append(...sortedRows)`.
12+
1. Obtenez tous les `<tr>` de `<tbody>`.
13+
2. Triez-les ensuite en les comparant au contenu du premier `<td>` (le champ du nom).
14+
3. Insérez maintenant les nœuds dans le bon ordre par `.append(...sortedRows)`.
1515

16-
We don't have to remove row elements, just "re-insert", they leave the old place automatically.
16+
Nous n'avons pas à supprimer les éléments de ligne, il suffit de les "réinsérer", ils quittent automatiquement l'ancien emplacement.
1717

18-
P.S. In our case, there's an explicit `<tbody>` in the table, but even if HTML table doesn't have `<tbody>`, the DOM structure always has it.
18+
P.S. Dans notre cas, il y a un `<tbody>` explicite dans le tableau, mais même si le tableau HTML n'a pas de `<tbody>`, la structure DOM l'a toujours.

2-ui/1-document/07-modifying-document/12-sort-table/task.md

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

33
---
44

5-
# Sort the table
5+
# Trier le tableau
66

7-
There's a table:
7+
Il y a un tableau :
88

99
```html run
1010
<table>
@@ -30,6 +30,6 @@ There's a table:
3030
</table>
3131
```
3232

33-
There may be more rows in it.
33+
Il peut y avoir plus de lignes.
3434

35-
Write the code to sort it by the `"name"` column.
35+
Écrivez le code pour le trier par la colonne `"name"`.

2-ui/1-document/07-modifying-document/4-clear-elem/solution.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
First, let's see how *not* to do it:
2+
Voyons d'abord comment ne *pas* le faire :
33

44
```js
55
function clear(elem) {
@@ -9,11 +9,11 @@ function clear(elem) {
99
}
1010
```
1111

12-
That won't work, because the call to `remove()` shifts the collection `elem.childNodes`, so elements start from the index `0` every time. But `i` increases, and some elements will be skipped.
12+
Cela ne fonctionnera pas, car l'appel à `remove()` décale la collection `elem.childNodes`, donc les éléments commencent à partir de l'index `0` à chaque fois. Mais `i` augmente et certains éléments seront ignorés.
1313

14-
The `for..of` loop also does the same.
14+
La boucle `for..of` fait de même.
1515

16-
The right variant could be:
16+
La bonne variante pourrait être :
1717

1818
```js
1919
function clear(elem) {
@@ -23,7 +23,7 @@ function clear(elem) {
2323
}
2424
```
2525

26-
And also there's a simpler way to do the same:
26+
Et il existe également un moyen plus simple de faire de même :
2727

2828
```js
2929
function clear(elem) {

2-ui/1-document/07-modifying-document/4-clear-elem/task.md

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

33
---
44

5-
# Clear the element
5+
# Effacer l'élément
66

7-
Create a function `clear(elem)` that removes everything from the element.
7+
Créez une fonction `clear(elem)` qui supprime tout de l'élément.
88

99
```html run height=60
1010
<ol id="elem">
@@ -13,8 +13,8 @@ Create a function `clear(elem)` that removes everything from the element.
1313
</ol>
1414

1515
<script>
16-
function clear(elem) { /* your code */ }
16+
function clear(elem) { /* votre code */ }
1717
18-
clear(elem); // clears the list
18+
clear(elem); // efface la liste
1919
</script>
2020
```
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
The HTML in the task is incorrect. That's the reason of the odd thing.
1+
Le code HTML de cette tâche est incorrect. Voilà la raison de la chose étrange.
22

3-
The browser has to fix it automatically. But there may be no text inside the `<table>`: according to the spec only table-specific tags are allowed. So the browser adds `"aaa"` *before* the `<table>`.
3+
Le navigateur doit le réparer automatiquement. Mais il peut ne pas y avoir de texte à l'intérieur de la `<table>` : selon la spécification, seules les balises spécifiques à la table sont autorisées. Le navigateur ajoute donc `"aaa"` *avant* la `<table>`.
44

5-
Now it's obvious that when we remove the table, it remains.
5+
Maintenant, il est évident que lorsque nous retirons la `table`, la chaîne de caractères reste.
66

7-
The question can be easily answered by exploring the DOM using the browser tools. It shows `"aaa"` before the `<table>`.
7+
La question peut être facilement répondue en explorant le DOM à l'aide des outils du navigateur. Il montre `"aaa"` avant la `<table>`.
88

9-
The HTML standard specifies in detail how to process bad HTML, and such behavior of the browser is correct.
9+
Le standard HTML spécifie en détail comment traiter un mauvais HTML, et un tel comportement du navigateur est correct.

2-ui/1-document/07-modifying-document/5-why-aaa/task.md

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

33
---
44

5-
# Why does "aaa" remain?
5+
# Pourquoi "aaa" reste-t-il ?
66

7-
In the example below, the call `table.remove()` removes the table from the document.
7+
Dans l'exemple ci-dessous, l'appel `table.remove()` supprime le tableau du document.
88

9-
But if you run it, you can see that the text `"aaa"` is still visible.
9+
mais si vous l'exécutez, vous pouvez voir que le texte `"aaa"` est toujours visible.
1010

11-
Why does that happen?
11+
Pourquoi cela se produit-il ?
1212

1313
```html height=100 run
1414
<table id="table">
@@ -19,9 +19,9 @@ Why does that happen?
1919
</table>
2020

2121
<script>
22-
alert(table); // the table, as it should be
22+
alert(table); // la table, comme il se doit
2323
2424
table.remove();
25-
// why there's still aaa in the document?
25+
// pourquoi y a-t-il encore aaa dans le document ?
2626
</script>
2727
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Please note the usage of `textContent` to assign the `<li>` content.
1+
Veuillez noter l'utilisation de `textContent` pour attribuer le contenu `<li>`.

2-ui/1-document/07-modifying-document/6-create-list/task.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ importance: 4
22

33
---
44

5-
# Create a list
5+
# Créer une liste
66

7-
Write an interface to create a list from user input.
7+
Écrivez une interface pour créer une liste à partir des entrées utilisateur.
88

9-
For every list item:
9+
Pour chaque élément de la liste :
1010

11-
1. Ask a user about its content using `prompt`.
12-
2. Create the `<li>` with it and add it to `<ul>`.
13-
3. Continue until the user cancels the input (by pressing `key:Esc` or CANCEL in prompt).
11+
1. Interrogez un utilisateur sur son contenu en utilisant `prompt`.
12+
2. Créez le `<li>` avec et ajoutez-le à `<ul>`.
13+
3. Continuez jusqu'à ce que l'utilisateur annule l'entrée (en appuyant sur la touche `key:Esc` ou CANCEL dans le prompt).
1414

15-
All elements should be created dynamically.
15+
Tous les éléments doivent être créés dynamiquement.
1616

17-
If a user types HTML-tags, they should be treated like a text.
17+
Si un utilisateur tape des balises HTML, elles doivent être traitées comme un texte.
1818

1919
[demo src="solution"]
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The easiest way to walk the object is to use recursion.
1+
La façon la plus simple de parcourir l'objet est d'utiliser la récursivité.
22

3-
1. [The solution with innerHTML](sandbox:innerhtml).
4-
2. [The solution with DOM](sandbox:build-tree-dom).
3+
1. [La solution avec innerHTML](https://plnkr.co/edit/PzjPAk9yKHeKkT36?p=preview).
4+
2. [La solution avec DOM](https://plnkr.co/edit/e3TEVqQrm7ZqZkn6?p=preview).

2-ui/1-document/07-modifying-document/7-create-object-tree/task.md

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

33
---
44

5-
# Create a tree from the object
5+
# Créer un arbre à partir de l'objet
66

7-
Write a function `createTree` that creates a nested `ul/li` list from the nested object.
7+
Écrivez une fonction `createTree` qui crée une liste imbriquée `ul/li` à partir de l'objet imbriqué.
88

9-
For instance:
9+
Par exemple :
1010

1111
```js
1212
let data = {
@@ -28,24 +28,24 @@ let data = {
2828
};
2929
```
3030

31-
The syntax:
31+
La syntaxe :
3232

3333
```js
3434
let container = document.getElementById('container');
3535
*!*
36-
createTree(container, data); // creates the tree in the container
36+
createTree(container, data); // crée l'arbre dans le conteneur
3737
*/!*
3838
```
3939

40-
The result (tree) should look like this:
40+
Le résultat (arbre) devrait ressembler à ceci :
4141

4242
[iframe border=1 src="build-tree-dom"]
4343

44-
Choose one of two ways of solving this task:
44+
Choisissez l'une des deux façons de résoudre cette tâche :
4545

46-
1. Create the HTML for the tree and then assign to `container.innerHTML`.
47-
2. Create tree nodes and append with DOM methods.
46+
1. Créez le code HTML de l'arborescence, puis attribuez-le à `container.innerHTML`.
47+
2. Créez des nœuds d'arbre et ajoutez-les avec les méthodes DOM.
4848

49-
Would be great if you could do both.
49+
Ce serait génial si vous pouviez faire les deux.
5050

51-
P.S. The tree should not have "extra" elements like empty `<ul></ul>` for the leaves.
51+
P.S. L'arbre ne doit pas avoir d'éléments "supplémentaires" comme des `<ul></ul>` vides pour les feuilles (de l'arbre).
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
To append text to each `<li>` we can alter the text node `data`.
1+
Pour ajouter du texte à chaque `<li>`, nous pouvons modifier le nœud texte `data`.

2-ui/1-document/07-modifying-document/8-tree-count/task.md

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

33
---
44

5-
# Show descendants in a tree
5+
# Afficher les descendants dans un arbre
66

7-
There's a tree organized as nested `ul/li`.
7+
Il y a un arbre organisé comme un `ul/li` imbriqué.
88

9-
Write the code that adds to each `<li>` the number of its descendants. Skip leaves (nodes without children).
9+
Écrivez le code qui ajoute à chaque `<li>` le nombre de ses descendants. Sautez les feuilles (nœuds sans enfants).
1010

11-
The result:
11+
Le resultat :
1212

1313
[iframe border=1 src="solution"]
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
We'll create the table as a string: `"<table>...</table>"`, and then assign it to `innerHTML`.
1+
Nous allons créer le tableau sous forme de chaîne de caractères : `"<table>...</table>"`, puis l'affecter à `innerHTML`.
22

3-
The algorithm:
3+
L'algorithme :
44

5-
1. Create the table header with `<th>` and weekday names.
6-
2. Create the date object `d = new Date(year, month-1)`. That's the first day of `month` (taking into account that months in JavaScript start from `0`, not `1`).
7-
3. First few cells till the first day of the month `d.getDay()` may be empty. Let's fill them in with `<td></td>`.
8-
4. Increase the day in `d`: `d.setDate(d.getDate()+1)`. If `d.getMonth()` is not yet the next month, then add the new cell `<td>` to the calendar. If that's a Sunday, then add a newline <code>"&lt;/tr&gt;&lt;tr&gt;"</code>.
9-
5. If the month has finished, but the table row is not yet full, add empty `<td>` into it, to make it square.
5+
1. Créer l'en-tête du tableau avec les noms `<th>` et les jours de la semaine.
6+
2. Créez l'objet de date `d = new Date(year, month-1)`. C'est le premier jour de `month` (en tenant compte du fait que les mois en JavaScript commencent à `0`, pas à `1`).
7+
3. Les premières cellules jusqu'au premier jour du mois `d.getDay()` peuvent être vides. Remplissons-les avec `<td></td>`.
8+
4. Augmentez le jour en `d`: `d.setDate(d.getDate()+1)`. Si `d.getMonth()` n'est pas encore le mois suivant, alors ajoutez la nouvelle cellule `<td>` au calendrier. Si c'est un dimanche, ajoutez une nouvelle ligne <code>"&lt;/tr&gt;&lt;tr&gt;"</code>.
9+
5. Si le mois est terminé, mais que la ligne du tableau n'est pas encore pleine, ajoutez-y un `<td>` vide pour le rendre carré.

2-ui/1-document/07-modifying-document/9-calendar-table/task.md

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

33
---
44

5-
# Create a calendar
5+
# Créer un calendrier
66

7-
Write a function `createCalendar(elem, year, month)`.
7+
Écrivez une fonction `createCalendar(elem, year, month)`.
88

9-
The call should create a calendar for the given year/month and put it inside `elem`.
9+
L'appel doit créer un calendrier pour l'année/le mois donné et le mettre dans `elem`.
1010

11-
The calendar should be a table, where a week is `<tr>`, and a day is `<td>`. The table top should be `<th>` with weekday names: the first day should be Monday, and so on till Sunday.
11+
Le calendrier doit être un tableau, où une semaine est un `<tr>` et un jour est un `<td>`. Le dessus du tableau doit être un `<th>` avec les noms des jours de la semaine : le premier jour doit être le lundi, et ainsi de suite jusqu'au dimanche.
1212

13-
For instance, `createCalendar(cal, 2012, 9)` should generate in element `cal` the following calendar:
13+
Par exemple, `createCalendar(cal, 2012, 9)` devrait générer dans l'élément `cal` le calendrier suivant :
1414

1515
[iframe height=210 src="solution"]
1616

17-
P.S. For this task it's enough to generate the calendar, should not yet be clickable.
17+
P.S. Pour cette tâche, il suffit de générer le calendrier, il ne doit pas encore être cliquable.

0 commit comments

Comments
 (0)