From 5981a226cf9510f678dca35de6f1bc135681b860 Mon Sep 17 00:00:00 2001 From: Olivier Lacan Date: Sat, 19 May 2018 02:59:53 -0400 Subject: [PATCH 1/3] French translation by Olivier Lacun --- README.md | 3 +- collector.rb | 1 + ...015-01-01-try-ruby-version-4.html.markdown | 2 +- translations/fr/README.md | 21 ++++++ translations/fr/try_ruby_10.md | 26 ++++++++ translations/fr/try_ruby_100.md | 18 ++++++ translations/fr/try_ruby_110.md | 24 +++++++ translations/fr/try_ruby_120.md | 21 ++++++ translations/fr/try_ruby_130.md | 13 ++++ translations/fr/try_ruby_140.md | 14 ++++ translations/fr/try_ruby_150.md | 12 ++++ translations/fr/try_ruby_160.md | 27 ++++++++ translations/fr/try_ruby_170.md | 37 +++++++++++ translations/fr/try_ruby_180.md | 34 ++++++++++ translations/fr/try_ruby_190.md | 17 +++++ translations/fr/try_ruby_20.md | 19 ++++++ translations/fr/try_ruby_200.md | 12 ++++ translations/fr/try_ruby_210.md | 17 +++++ translations/fr/try_ruby_220.md | 21 ++++++ translations/fr/try_ruby_230.md | 30 +++++++++ translations/fr/try_ruby_240.md | 27 ++++++++ translations/fr/try_ruby_250.md | 28 ++++++++ translations/fr/try_ruby_260.md | 20 ++++++ translations/fr/try_ruby_270.md | 19 ++++++ translations/fr/try_ruby_280.md | 27 ++++++++ translations/fr/try_ruby_290.md | 18 ++++++ translations/fr/try_ruby_30.md | 13 ++++ translations/fr/try_ruby_300.md | 23 +++++++ translations/fr/try_ruby_310.md | 24 +++++++ translations/fr/try_ruby_320.md | 38 +++++++++++ translations/fr/try_ruby_330.md | 33 ++++++++++ translations/fr/try_ruby_340.md | 24 +++++++ translations/fr/try_ruby_350.md | 12 ++++ translations/fr/try_ruby_360.md | 29 +++++++++ translations/fr/try_ruby_370.md | 27 ++++++++ translations/fr/try_ruby_380.md | 33 ++++++++++ translations/fr/try_ruby_390.md | 53 +++++++++++++++ translations/fr/try_ruby_40.md | 27 ++++++++ translations/fr/try_ruby_400.md | 41 ++++++++++++ translations/fr/try_ruby_410.md | 40 ++++++++++++ translations/fr/try_ruby_420.md | 36 +++++++++++ translations/fr/try_ruby_430.md | 34 ++++++++++ translations/fr/try_ruby_440.md | 31 +++++++++ translations/fr/try_ruby_450.md | 33 ++++++++++ translations/fr/try_ruby_460.md | 33 ++++++++++ translations/fr/try_ruby_470.md | 20 ++++++ translations/fr/try_ruby_480.md | 25 ++++++++ translations/fr/try_ruby_490.md | 15 +++++ translations/fr/try_ruby_50.md | 13 ++++ translations/fr/try_ruby_500.md | 31 +++++++++ translations/fr/try_ruby_510.md | 28 ++++++++ translations/fr/try_ruby_520.md | 27 ++++++++ translations/fr/try_ruby_530.md | 46 +++++++++++++ translations/fr/try_ruby_540.md | 24 +++++++ translations/fr/try_ruby_550.md | 64 +++++++++++++++++++ translations/fr/try_ruby_560.md | 31 +++++++++ translations/fr/try_ruby_60.md | 16 +++++ translations/fr/try_ruby_70.md | 13 ++++ translations/fr/try_ruby_80.md | 17 +++++ translations/fr/try_ruby_90.md | 30 +++++++++ 60 files changed, 1490 insertions(+), 2 deletions(-) create mode 100644 translations/fr/README.md create mode 100644 translations/fr/try_ruby_10.md create mode 100644 translations/fr/try_ruby_100.md create mode 100644 translations/fr/try_ruby_110.md create mode 100644 translations/fr/try_ruby_120.md create mode 100644 translations/fr/try_ruby_130.md create mode 100644 translations/fr/try_ruby_140.md create mode 100644 translations/fr/try_ruby_150.md create mode 100644 translations/fr/try_ruby_160.md create mode 100644 translations/fr/try_ruby_170.md create mode 100644 translations/fr/try_ruby_180.md create mode 100644 translations/fr/try_ruby_190.md create mode 100644 translations/fr/try_ruby_20.md create mode 100644 translations/fr/try_ruby_200.md create mode 100644 translations/fr/try_ruby_210.md create mode 100644 translations/fr/try_ruby_220.md create mode 100644 translations/fr/try_ruby_230.md create mode 100644 translations/fr/try_ruby_240.md create mode 100644 translations/fr/try_ruby_250.md create mode 100644 translations/fr/try_ruby_260.md create mode 100644 translations/fr/try_ruby_270.md create mode 100644 translations/fr/try_ruby_280.md create mode 100644 translations/fr/try_ruby_290.md create mode 100644 translations/fr/try_ruby_30.md create mode 100644 translations/fr/try_ruby_300.md create mode 100644 translations/fr/try_ruby_310.md create mode 100644 translations/fr/try_ruby_320.md create mode 100644 translations/fr/try_ruby_330.md create mode 100644 translations/fr/try_ruby_340.md create mode 100644 translations/fr/try_ruby_350.md create mode 100644 translations/fr/try_ruby_360.md create mode 100644 translations/fr/try_ruby_370.md create mode 100644 translations/fr/try_ruby_380.md create mode 100644 translations/fr/try_ruby_390.md create mode 100644 translations/fr/try_ruby_40.md create mode 100644 translations/fr/try_ruby_400.md create mode 100644 translations/fr/try_ruby_410.md create mode 100644 translations/fr/try_ruby_420.md create mode 100644 translations/fr/try_ruby_430.md create mode 100644 translations/fr/try_ruby_440.md create mode 100644 translations/fr/try_ruby_450.md create mode 100644 translations/fr/try_ruby_460.md create mode 100644 translations/fr/try_ruby_470.md create mode 100644 translations/fr/try_ruby_480.md create mode 100644 translations/fr/try_ruby_490.md create mode 100644 translations/fr/try_ruby_50.md create mode 100644 translations/fr/try_ruby_500.md create mode 100644 translations/fr/try_ruby_510.md create mode 100644 translations/fr/try_ruby_520.md create mode 100644 translations/fr/try_ruby_530.md create mode 100644 translations/fr/try_ruby_540.md create mode 100644 translations/fr/try_ruby_550.md create mode 100644 translations/fr/try_ruby_560.md create mode 100644 translations/fr/try_ruby_60.md create mode 100644 translations/fr/try_ruby_70.md create mode 100644 translations/fr/try_ruby_80.md create mode 100644 translations/fr/try_ruby_90.md diff --git a/README.md b/README.md index aa3ba570..e68eaccf 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Ukrainian translation by [_Andrii Palchik_](https://github.com/andriipalchik) Macedonian translation by [_Violeta Pavleska_](https://github.com/violeta-p) Chinese translation by [_Ye Junzhe_](https://github.com/McF4r) & [_Bitfox_](https://github.com/bitfoxtop) & [_Heng Li_](https://github.com/iheng) Turkish translation by [_Ali Rıza Şahin_](https://github.com/ARS-coding) +French translation by _Olivier Lacan_ Suggestions to improve translations are welcome. If you submit a pull request updating a translation please @@ -77,7 +78,7 @@ for more background information on how and why this website was created. ## The MIT License -Copyright (C) 2014-2019 Ivo Herweijer +Copyright (C) 2014-2024 Ivo Herweijer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/collector.rb b/collector.rb index 564cb617..8902ed98 100644 --- a/collector.rb +++ b/collector.rb @@ -158,6 +158,7 @@ def initialize(app, options_hash={}, &block) Collector.new('translations/zh/try_ruby_*.md', 'source/try_ruby_zh.json').collect Collector.new('translations/de/try_ruby_*.md', 'source/try_ruby_de.json').collect Collector.new('translations/tr/try_ruby_*.md', 'source/try_ruby_tr.json').collect + Collector.new('translations/fr/try_ruby_*.md', 'source/try_ruby_fr.json').collect # TODO: add any new translations here true diff --git a/source/articles/2015-01-01-try-ruby-version-4.html.markdown b/source/articles/2015-01-01-try-ruby-version-4.html.markdown index 07c8df95..14bda143 100644 --- a/source/articles/2015-01-01-try-ruby-version-4.html.markdown +++ b/source/articles/2015-01-01-try-ruby-version-4.html.markdown @@ -38,7 +38,7 @@ I had to make some alterations to the TryRuby lesson content. Also updated some - Removed mousehole stuff - Improved the feedback given to the user based on the program's output a bit - Added support for lesson content in multiple languages. The Spanish, Brazilian Portuguese, - Japanese, Russian, Ukrainian, Macedonian and Dutch translations are available. + Japanese, Russian, Ukrainian, Macedonian, Dutch, Turkish and French translations are available. __If YOU would like to add a translation to TryRuby you are most welcome !__ - Added explanation of if/else statements - Changed the subject of the "Class" tutorials from building a blog (so last decade) to making an diff --git a/translations/fr/README.md b/translations/fr/README.md new file mode 100644 index 00000000..697db85e --- /dev/null +++ b/translations/fr/README.md @@ -0,0 +1,21 @@ +## Copyright (C) +Try Ruby version 4 French translation, 2018, _Olivier Lacan_ + +## The MIT License +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/translations/fr/try_ruby_10.md b/translations/fr/try_ruby_10.md new file mode 100644 index 00000000..131aac34 --- /dev/null +++ b/translations/fr/try_ruby_10.md @@ -0,0 +1,26 @@ +--- +lang: FR +title: 30 minutes de libre ? Essaie Ruby ! +answer: +class: stretcher chapmark +ok: +error: +--- + +Ruby est un language de programmation originaire du Japon et qui a +revolutionné le développement logiciel. + +La beauté de Ruby se situe dans sa balance entre simplicité et puissance. + +Tu peux saisir du code Ruby dans l'éditeur et utiliser les boutons suivants pour naviguer : + +- __Run__ → Execute le code dans l'éditeur +- __Copy__ → Copie l'example de code dans l'éditeur +- __Next__ → Vous permet de sauter à la leçon suivante +- __Back__ → Vous permet de revenir à la leçon précédente +- __Clear__ → Remets l'éditeur à zéro + +Utilise le bouton « planête » +ci-dessus pour changer le language de TryRuby. + +### Clique sur __Next__ pour commencer à apprendre. diff --git a/translations/fr/try_ruby_100.md b/translations/fr/try_ruby_100.md new file mode 100644 index 00000000..447be28a --- /dev/null +++ b/translations/fr/try_ruby_100.md @@ -0,0 +1,18 @@ +--- +lang: FR +title: Stop, t'es barge ! +answer: ^\d{1,}$ +ok: Seuls les strings peuvent être inversés +error: +--- + +On ne peut pas inverser le nombre quarante. J'imagine que tu +pourrais tenir ton moniteur en face d'un mirroir, mais inverser un +nombre n'est pas franchement très logique. + +Ruby a lancé un message d'erreur. Ruby t'explique qu'il n'y a pas de +méthode pour inverser des nombres. + +Tu pourrais peut-être transformer ce nombre en string pour commencer : + + 40.to_s.reverse diff --git a/translations/fr/try_ruby_110.md b/translations/fr/try_ruby_110.md new file mode 100644 index 00000000..a967a384 --- /dev/null +++ b/translations/fr/try_ruby_110.md @@ -0,0 +1,24 @@ +--- +lang: FR +title: Les garçons sont différents des filles +answer: \[\] +ok: Bon, d'accord, voilà une liste vide. +error: +--- + +Et les nombres sont différents des strings. + +Bien qu'il soit possible d'utiliser des méthodes sur n'importe quel +objet avec Ruby, certaines méthodes ne fonctionnent qu'avec certains +types de choses. Mais il est toujours possible de passer d'un type à un +autre avec les méthodes "to" to Ruby. + +- __to_s__ convertit les choses en __s__trings +- __to_i__ convertit les choses en __i__ntegers (nombres entiers) +- __to_a__ convertit les choses en __a__rrays + +__Qu'est-ce qu'un array ?!__ + +C'est une liste. Saisis une paire de crochets : + + [] diff --git a/translations/fr/try_ruby_120.md b/translations/fr/try_ruby_120.md new file mode 100644 index 00000000..8dff828d --- /dev/null +++ b/translations/fr/try_ruby_120.md @@ -0,0 +1,21 @@ +--- +lang: FR +title: Faire la queue +answer: ^\[(\d+)(,\s*\d+){3,}\]$ +ok: Excellent +error: Essaye d'ajouter un quatrième nombre à la liste +--- + +Les listes (arrays) stockent des choses __dans un ordre défini__. + +C'est un peu comme faire la queue pour acheter une baguette. Tu es +derrière quelqu'un et ce sera impensable de les pousser pour passer +devant, non? Et le mec derrière toi, tu gardes un œil sur lui, juste au +cas où ? + +Voilà une liste pour toi. Des numéros de lotterie : + + [12, 47, 35] + +Essaie d'ajouter un nombre à cette liste: saisis une virgule après 35 +suivie d'un nombre. L'espace est facultatif. diff --git a/translations/fr/try_ruby_130.md b/translations/fr/try_ruby_130.md new file mode 100644 index 00000000..859e1daa --- /dev/null +++ b/translations/fr/try_ruby_130.md @@ -0,0 +1,13 @@ +--- +lang: FR +title: Un d'entre eux lève la main +answer: ^47$ +ok: D'accord +error: +--- + +Une liste de numéros de lotterie. Lequel est le plus grand ? + +Essaye: + + [12, 47, 35].max diff --git a/translations/fr/try_ruby_140.md b/translations/fr/try_ruby_140.md new file mode 100644 index 00000000..148aab45 --- /dev/null +++ b/translations/fr/try_ruby_140.md @@ -0,0 +1,14 @@ +--- +lang: FR +title: Ranger une liste proprement +answer: ^\[(\d+)(,\s*\d+){2,}\]$ +ok: Sauvegardé ! +error: +--- + +Bien, bien. Cela dit c'est ennuyant d'avoir à retaper cette liste chaque +fois que tu en as besoin, non ? + +Sauvegardons nos numéros dans un ticket comme ça : + + ticket = [12, 47, 35] diff --git a/translations/fr/try_ruby_150.md b/translations/fr/try_ruby_150.md new file mode 100644 index 00000000..2ab986f9 --- /dev/null +++ b/translations/fr/try_ruby_150.md @@ -0,0 +1,12 @@ +--- +lang: FR +title: Maintenant entre ticket +answer: \[(\d+(, )?){2,}\] +load: ticket = [12, 47, 35] +ok: Réstoré! +error: +--- + +Maintenant, saisi: + + ticket diff --git a/translations/fr/try_ruby_160.md b/translations/fr/try_ruby_160.md new file mode 100644 index 00000000..b90af4b4 --- /dev/null +++ b/translations/fr/try_ruby_160.md @@ -0,0 +1,27 @@ +--- +lang: FR +title: Sauvegardé, rangé proprement +answer: \[12, 35, 47\] +load: ticket = [12, 47, 35] +ok: Tu as organisé la liste en ordre +error: +--- + +Tu as gardé tes numéro de lotto en les rangeant dans une __variable__ +nommée ticket. Mais n'importe quel autre nom, comme _lalistedejimmy_, +aurait aussi fait l'affaire. + +Comme tu découvriras, la programmation c'est surtout jongler avec des +variables. + +Mettons les numéros de lotto dans l'ordre. + +Utilise: + + ticket.sort! + +Tu avais une liste. Tu as organisé la liste dans l'ordre. La variable +ticket a maintenant changé Est-ce que tu as remarqué que la méthode +_sort!_ a un gros point d'exclamation à la fin ? Souvent les méthodes +Ruby crient comme ça lorsqu'elle modifient une variable pour de bon. +C'est rien de grave, juste une ponctuation. diff --git a/translations/fr/try_ruby_170.md b/translations/fr/try_ruby_170.md new file mode 100644 index 00000000..38d62934 --- /dev/null +++ b/translations/fr/try_ruby_170.md @@ -0,0 +1,37 @@ +--- +lang: FR +title: Élementaire +answer: ^(12|35|47)$ +load: ticket = [12, 47, 35] +ok: D'accord +error: Presque +--- + +Donc nous avons stocké nos numéros de loterie dans la variable ticket. +Comment faire pour les retrouver ? + +On a déjà vu qu'il est possible d'obtenir le numéro le plus élevé avec __max__. +On peut également obtenir le premier (__first__) ou le dernier (__last__) +élement de la liste. +Mais que faire si on a besoin d'un élement specifique de la liste? + +### [ ] +Ruby utilise des crochets droits [ ] pour viser un élement. +Les crochets droits sont très commun dans Ruby. +Ce sont comme des lunettes de visée pour aligner une cible. Exactement. +Ces crochets signifient, "Je cherche ____". Prêt, vises. + +Recupèrons tous nos numéros de lotto : + + puts ticket[0] + puts ticket[1] + puts ticket[2] + +Pourquoi utiliser [0], [1], [2] ? + +Et pourquoi pas [1], [2] and [3] ? Est-ce que c'est une éspèce de truc Zen japonais ? +Non, nous autre les amis des ordinateurs on préfère juste commencer à compter à +partir de zéro. C'est pas juste un truc dans Ruby, ça s'appelle _l'indexation à +base zéro_ et c'est utilisé dans la plupart des languages de programmation. + +> Un petit rappel : tu peux utiliser le bouton __Copy__ pour recopier l'exemple de code dans l'éditeur. diff --git a/translations/fr/try_ruby_180.md b/translations/fr/try_ruby_180.md new file mode 100644 index 00000000..7818e7da --- /dev/null +++ b/translations/fr/try_ruby_180.md @@ -0,0 +1,34 @@ +--- +lang: FR +title: Le résumé #2 est arrivé +answer: \w+ +class: stretcher chapmark +load: poem = "My toast has flown from my hand\nAnd my toast has gone to the moon.\nBut when I saw it on television,\nPlanting our flag on Halley's comet,\nMore still did I want to eat it.\n" +ok: Est-ce que ça rime? +error: +--- + +Jettons un œil à ce qui s'est passé pendant ta deuxième minute: + +### Erreurs +Si tu essayes d'inverser un nombre ou de faire des choses bizarres, Ruby +te dira ce qui ne va pas. + +### Listes +Les arrays sont des listes pour stocker des choses dans un ordre +spécifique. On sait égaelement comment créer un array et récuperer des +élement dans un array. + +### Variables +Les variables sauvegardent une chose et lui donne un nom. Tu as utilisé +le signe égal pour ça. Par example: ticket = [14, 37, 18]. + +### 2/8 +En tout il y a huit sections. Tu as fini deux-huitièmes du chemin! C'est +pas si compliqué, non? Et il y a plein de bonnes choses à suivre. + +Changeons de direction pour un instant. J'ai mis un petit bout de poésie +pour toi dans une certaine variable. +Jette un œil. Saisi: + + puts poem diff --git a/translations/fr/try_ruby_190.md b/translations/fr/try_ruby_190.md new file mode 100644 index 00000000..346ae874 --- /dev/null +++ b/translations/fr/try_ruby_190.md @@ -0,0 +1,17 @@ +--- +lang: FR +title: Malheuresement, la poésie de biscotte c'est pas ton truc +answer: (toast){0} +load: prev +ok: Excellent +error: Ça sent toujours la biscotte pour moi +--- + +Eh, c'est pas grave. T'es pas obligé d'aimer ça. Laisses toi aller et +améliore mon poème. Au lieu d'une biscotte, tu peux essayer un melon +pourquoi pas. Essaie de voir ce nouveau poème: + + poem.gsub("toast", "honeydew") + +La méthode __gsub__ est un raccourci pour *sub*stitution *g*lobale. +Elle remplace toutes les instances du mot "toast" avec "honeydew". diff --git a/translations/fr/try_ruby_20.md b/translations/fr/try_ruby_20.md new file mode 100644 index 00000000..0020ddf4 --- /dev/null +++ b/translations/fr/try_ruby_20.md @@ -0,0 +1,19 @@ +--- +lang: EN +title: Using the editor +answer: ^\d{1,}$ +ok: Good! You did a bit of math. See how the answer popped out? +error: Type 2 + 6 in the editor +--- + +The editor window at the bottom is where you type your Ruby code, hit the __Run__ button and +watch it run! + +For example, try typing some math. Like: + + 2 + 6 + +The output of your program should show itself at the output window at the top. +There should also be a line that tells you how well you did. + +> Alternatively you can hit the __Copy__ button to copy the example code to the editor. diff --git a/translations/fr/try_ruby_200.md b/translations/fr/try_ruby_200.md new file mode 100644 index 00000000..9033f3d0 --- /dev/null +++ b/translations/fr/try_ruby_200.md @@ -0,0 +1,12 @@ +--- +lang: EN +title: Ready, Aim +answer: ^\n.ti tae ot (.+) +load: prev +ok: Okay, sure. So the whole poem has been turned backwards. +error: +--- + +Here's a question: what happens when we reverse this whole poem? + + poem.reverse diff --git a/translations/fr/try_ruby_210.md b/translations/fr/try_ruby_210.md new file mode 100644 index 00000000..c819ace1 --- /dev/null +++ b/translations/fr/try_ruby_210.md @@ -0,0 +1,17 @@ +--- +lang: EN +title: Too Much Reversal +answer: ^\["More still did (.+) +load: prev +ok: Yes, almost what we want +error: +--- + +So the whole poem's been turned backwards, letter-by-letter. I really wanted to just reverse the lines though. +Move the last line up to first and the first line down to last. + +Backwards, but not __that__ backwards. + +Here's how: + + poem.lines.reverse diff --git a/translations/fr/try_ruby_220.md b/translations/fr/try_ruby_220.md new file mode 100644 index 00000000..e831019c --- /dev/null +++ b/translations/fr/try_ruby_220.md @@ -0,0 +1,21 @@ +--- +lang: EN +title: Ringlets of Chained Methods +answer: ^More still did (.+) +load: prev +ok: Good show, my friend! The join method took that array of lines and put them together into a string. +error: +--- + +So what do you see? What happened there? You typed __poem.lines.reverse__ and what happened? + +Two things happened. You turned the poem into a list using lines. +Lines decides the way the string is split up and converts it into an Array. + +Then, you reversed that list. You had each line. You reversed them. That's it. + +Let's tack one more method on the end there: + + puts poem.lines.reverse.join + +Combining methods like this is called _method chaining_. \ No newline at end of file diff --git a/translations/fr/try_ruby_230.md b/translations/fr/try_ruby_230.md new file mode 100644 index 00000000..750633ab --- /dev/null +++ b/translations/fr/try_ruby_230.md @@ -0,0 +1,30 @@ +--- +lang: EN +title: Of All the Summaries, #3 is Here Now +answer: \{\} +class: stretcher chapmark +load: prev +ok: You've made an empty hash ! +error: +--- + +### Exclamations +Methods may have exclamations (and also question marks) in their name. +These are just there to better explain what their function is. No big deal. + +### String manipulation +Search and change strings + +### Chaining +Chaining methods lets you get a lot more done. Break up a poem, reverse it, reassemble it: +__poem.lines.reverse.join__ + +At this point, you may want to tinker with the poem a bit more. A complete list of all the String +methods is here. + +Go ahead and try a few, such as: poem.downcase or poem.swapcase + +## Ready ? +When you feel ready to move on, type: + + books = {} diff --git a/translations/fr/try_ruby_240.md b/translations/fr/try_ruby_240.md new file mode 100644 index 00000000..3bb1fc32 --- /dev/null +++ b/translations/fr/try_ruby_240.md @@ -0,0 +1,27 @@ +--- +lang: EN +title: A Wee Blank Book +answer: ^(splendid|quite_good|mediocre|quite_not_good|abyssmal)$ +load: books = {} +ok: Yes that's a new review +error: Use one of splendid, quite_good, mediocre, quite_not_good, abyssmal. Don't forget the colon +--- + +You've made an empty __hash__. A hash is like an array, only every one of its elements has a name. + +We're going to stuff some miniature book reviews in our new hash. Here's our rating system: + +- :splendid → a masterpiece +- :quite\_good → enjoyed, sure, yes +- :mediocre → equal parts great and terrible +- :quite\_not\_good → notably bad +- :abyssmal → steaming wreck + +To rate a book, put the title in square brackets and put the rating after the equals. For example: + + books["Gravitys Rainbow"] = :splendid + +> By now I think it is only fair to tell you that all lessons in TryRuby are separate from each other. +> So if you go crazy typing book reviews here, you can only use 'em in this lesson. +> If you want to use your reviews in the next lesson you should copy/paste them. +> Don't worry about this too much, each lesson has plenty of predefined stuff for you to play around with. diff --git a/translations/fr/try_ruby_250.md b/translations/fr/try_ruby_250.md new file mode 100644 index 00000000..3b5c6b05 --- /dev/null +++ b/translations/fr/try_ruby_250.md @@ -0,0 +1,28 @@ +--- +lang: EN +title: More Bite-Size Reviews +answer: [3-9] +load: books = {"Gravitys Rainbow" => :splendid} +ok: See, the length method works on strings, array's and hashes. +error: +--- + +Keep going, fill it up with reviews. And, if you want to see the whole list, just type: __puts books__ + +Again, the ratings are: :splendid, :quite\_good, :mediocre, :quite\_not\_good and :abyssmal. + +These ratings are not strings. When you place a colon in front of a simple word, you get a __symbol__. +Symbols are cheaper than strings (in terms of computer memory.) If you use a word over and over in your program, +use a symbol. Rather than having thousands of copies of that word in memory, the computer will store the symbol only +__once__. + +More importantly, a symbol tells you that is not just any old word but has a meaning within your program. + +Enter 2 more bookreviews, use __books.length__ to see how many reviews there are in the hash: + + books["The deep end"] = :abyssmal + books["Living colors"] = :mediocre + + puts books + + puts books.length diff --git a/translations/fr/try_ruby_260.md b/translations/fr/try_ruby_260.md new file mode 100644 index 00000000..5bb17c7e --- /dev/null +++ b/translations/fr/try_ruby_260.md @@ -0,0 +1,20 @@ +--- +lang: EN +title: Wait, Did I Like Gravity's Rainbow? +answer: ^(splendid|quite_good|mediocre|quite_not_good|abyssmal)$ +load: books = {"Gravitys Rainbow" => :splendid, "The deep end" => :abyssmal, "Living colors" => :mediocre} +ok: I liked it a lot +error: +--- + +One great thing about Ruby is that names are often reused, which means fewer names you need to remember. + +Remember how we retrieved items from an array using a number: +__puts ticket[1]__. + +For a hash this works the same way, except we don't use a number to get an element but a name. + +So, if you'd like to look up one of your old reviews, again put the title in the square. But leave off the equals. +Just like this: + + puts books["Gravitys Rainbow"] diff --git a/translations/fr/try_ruby_270.md b/translations/fr/try_ruby_270.md new file mode 100644 index 00000000..11f43c99 --- /dev/null +++ b/translations/fr/try_ruby_270.md @@ -0,0 +1,19 @@ +--- +lang: EN +title: Hashes as Pairs +answer: ^\[".*"\] +load: prev +ok: You found the keys +error: +--- + +Keep in mind that hashes won't keep things in order. That's not their job. It'll just pair up +two things: a __key__ and a __value__. + +In your reviews, the book's title is the key and the rating is the value. + +If you want to just see the titles of all the books you've reviewed: + + books.keys + +You can also try this with .values instead of .keys. \ No newline at end of file diff --git a/translations/fr/try_ruby_280.md b/translations/fr/try_ruby_280.md new file mode 100644 index 00000000..edee0dba --- /dev/null +++ b/translations/fr/try_ruby_280.md @@ -0,0 +1,27 @@ +--- +lang: EN +title: Are You Harsh? +answer: "mediocre" +load: books = {"Gravitys Rainbow" => :splendid, "The deep end" => :abyssmal, "Living colors" => :mediocre, "Bumblebees" => :mediocre} +ok: Great, wow! You've made a scorecard of your ratings +error: +--- + +So are you giving out harsh, unfair reviews? Let's keep score with a new hash __ratings__: + +Then, okay, now let's count up your reviews. Just stay with me. Type: + + ratings = Hash.new {0} + + books.values.each { |rate| + ratings[rate] += 1 + } + + puts ratings + +The straight line in the code is the pipe character, probably located right above the Enter key +on your keyboard. + +That _+= 1_ line means: increase the value by 1. + +Don't worry if you don't understand everything that is going on here. It will be revealed later. diff --git a/translations/fr/try_ruby_290.md b/translations/fr/try_ruby_290.md new file mode 100644 index 00000000..e41cd742 --- /dev/null +++ b/translations/fr/try_ruby_290.md @@ -0,0 +1,18 @@ +--- +lang: EN +title: A Tally +answer: \w+ +ok: Yodelay! +error: +--- + +One of the amazing new things we've just used is a __block__. We're going to explore these more +in this and the next lesson. But, basically, a block is a bit of Ruby code surrounded by curly +braces. + +Let's try another block: + + 5.times { print "Odelay! " } + +Blocks are always attached to methods. Like the __times__ method, which takes the block and runs +the code over and over. (In our example: five times.) \ No newline at end of file diff --git a/translations/fr/try_ruby_30.md b/translations/fr/try_ruby_30.md new file mode 100644 index 00000000..a504f1c7 --- /dev/null +++ b/translations/fr/try_ruby_30.md @@ -0,0 +1,13 @@ +--- +lang: EN +title: Numbers and Math +answer: ^[0-9\.,-]{1,}$ +ok: Good +error: +--- + +Ruby recognizes numbers and mathematic symbols. You could try some other math like: + + 4 * 10 + 5 - 12 + 30 / 4 \ No newline at end of file diff --git a/translations/fr/try_ruby_300.md b/translations/fr/try_ruby_300.md new file mode 100644 index 00000000..59198554 --- /dev/null +++ b/translations/fr/try_ruby_300.md @@ -0,0 +1,23 @@ +--- +lang: EN +title: Have you got the time? +answer: ^[0-9]$ +ok: You timed it just right! +error: Run the block 0 to 9 times +--- + +As we saw in the first example with a block (when counting ratings) we can pass a value to the block. Which +values are __passed__ is determined by the method that is running the block. + +The values that are __received__ by the block are placed in the variable name at the beginning of the block, +between two pipe symbols: | + +Let's try that with this block: + + 5.times { |time| + puts time + } + +Here, method __.times__ sends a value to variable __|time|__. But note that variable time is only known within the block. + +> Did you notice that you can split code over multiple lines. This makes it a bit easier to read. diff --git a/translations/fr/try_ruby_310.md b/translations/fr/try_ruby_310.md new file mode 100644 index 00000000..b3bcd239 --- /dev/null +++ b/translations/fr/try_ruby_310.md @@ -0,0 +1,24 @@ +--- +lang: EN +title: Now Arriving at Summary #4 +answer: +class: stretcher chapmark +ok: +error: +--- + +This last lesson was a bit longer. You've probably used up three minutes learning about: + +### Hashes +The little dictionary with the curly pages: __{}__ + +### Symbols +Tiny, efficient code words with a colon, like: __:splendid__ + +### Blocks +Chunks of code which can be tacked on to many of Ruby's methods. Here's the code you used to +build a scorecard: +__books.values.each { |rate| ratings[rate] += 1 }__ + +### Next +In the next lesson we will delve al little bit deeper into methods. diff --git a/translations/fr/try_ruby_320.md b/translations/fr/try_ruby_320.md new file mode 100644 index 00000000..7e67a5e7 --- /dev/null +++ b/translations/fr/try_ruby_320.md @@ -0,0 +1,38 @@ +--- +lang: EN +title: To (be) or not to (be) +answer: +load: poem = "My toast has flown from my hand\nAnd my toast has gone to the moon.\nYada yada yada\n" +ok: +error: +--- + +One other little thing we haven't really talked about openly: method arguments. +Remember when we changed the poem a little bit ? We used: +__poem.gsub("toast", "honeydew")__ + +The gsub method needs 2 arguments, which we passed to gsub by including two strings between +parenthesis. _Arguments tell the method exactly what to do._ + +### Parenthesis +Actually, most of the time Ruby doesn't mind if you omit the parenthesis. So this would have +worked too: +__poem.gsub "toast", "honeydew"__ + +We have already used another method with a parameter. Many times in fact, though it was not very +obvious: + + puts "Hello" + puts("Hello") + +Yes __puts__ is also a method. Using puts with or without parenthesis is the same to Ruby, but the +version without parenthesis is a bit easier to read. And it saves you valuable typing time ! + +> So I guess the conclusion is that you can do whatever you like with parenthesis as long as your +> code reads nicely. + +### to (be) or not to (be) +So if _to_ is a method and _be_ is an argument we now know the answer to this age old question. +It is really just a matter of preference whether you want _to be_ or _to(be)_. + +Are you in the mood for more Shakespeare ? Read on. diff --git a/translations/fr/try_ruby_330.md b/translations/fr/try_ruby_330.md new file mode 100644 index 00000000..1b1638ab --- /dev/null +++ b/translations/fr/try_ruby_330.md @@ -0,0 +1,33 @@ +--- +lang: EN +title: The Taming of the Shrew +answer: ^tame +ok: Good good ! +error: +--- + +You totally know how to use Ruby now. I mean you've got down the essentials. +You just need to keep learning more methods and try out more complex blocks. + +But there's one side of Ruby we haven't settled. Making your own methods. +__Ahem!__ Let's get it over with then. + +Next to using Ruby's built in methods (like puts, sort, times) you can define +your own methods. Why is that a good idea? Two reasons: + +### To make your program shorter +If you have to do the same thing in more than one part of your code it is easier +to put that code in a separate method. Your code will be shorter. + +### To make your code easier to read +Suppose your program needs to do a lot of different things. +You __could__ stuff all code into one long piece. But it would be very difficult to +read and understand that code later. + +Instead you should cut up your code in different methods and give each method an easy to +understand English name. You will thank yourself later. + +So how do we define a method ? Like this: + + def tame( number_of_shrews ) + end diff --git a/translations/fr/try_ruby_340.md b/translations/fr/try_ruby_340.md new file mode 100644 index 00000000..0da857a1 --- /dev/null +++ b/translations/fr/try_ruby_340.md @@ -0,0 +1,24 @@ +--- +lang: EN +title: In Ruby, Def Leppard means: define method Leppard +answer: ^tame +ok: Tame is not lame +error: +--- + +Hey, okay, you done it. You're making your own method. You started with def, followed by the name of the method. +And a list of arguments which the method will need. This isn't too scary and dangerous! +All we have to do is fill it up with Ruby and finish it up with end. + +Here's the code: + + def tame( number_of_shrews ) + number_of_shrews.times { + puts "Tamed a shrew" + } + end + +> __P.S.__ +> If you don't get the title of this chapter. +> Def Leppard +> is the name of a, once famous, English rock band. diff --git a/translations/fr/try_ruby_350.md b/translations/fr/try_ruby_350.md new file mode 100644 index 00000000..8d88d089 --- /dev/null +++ b/translations/fr/try_ruby_350.md @@ -0,0 +1,12 @@ +--- +lang: EN +title: The Ripened Fruit of Your Own Creation +answer: ^Tamed a shrew +ok: That'll show those shrews +error: +load: def tame(number_of_shrews);number_of_shrews.times{puts "Tamed a shrew"};end; +--- + +A new method is born. Let us use it now: + + tame 5 diff --git a/translations/fr/try_ruby_360.md b/translations/fr/try_ruby_360.md new file mode 100644 index 00000000..a2b3d9d5 --- /dev/null +++ b/translations/fr/try_ruby_360.md @@ -0,0 +1,29 @@ +--- +lang: EN +title: Give and take +answer: \d+ +ok: Right on. Bravo. +error: +--- + +Most methods do not only want some parameters as input, but will also __give something back__. +I have changed our method a bit so it will return a value to you. Try it: + + def tame( number_of_shrews ) + number_of_shrews.times { + puts "Tamed a shrew" + } + return number_of_shrews + end + + puts tame(3) + +### Return +And, since you're getting so advanced and capable here, one other tip: +you can omit the word __return__ from the last line of the method. +Ruby will automagically return the last value that was used inside the method. + +So we can change the last line to just: __number\_of\_shrews__. + +But since method __.times__ also returns the _number\_of\_shrews_ we can +remove the entire last line. So in fact our original method already did what we wanted all along ! diff --git a/translations/fr/try_ruby_370.md b/translations/fr/try_ruby_370.md new file mode 100644 index 00000000..8098d3d5 --- /dev/null +++ b/translations/fr/try_ruby_370.md @@ -0,0 +1,27 @@ +--- +lang: EN +title: Hello, Who's There? And Summary #5 Waves Its Hat! +answer: +class: stretcher chapmark +ok: +error: +--- + +Well done, well done, well done, well done! + +Truly, truly, truly, truly, truuuuuuuuly! + +Here's the last few minutes of your life in review: + +### Methods +Methods can be defined with __def__ and have a name. Methods make your program shorter +and easier to read. + +### Parameters +Methods can have parameters. + +### Return values +Methods (almost) always return a value. + +## Now +To (be) or not to (be) is not a question to you anymore. Are you ready for some more Shakespeare ? diff --git a/translations/fr/try_ruby_380.md b/translations/fr/try_ruby_380.md new file mode 100644 index 00000000..88909568 --- /dev/null +++ b/translations/fr/try_ruby_380.md @@ -0,0 +1,33 @@ +--- +lang: EN +title: The world is our oyster +answer: ^\{\"William +ok: Good. Bit difficult to read. +error: +load: def get_shakey;JSON.parse("{\"William Shakespeare\": {\"1\": {\"title\": \"The Two Gentlemen of Verona\", \"finished\": 1591},\"2\": {\"title\": \"The Taming of the Shrew\", \"finished\": 1591},\"3\": {\"title\": \"Henry VI, Part 2\", \"finished\": 1591},\"4\": {\"title\": \"Henry VI, Part 3\", \"finished\": 1591},\"5\": {\"title\": \"Henry VI, Part 1\", \"finished\": 1592},\"6\": {\"title\": \"Titus Andronicus\", \"finished\": 1592},\"7\": {\"title\": \"Richard III\", \"finished\": 1593},\"8\": {\"title\": \"Edward III\", \"finished\": 1593},\"9\": {\"title\": \"The Comedy of Errors\", \"finished\": 1594},\"10\": {\"title\": \"Love's Labour's Lost\", \"finished\": 1595},\"11\": {\"title\": \"Love's Labour's Won\", \"finished\": 1596},\"12\": {\"title\": \"Richard II\", \"finished\": 1595},\"13\": {\"title\": \"Romeo and Juliet\", \"finished\": 1595},\"14\": {\"title\": \"A Midsummer Night's Dream\", \"finished\": 1595},\"15\": {\"title\": \"King John\", \"finished\": 1596},\"16\": {\"title\": \"The Merchant of Venice\", \"finished\": 1597},\"17\": {\"title\": \"Henry IV, Part 1\", \"finished\": 1597},\"18\": {\"title\": \"The Merry Wives of Windsor\", \"finished\": 1597},\"19\": {\"title\": \"Henry IV, Part 2\", \"finished\": 1598},\"20\": {\"title\": \"Much Ado About Nothing\", \"finished\": 1599},\"21\": {\"title\": \"Henry V\", \"finished\": 1599},\"22\": {\"title\": \"Julius Caesar\", \"finished\": 1599},\"23\": {\"title\": \"As You Like It\", \"finished\": 1600},\"24\": {\"title\": \"Hamlet\", \"finished\": 1601},\"25\": {\"title\": \"Twelfth Night\", \"finished\": 1601},\"26\": {\"title\": \"Troilus and Cressida\", \"finished\": 1602},\"27\": {\"title\": \"Sir Thomas More\", \"finished\": 1604},\"28\": {\"title\": \"Measure for Measure\", \"finished\": 1604},\"29\": {\"title\": \"Othello\", \"finished\": 1604},\"30\": {\"title\": \"All's Well That Ends Well\", \"finished\": 1605},\"31\": {\"title\": \"King Lear\", \"finished\": 1606},\"32\": {\"title\": \"Timon of Athens\", \"finished\": 1606},\"33\": {\"title\": \"Macbeth\", \"finished\": 1606},\"34\": {\"title\": \"Antony and Cleopatra\", \"finished\": 1606},\"35\": {\"title\": \"Pericles, Prince of Tyre\", \"finished\": 1608},\"36\": {\"title\": \"Coriolanus\", \"finished\": 1608},\"37\": {\"title\": \"The Winter's Tale\", \"finished\": 1611},\"38\": {\"title\": \"Cymbeline\", \"finished\": 1610},\"39\": {\"title\": \"The Tempest\", \"finished\": 1611},\"40\": {\"title\": \"Cardenio\", \"finished\": 1613},\"41\": {\"title\": \"Henry VIII\", \"finished\": 1613},\"42\": {\"title\": \"The Two Noble Kinsmen\", \"finished\": 1614}}}");end; +--- + +So far we have been running programs that only use things that we have typed ourselves. +Which is nice, I mean that _Odelaying_ was epic, but this the internet era so it is about +time we included the rest of the world in our programming efforts. + +Many, many, many websites are available that you can ask for information. For instance +this link will give you all current Google news feeds +about Ruby. + +Your web browser will probably display it quite nicely for you. If you look at the source +(type: control-U) you will see a long string of strangely formatted text. In the Google example +it is in the __rss__ format. + +### Formats +There are many other formats, with strange names, available and used on the web, like: +html, xml and json. Yes, even this very website uses a couple of these. + +I have prepared a method for you that will fetch a list of the complete works of William +Shakespeare from the internet. +(Don't worry it actually comes from the same server that this website runs on, so +we're not bothering anyone.) + +Get the data with: + + get_shakey diff --git a/translations/fr/try_ruby_390.md b/translations/fr/try_ruby_390.md new file mode 100644 index 00000000..f6872930 --- /dev/null +++ b/translations/fr/try_ruby_390.md @@ -0,0 +1,53 @@ +--- +lang: EN +title: Noble Kinsmen +answer: ^The Two Noble Kinsmen$ +ok: That's much better +error: +load: prev +--- + +Okay we now have a list of plays from the internet. The list was in the json format. +Fortunately for us Ruby kindly provides a method to convert json data to a Ruby hash. +The _get\_shakey_ method already did that for us. + +But since the structure of the json data is retained in the hash, it is still a bit difficult to read. +Let us write a method to display the plays nicely. + +If you inspect the list of plays carefully you will see that it has a kind of nested +structure. (This is actually quite common in data you get from the internet.) +Looks like this: + + + +To list the plays we first have to access the top "William Shakespeare" hash element by it's name. +Next we have to __iterate__ through each element below it. + +Ruby has a method for iterating. It is called __each__. We have seen it before when +creating our book rating system. + +Everything that method __each__ returns is passed to a block: + + s = get_shakey + + s["William Shakespeare"].each { |key, val| + puts val["title"] + } diff --git a/translations/fr/try_ruby_40.md b/translations/fr/try_ruby_40.md new file mode 100644 index 00000000..106ca039 --- /dev/null +++ b/translations/fr/try_ruby_40.md @@ -0,0 +1,27 @@ +--- +lang: EN +title: Putting it differently +answer: ^[0-9\.,-]{1,}$ +ok: Well put +error: +--- + +Did you notice that if you typed more than one formula you only saw the answer for the last one. +What is going on ? + +> To make this website easier to use I have told Ruby to copy the result of your program to the +> output screen at the top. So when you type a formula you get to see the results. +> __But only the last result.__ And only if the output is still empty. + +So when you entered 2 or more formula's, Ruby only showed the result of the last formula. + +Of course you have the power to control the screen ! Just type __puts__ before each formula +(with a space in between). Puts means: *'put something on the screen'*. + +Try this: + + puts 4 * 10 + puts 5 - 12 + puts 30 / 4 + +Now remove the puts from the last formula and see what happens. diff --git a/translations/fr/try_ruby_400.md b/translations/fr/try_ruby_400.md new file mode 100644 index 00000000..b9bd7cda --- /dev/null +++ b/translations/fr/try_ruby_400.md @@ -0,0 +1,41 @@ +--- +lang: EN +title: All together now +answer: ^4$ +ok: Yes, Shakespeare wrote 4 plays in 1591 +error: Answer for the year 1591 should be 4 +load: prev +--- + +Now suppose we only want to know the names and number of plays written by Shakespeare +in a certain year. + +Ruby lets us __select__ values from a hash. The select method uses a block to let us +define what to select and returns what it found. + +We can then use the results returned by __select__ in the __each__ method as before by +simply adding it after the select block. This is another example of method chaining, which we saw +earlier when reversing a poem. + +I have prepared the __count\_plays__ method for you. See if you can find out how many plays +were written by Shakespeare in the year __1591__. Try this: + + def count_plays(year) + s = get_shakey + + s["William Shakespeare"] + .select { |k, v| + v["finished"] == year + }.each { |key, val| + puts val["title"] + }.count + end + + puts count_plays(0) + +Did you notice that I chained the count method at the end of the each method. This gives +us a return value for the __count\_plays__ method. + +There is another possibility for chaining here. See that loney line __s = get_shakey__. +You could add the __["William Shakespeare"].select { |k, v|__ at the end of get_shakey +(no dot needed in this case). diff --git a/translations/fr/try_ruby_410.md b/translations/fr/try_ruby_410.md new file mode 100644 index 00000000..1ec0b868 --- /dev/null +++ b/translations/fr/try_ruby_410.md @@ -0,0 +1,40 @@ +--- +lang: EN +title: All's Well That Ends Well +answer: All's Well That Ends Well +ok: True +error: Use 1605 as the second parameter +load: prev +--- + +Okay, we got some data from the internet, we selected what we wanted and printed it out. +What is left to improve? We could print the results a bit prettier. Like add the year +and align titles and years. + +This means printing several values on one line. Ruby has a neat way of doing +that. It is just like printing a string like: __puts "Hi, my name is Jimmy"__. +But instead of the literal value _Jimmy_ we use the value of a variable. + +First replace __Jimmy__ with __#{}__. If Ruby sees a hash symbol # followed by a curly brace { +it looks for a variable between the first brace and the following closing brace }. +So we can use this: __"Hi, my name is \#{name}"__. + +Let's change our code a bit + + def print_plays(year_from, year_to) + get_shakey["William Shakespeare"] + .select { |k, v| + year_from <= v["finished"] && + year_to >= v["finished"] + }.each { |k, v| + puts "#{v["title"].ljust(30)} #{v["finished"]}" + } + end + print_plays(1600, 1605) + +I have added __.ljust(30)__ to the title. This way the title is _left justified_ with a minimum +length of 30 characters so the years align nicely. + +See if you can change the ouput of the program so that it shows the plays like this: __1600 -> As You Like It__ + +__All's Well That Ends Well ?__ Hey we're not done yet, but the end is in sight ! diff --git a/translations/fr/try_ruby_420.md b/translations/fr/try_ruby_420.md new file mode 100644 index 00000000..ccda7ab9 --- /dev/null +++ b/translations/fr/try_ruby_420.md @@ -0,0 +1,36 @@ +--- +lang: EN +title: If only I new how to make a decision +answer: +ok: +error: +--- + +Decision making, in real life this can be a real problem. Not for us though. +Ruby makes it very easy to make decisions. + + if 1 < 2 + puts "It is true: 1 is less than 2" + end + +The key word here is __if__. If can be placed before a method or after a method, like so: + + puts "It is true: 1 is less than 2" if 1 < 2 + +__If__ is a method that requires one parameter. That parameter can be any expression that you +want to test. The outcome of the expression must be either __true__ or __false__. +Here are a couple of expressions with their outcomes: + + 5 <= 10 # => true + 'abc' == 'def' # => false + true # => true + 123456 # => true + 0 # => true + nil # => false + 'xyz'.empty? # => false + 'a' > 5 # => error: + # comparison of String with + # Numeric failed + +The _if expression_ can take many forms. It can compare literal values (1 < 2), +variables (a < 1) and the return value of a method ('xyz'.empty?). diff --git a/translations/fr/try_ruby_430.md b/translations/fr/try_ruby_430.md new file mode 100644 index 00000000..7de3263c --- /dev/null +++ b/translations/fr/try_ruby_430.md @@ -0,0 +1,34 @@ +--- +lang: EN +title: And Now For the Startling Conclusion +answer: is not equal to 100$ +ok: That's better +error: This can't be right +--- + +Did you see the 2 equal signs in __'abc' == 'def'__? + +This __==__ means __is equal to__. +The single equal sign that we have seen before means __assign a value to a variable__. + +To make it more confusing: you can use the assignment after an if method like this: + + a = 0 + + if a = 100 + puts "Expression is true, but a is now: #{a}" + else + puts "#{a} is not equal to 100" + end + +Change the = into == and see what happens. + +I can guarantee you that you will forget typing the second equal sign regularly. I also +still forget it sometimes. + +### else +In the code above I have added an else expression. This part will be executed when the +__if test-expression__ evaluates to false. + +> There are more variations to this if-then-else theme. You can read more +> here. diff --git a/translations/fr/try_ruby_440.md b/translations/fr/try_ruby_440.md new file mode 100644 index 00000000..7c3c7d0e --- /dev/null +++ b/translations/fr/try_ruby_440.md @@ -0,0 +1,31 @@ +--- +lang: EN +title: Me hungry +answer: ^Me not hungry.$ +ok: Yes +error: No way am I hungry at 10 AM ! +--- + +Okay, this is coming along wonderfully. This is simple stuff for you, but keep in mind that you +didn't know __any Ruby whatsoever__ just fifteen minutes ago! + +Last step. Let's tie it all together, you know? Let's make it chime together like a very nice set +of glistening chimes on the beach in the maginificent sunlight! + +We'll define two methods first and then take a decision: + + def hungry?(time_of_day_in_hours) + puts "Me hungry." + true + end + + def eat_an(what) + puts "Me eat #{what}.\n" + end + + eat_an 'apple' if hungry?(14) + + eat_an 'apple' if hungry?(10) + +Now see if you can change the method __hungry?__ to display __"Me not hungry"__ and returning false +when the time is less than 12. diff --git a/translations/fr/try_ruby_450.md b/translations/fr/try_ruby_450.md new file mode 100644 index 00000000..0b263950 --- /dev/null +++ b/translations/fr/try_ruby_450.md @@ -0,0 +1,33 @@ +--- +lang: EN +title: Summary #6 Which Means You've Come So Far +answer: \{\} +class: stretcher chapmark +ok: Ok, that's an empty hash +error: +--- + +You're a level six Ruby cleric. I mean what a great job you've done. Let's review: + + +### Data +You loaded some data of the internet, traversed a data structure and selected values. + +### Iterating +You iterated all elements of a hash and you chained some more methods. + +### Pretty printing +And if that wasn't enough, you formatted and printed some values in a way that is easy +to read for humans. In fact __you made a real program !__ + +### IF +You learned to take control of your programs with __if__ and __else__ statements. + +## So +What could possibly be next? What could you possibly have to learn now? +Ha, this is the best part. You've come such a long way that we're going +to uncover classes. For two more short lessons and you're done. + +Earlier, we created a hash like this: + + Hash.new diff --git a/translations/fr/try_ruby_460.md b/translations/fr/try_ruby_460.md new file mode 100644 index 00000000..fcb68e5b --- /dev/null +++ b/translations/fr/try_ruby_460.md @@ -0,0 +1,33 @@ +--- +lang: EN +title: Not a School Class, a Working Class +answer: +ok: +error: +--- + +You see, the empty curly braces {} is a shortcut for Hash.new. The new method is used to make objects +of a certain class. Think "class" as in "working class" — a specific group of objects which +are similar, have the same jobs, the same shirts. +What use is a class ? + +### BlurbalizerTM +You just had a brilliant idea for a new app. It is going to be __the__ next instant +messaging platform. You want an app where people can send each other short messages. You call +these messages BlurbsTM. A BlurbTM has a maximum length of just 40 characters. Let's do a mood setting too. + + + +### Where to start +Well, you might store your BlurbsTM entries in a json file, right? +But how would you keep track of the content of the entry and the time it was posted? +And when you loaded the file, how would it look in Ruby? +Would it be a Hash? Or an Array? Or an Array of Arrays? Or something else? + +### Class +I really think you'll want to use a class. You are already familiar with many classes: +Hash, Array, String. +Let's make a new class (returns no output): + + class Blurb + end diff --git a/translations/fr/try_ruby_470.md b/translations/fr/try_ruby_470.md new file mode 100644 index 00000000..12cdde83 --- /dev/null +++ b/translations/fr/try_ruby_470.md @@ -0,0 +1,20 @@ +--- +lang: EN +title: The Stuff Apps are Made of +answer: +ok: +error: +--- + +You've opened up a new BlurbTM class. What is your blog entry made of? +The content, sure. Also, a time when the BlurbTM was posted. And a mood. + +Okay, so you've got the first line of the class, here's the rest: + + class Blurb + attr_accessor :content, :time, :mood + end + +Class names always begin with a capital letter. + +(Still no output) diff --git a/translations/fr/try_ruby_480.md b/translations/fr/try_ruby_480.md new file mode 100644 index 00000000..049990cc --- /dev/null +++ b/translations/fr/try_ruby_480.md @@ -0,0 +1,25 @@ +--- +lang: EN +title: Accessors Are the Dangling Limbs +answer: Blurb: +ok: My first Blurb +error: +load: class Blurb;attr_accessor :content,:time,:mood;end +--- + +Hey, good class, man. You've got a new BlurbTM class. + +In the class definition, you used a method called attr\_accessor. +There are many __attr__ibute methods like this which add little settings to classes. +These attributes are just variables attached to a class. + +Think of it this way. A class is like a person. That star-shaped human thing out there. +And the attributes are the dangling limbs, the different parts that make up a body and +other people can shake hands with. + +### Now +To create a BlurbTM and set the content: + + blurb1 = Blurb.new + puts blurb1 + blurb1.content = "Today Mount Hood Was Stolen!" diff --git a/translations/fr/try_ruby_490.md b/translations/fr/try_ruby_490.md new file mode 100644 index 00000000..95e72478 --- /dev/null +++ b/translations/fr/try_ruby_490.md @@ -0,0 +1,15 @@ +--- +lang: EN +title: An Object, That Neat Little Package +answer: Blurb: +ok: Blurb updated +error: +load: prev;blurb1=Blurb.new;blurb1.content="Today Mount Hood Was Stolen!" +--- + +Go ahead and set the BlurbTM time and mood: + + blurb1.time = Time.now + blurb1.mood = :sick + + puts blurb1 diff --git a/translations/fr/try_ruby_50.md b/translations/fr/try_ruby_50.md new file mode 100644 index 00000000..89c1485b --- /dev/null +++ b/translations/fr/try_ruby_50.md @@ -0,0 +1,13 @@ +--- +lang: EN +title: Say Your Name +answer: [a-zA-Z]{1,1} +ok: Perfect, you've formed a string from the letters of your name +error: +--- + +Sure, computers are handy and fast for math. Let's move on. Want to see your name reversed? + +First type your first name in quotes like this: + + "Jimmy" diff --git a/translations/fr/try_ruby_500.md b/translations/fr/try_ruby_500.md new file mode 100644 index 00000000..a18e0207 --- /dev/null +++ b/translations/fr/try_ruby_500.md @@ -0,0 +1,31 @@ +--- +lang: EN +title: Quickening it Up +answer: ^\d{4} +ok: Noted +error: +--- + +Cool, you're app is awesome. Hey, let's make things a bit easier on you. +You're not going to want to set the time like that every time you BlurbTM. + +You just want to type the content and set the mood, right? + +Let's add an __initialize__ method to our class. This method is called whenever a new BlurbTM +is created. +At the same time we can limit the length of the BlurbTM content to 40 characters. + + class Blurb + attr_accessor :content, :time, :mood + + def initialize(mood, content="") + @time = Time.now + @content = content[0..39] + @mood = mood + end + end + + Blurb.new.time + +(That parameter __content=""__ is there to make sure that we know content is a string, +even if no content parameter is passed to the initialize method.) diff --git a/translations/fr/try_ruby_510.md b/translations/fr/try_ruby_510.md new file mode 100644 index 00000000..a1890dcb --- /dev/null +++ b/translations/fr/try_ruby_510.md @@ -0,0 +1,28 @@ +--- +lang: EN +title: You've Taught Your App to Reject Worthless Things +answer: Blurb: +ok: Blurb added +error: +load: class Blurb;attr_accessor :content,:time,:mood;def initialize(mood, content="");@time=Time.now;@content=content[0..39];@mood=mood;end;end;blurb1=Blurb.new(:sick,"Today Mount Hood Was Stolen!") +--- + +Did you see how inside the class we used the at-symbols (@time). + +__Outside__ the class, we use accessors: + +> __blurb.time = Time.now__ + +but __inside__ we use the __object's variables__: + +> __@time = Time.now__ + +They're the exact same thing, but expressed in two different places of your program. + +### Create another BlurbTM +When a new BlurbTM is created, the initialize method is used to check for any +arguments to new. + +Uh, we need two arguments: + + Blurb2 = Blurb.new :confused, "I can not believe Mt. Hood was stolen!" diff --git a/translations/fr/try_ruby_520.md b/translations/fr/try_ruby_520.md new file mode 100644 index 00000000..d0fc133b --- /dev/null +++ b/translations/fr/try_ruby_520.md @@ -0,0 +1,27 @@ +--- +lang: EN +title: A Giraffe Has Not Stolen Summary #7 +answer: +class: stretcher chapmark +ok: +error: +load: prev;blurb2=Blurb.new :confused, "I can not believe Mt. Hood was stolen!" +--- + +Aha, you're here. And all in one piece. We're still going to make your app real, +but until then, let's review, okay? + +### Classes +Everything in Ruby is some kind of object. Classes explain objects, how a certain object works. +For example, you made a few BlurbTM objects and these objects are explained in the Blurb +class. +In other words: you call them Blurb objects. +You can use classes to (kinda) model real life objects. + +### Accessors +Accessors are variables attached to an object which can be used __outside__ the object. +(blurb2.time = Time.now) + +### Object variables +Object variables are the same variables you're using for accessors, but __inside__ the object. +(@time = Time.now) diff --git a/translations/fr/try_ruby_530.md b/translations/fr/try_ruby_530.md new file mode 100644 index 00000000..85e2e25e --- /dev/null +++ b/translations/fr/try_ruby_530.md @@ -0,0 +1,46 @@ +--- +lang: EN +title: Your Own Turf +answer: Blurbalizer: +ok: My app created +error: +load: class Blurb;attr_accessor :content,:time,:mood;def initialize(mood, content="");@time=Time.now;@content=content[0..39];@mood=mood;end;end +--- + +Okay, let's wrap things up, kid. Here's the last chapter of the GRIPPING epic story of Try Ruby! +Now that you've got a taste of how it all works, how are you going to use it around the house +and in your grocer's freezer? +You're a great person (one of my favorites), but you need guidance. + +### Let's finish your app +You have app entries, but no actual app. +It still needs a title, someplace to store all BlurbsTM and a timeline in order to work. + +Guess what, we're going to use another class. I've given all the code for the new class in one go. +Just __take your time__ to study it. +I'm in no hurry, I'll wait for you in the next lesson. + + class Blurbalizer + def initialize(title) + @title = title + @blurbs = [] # A fresh clean array + # for storing Blurbs + end + + def add_a_blurb(mood, content) + # The << means add to the end of the array + @blurbs << Blurb.new(mood, content) + end + + def show_timeline + puts "Blurbify: #{@title} has #{@blurbs.count} Blurbs" + + @blurbs.sort_by { |t| + t.time + }.reverse.each { |t| + puts "#{t.content.ljust(40)} #{t.time}" + } + end + end + + myapp = Blurbalizer.new "The Big Blurb" diff --git a/translations/fr/try_ruby_540.md b/translations/fr/try_ruby_540.md new file mode 100644 index 00000000..7b756365 --- /dev/null +++ b/translations/fr/try_ruby_540.md @@ -0,0 +1,24 @@ +--- +lang: EN +title: What's that Blurb all about? +answer: Today +ok: Bring on the blurbs +error: +load: prev;class Blurbalizer;attr_reader :title;def initialize(title);@title=title;@blurbs=[];end;def add_a_blurb(mood, content);@blurbs << Blurb.new(mood, content);@blurbs.each {|t| t.time -= 73};end;def show_timeline;puts "Blurbalizer: #{@title} has #{@blurbs.count} Blurbs\n";@blurbs.sort_by { |t| t.time}.reverse.each { |t| puts "#{t.content.ljust(40)} #{t.time}"};end;end;myapp = Blurbalizer.new "The Big Blurb";myapp.add_a_blurb :sick,"Today Mount Hood Was Stolen!";myapp.add_a_blurb :confused,"I can not believe Mt. Hood was stolen!";myapp.add_a_blurb :dazed,"I am speechless!";myapp.add_a_blurb :mad,"It was stolen by a giraffe !!";myapp.add_a_blurb :sad,"I Left my Hoodie on the Mountain!";myapp.add_a_blurb :mad,"I am never going back to that mountain." +--- + +There you are. Did you figure out what all that code in the BlurbalizerTM class does ? + +> In the BlurbalizerTM class are two __methods__ (add\_a\_blurb and show\_timeline). +> You can use a method outside the class, just like we did with accessors. + +Time to start using BlurbalizerTM. I've already loaded some BlurbsTM for you, +but feel free to add your own. + +We're no longer creating BlurbsTM directly, but we use the add\_a\_blurb __method__ of the +BlurbalizerTM class. This way we can be sure all our BlurbsTM are stored in the +myapp object. + + myapp.add_a_blurb :moody, "Add Blurb here" + + myapp.show_timeline diff --git a/translations/fr/try_ruby_550.md b/translations/fr/try_ruby_550.md new file mode 100644 index 00000000..c23462f1 --- /dev/null +++ b/translations/fr/try_ruby_550.md @@ -0,0 +1,64 @@ +--- +lang: EN +title: It's All About Combining +answer: :- +ok: Moody ! +error: +load: prev +--- + +Some beautiful things can be done with the simple parts of Ruby, especially when you combine them +together into new things. +Here we've got an app made of a class containing another class. And, actually, Ruby really does good +with this kind of creature. It is called object oriented programming. + +We have arrived at the __last programming excercise__ of TryRuby. If you want, you can add some +more features to BlurbalizerTM. + +Maybe you want to print the mood as a smiley in the __show_timeline__ method. You could add +a _moodify_ method to the BlurbTM class and then use that method in the _show\_timeline_ method: + + class Blurb + attr_accessor :content, :time, :mood + + def initialize(mood, content="") + @time = Time.now + @content = content[0..39] + @mood = mood + end + + def moodify + if @mood == :sad + return ":-(" + elsif @mood == :happy + return ":-)" + # Add other moods here + end + + # The default mood + ":-|" + end + end + + class Blurbalizer + def initialize(title) + @title = title + @blurbs = [] + end + + def add_a_blurb(mood, content) + @blurbs << Blurb.new(mood, content) + end + + def show_timeline + puts "Blurbalizer: #{@title} has #{@blurbs.count} Blurbs" + + @blurbs.sort_by { |t| + t.time + }.reverse.each { |t| + puts "#{t.content.ljust(40)} #{t.time}" + } + end + end + + myapp.show_timeline diff --git a/translations/fr/try_ruby_560.md b/translations/fr/try_ruby_560.md new file mode 100644 index 00000000..746e124b --- /dev/null +++ b/translations/fr/try_ruby_560.md @@ -0,0 +1,31 @@ +--- +lang: EN +title: Summary #8, The Hey-Relax-You-Did-Good Summary +answer: +class: stretcher chapmark +ok: +error: +load: def ruby(f);puts "Go to www.ruby-lang.org to download Ruby";end;class K;attr_reader :rb;end;my_first_progam=K.new +--- + +This last section took a moment to wind down, to give you some pointers as to how you can use Ruby. + +If you enjoyed yourself, you can continue with the TryRuby Playground +or download and install Ruby: +ruby-lang.org + +Once you have Ruby installed, you can create a file, let say _my\_first\_progam.rb_, with a text +editor, type some Ruby code and then run it by opening a command prompt and typing: + + ruby my_first_progam.rb + +There are many (free) development tools available that combine an editor, file browser and a +'ruby-runner'. + +## Celebrate +You really deserve a double-layer cake with double-double frosting and a guy playing one of those guitars that's a double guitar. +I mean you finished, you really did! No doubt about it, you're a __certified red-blooded smartiac!__ + +## More info +There are a couple of articles on this website. They can give you some pointers on where to +go from here. diff --git a/translations/fr/try_ruby_60.md b/translations/fr/try_ruby_60.md new file mode 100644 index 00000000..c35a67c0 --- /dev/null +++ b/translations/fr/try_ruby_60.md @@ -0,0 +1,16 @@ +--- +lang: EN +title: Say Your Name Backwards +answer: \w+ +ok: dooG +error: +--- + +A string is a set of characters the computer can process. Imagine the letters are on a string of +laundry line and the quotes are clothespins holding the ends. The quotes mark the beginning and end. + +To reverse your name, type: + + "Jimmy".reverse + +(Don't forget the dot!) diff --git a/translations/fr/try_ruby_70.md b/translations/fr/try_ruby_70.md new file mode 100644 index 00000000..21cc4912 --- /dev/null +++ b/translations/fr/try_ruby_70.md @@ -0,0 +1,13 @@ +--- +lang: EN +title: Counting the Letters +answer: ^\d+$ +ok: Yep. Length is also a 'method' +error: +--- + +You have used the reverse __method__ on your name! By enclosing your name in quotes, you made a string. Then you called the reverse method, which works on strings to flip all the letters backwards. + +Now, let us see how many letters are in your name: + + "Jimmy".length diff --git a/translations/fr/try_ruby_80.md b/translations/fr/try_ruby_80.md new file mode 100644 index 00000000..94ac396d --- /dev/null +++ b/translations/fr/try_ruby_80.md @@ -0,0 +1,17 @@ +--- +lang: EN +title: On Repeat +answer: (\w+) +ok: Nice to meet you.Nice to meet you.Nice to meet you. +error: +--- + +Now, you're probably wondering what any of this is good for. + +Well, I'm sure you've been to a website that screamed, __Hey, your password is too short!__ + +See, some programs use that simple __.length__ code. + +Watch this. Let's multiply your name by 5. + + "Jimmy" * 5 diff --git a/translations/fr/try_ruby_90.md b/translations/fr/try_ruby_90.md new file mode 100644 index 00000000..624cc902 --- /dev/null +++ b/translations/fr/try_ruby_90.md @@ -0,0 +1,30 @@ +--- +lang: EN +title: Hey, Summary #1 Already +answer: ^NoMethodError(.*)$ +class: stretcher chapmark +ok: Nope, it is not possible to reverse a number. Click 'next' +error: +--- + +Let's look at what you've learned in the first minute. + +### The editor +Typing code into the editor and clicking on run gives you an answer in the ouput window. +(Almost) all code gives an answer. + +### Numbers and strings +Numbers and strings are Ruby's math and text objects. + +### Methods +You've used English-language methods like reverse and length. And symbolic methods like the +multiplication method: \* +__Methods mean action!__ + +This is the essence of your learning. Taking simple things, toying with them and turning them into +new things. Feeling comfortable yet? I promise you are. + +## Okay, +let's do something uncomfortable. Try reversing a number: + + 40.reverse From 79e4e5bc1deedc592ebb84a4e3fdececf6b33c8e Mon Sep 17 00:00:00 2001 From: Idris TAKERBOUST Date: Sun, 5 May 2024 15:53:35 +0200 Subject: [PATCH 2/3] French translation by Idris TAKERBOUST --- README.md | 2 +- source/about.html.markdown | 2 ++ source/layouts/_navbar.html.erb | 7 +++++ translations/fr/README.md | 2 +- translations/fr/try_ruby_10.md | 19 +++++------- translations/fr/try_ruby_110.md | 8 ++--- translations/fr/try_ruby_20.md | 20 ++++++------ translations/fr/try_ruby_200.md | 10 +++--- translations/fr/try_ruby_210.md | 14 ++++----- translations/fr/try_ruby_220.md | 20 ++++++------ translations/fr/try_ruby_230.md | 30 +++++++++--------- translations/fr/try_ruby_240.md | 38 +++++++++++------------ translations/fr/try_ruby_250.md | 31 +++++++++---------- translations/fr/try_ruby_260.md | 22 ++++++------- translations/fr/try_ruby_270.md | 18 +++++------ translations/fr/try_ruby_280.md | 29 +++++++++-------- translations/fr/try_ruby_290.md | 17 +++++----- translations/fr/try_ruby_30.md | 8 ++--- translations/fr/try_ruby_300.md | 20 ++++++------ translations/fr/try_ruby_310.md | 19 ++++++------ translations/fr/try_ruby_320.md | 46 +++++++++++++-------------- translations/fr/try_ruby_330.md | 40 ++++++++++++------------ translations/fr/try_ruby_340.md | 22 ++++++------- translations/fr/try_ruby_350.md | 11 ++++--- translations/fr/try_ruby_360.md | 26 ++++++++-------- translations/fr/try_ruby_370.md | 34 ++++++++++---------- translations/fr/try_ruby_380.md | 37 ++++++++++------------ translations/fr/try_ruby_390.md | 54 +++++++++++++++++++++++++++++--- translations/fr/try_ruby_40.md | 26 ++++++++-------- translations/fr/try_ruby_400.md | 30 +++++++----------- translations/fr/try_ruby_410.md | 36 ++++++++++----------- translations/fr/try_ruby_420.md | 30 +++++++++--------- translations/fr/try_ruby_430.md | 34 ++++++++++---------- translations/fr/try_ruby_440.md | 40 ++++++++++++------------ translations/fr/try_ruby_450.md | 38 +++++++++++------------ translations/fr/try_ruby_460.md | 46 +++++++++++++-------------- translations/fr/try_ruby_470.md | 14 ++++----- translations/fr/try_ruby_480.md | 27 ++++++++-------- translations/fr/try_ruby_490.md | 14 ++++----- translations/fr/try_ruby_50.md | 10 +++--- translations/fr/try_ruby_500.md | 23 +++++++------- translations/fr/try_ruby_510.md | 24 +++++++------- translations/fr/try_ruby_520.md | 25 +++++++-------- translations/fr/try_ruby_530.md | 36 ++++++++++----------- translations/fr/try_ruby_540.md | 28 +++++++---------- translations/fr/try_ruby_550.md | 55 +++++++++++++++++---------------- translations/fr/try_ruby_560.md | 33 +++++++++----------- translations/fr/try_ruby_60.md | 14 ++++----- translations/fr/try_ruby_70.md | 10 +++--- translations/fr/try_ruby_80.md | 14 ++++----- translations/fr/try_ruby_90.md | 34 ++++++++++---------- 51 files changed, 634 insertions(+), 613 deletions(-) diff --git a/README.md b/README.md index e68eaccf..37377210 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Ukrainian translation by [_Andrii Palchik_](https://github.com/andriipalchik) Macedonian translation by [_Violeta Pavleska_](https://github.com/violeta-p) Chinese translation by [_Ye Junzhe_](https://github.com/McF4r) & [_Bitfox_](https://github.com/bitfoxtop) & [_Heng Li_](https://github.com/iheng) Turkish translation by [_Ali Rıza Şahin_](https://github.com/ARS-coding) -French translation by _Olivier Lacan_ +French translation by [_Olivier Lacan_](https://github.com/olivierlacan) & [_Idris TAKERBOUST_](https://github.com/idrista) Suggestions to improve translations are welcome. If you submit a pull request updating a translation please diff --git a/source/about.html.markdown b/source/about.html.markdown index 7971078f..478a0aa3 100644 --- a/source/about.html.markdown +++ b/source/about.html.markdown @@ -52,6 +52,8 @@ Ukrainian translation by _Andrii Palchik_ Macedonian translation by _Violeta Pavleska_ Chinese translation by _Ye Junzhe_ & _Heng Li_ & _Bitfox_ Turkish translation by _Ali Rıza Şahin_ +French translation by _Olivier Lacan_ & _Idris TAKERBOUST_ + ### Privacy diff --git a/source/layouts/_navbar.html.erb b/source/layouts/_navbar.html.erb index ddd3f404..53fb16ce 100644 --- a/source/layouts/_navbar.html.erb +++ b/source/layouts/_navbar.html.erb @@ -139,6 +139,13 @@ > Türkçe + diff --git a/translations/fr/README.md b/translations/fr/README.md index 697db85e..01688464 100644 --- a/translations/fr/README.md +++ b/translations/fr/README.md @@ -1,5 +1,5 @@ ## Copyright (C) -Try Ruby version 4 French translation, 2018, _Olivier Lacan_ +Try Ruby version 4 French translation, 2018, _Olivier Lacan_, 2024, _Idris TAKERBOUST_ ## The MIT License Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/translations/fr/try_ruby_10.md b/translations/fr/try_ruby_10.md index 131aac34..46f7ad65 100644 --- a/translations/fr/try_ruby_10.md +++ b/translations/fr/try_ruby_10.md @@ -7,20 +7,17 @@ ok: error: --- -Ruby est un language de programmation originaire du Japon et qui a -revolutionné le développement logiciel. +Ruby est un language de programmation originaire du Japon qui a +révolutionné le développement logiciel. -La beauté de Ruby se situe dans sa balance entre simplicité et puissance. +La beauté de Ruby réside dans son équilibre entre simplicité et puissance. Tu peux saisir du code Ruby dans l'éditeur et utiliser les boutons suivants pour naviguer : -- __Run__ → Execute le code dans l'éditeur -- __Copy__ → Copie l'example de code dans l'éditeur -- __Next__ → Vous permet de sauter à la leçon suivante -- __Back__ → Vous permet de revenir à la leçon précédente -- __Clear__ → Remets l'éditeur à zéro +- __Run__ → Executer le code dans l'éditeur +- __Copy__ → Copier le code d'exemple dans l'éditeur +- __Next__ → Basculer à la leçon suivante +- __Back__ → Revenir à la leçon précédente -Utilise le bouton « planête » -ci-dessus pour changer le language de TryRuby. +
Clique sur Next pour commencer à apprendre.
-### Clique sur __Next__ pour commencer à apprendre. diff --git a/translations/fr/try_ruby_110.md b/translations/fr/try_ruby_110.md index a967a384..32f5f6d7 100644 --- a/translations/fr/try_ruby_110.md +++ b/translations/fr/try_ruby_110.md @@ -1,8 +1,8 @@ --- lang: FR -title: Les garçons sont différents des filles +title: Les pommes ne sont pas des oranges. answer: \[\] -ok: Bon, d'accord, voilà une liste vide. +ok: Parfait, voilà une liste vide. error: --- @@ -13,9 +13,9 @@ objet avec Ruby, certaines méthodes ne fonctionnent qu'avec certains types de choses. Mais il est toujours possible de passer d'un type à un autre avec les méthodes "to" to Ruby. -- __to_s__ convertit les choses en __s__trings +- __to_s__ convertit les choses en __s__trings (chaîne de caractères) - __to_i__ convertit les choses en __i__ntegers (nombres entiers) -- __to_a__ convertit les choses en __a__rrays +- __to_a__ convertit les choses en __a__rrays (listes / tableaux) __Qu'est-ce qu'un array ?!__ diff --git a/translations/fr/try_ruby_20.md b/translations/fr/try_ruby_20.md index 0020ddf4..9f76a9cf 100644 --- a/translations/fr/try_ruby_20.md +++ b/translations/fr/try_ruby_20.md @@ -1,19 +1,19 @@ --- -lang: EN -title: Using the editor +lang: FR +title: Utilisation de l'éditeur answer: ^\d{1,}$ -ok: Good! You did a bit of math. See how the answer popped out? -error: Type 2 + 6 in the editor +ok: Super ! Tu as fais un peu de maths. As-tu vu le résultat ? +error: Entre 2 + 6 dans l'éditeur --- -The editor window at the bottom is where you type your Ruby code, hit the __Run__ button and -watch it run! +L'éditeur est l'endroit où tu tapes ton code Ruby, appuie sur le bouton __Run__ +et regarde le s'exécuter ! -For example, try typing some math. Like: +Par exemple, essaie d'écrire des calculs. comme : 2 + 6 -The output of your program should show itself at the output window at the top. -There should also be a line that tells you how well you did. +La sortie de ton programme devrait s'afficher dans la fenêtre du bas. +Il devrait également y avoir une ligne qui te dit comment tu t'en sors. -> Alternatively you can hit the __Copy__ button to copy the example code to the editor. +> Autrement, tu peux appuyer sur le bouton __Copy__ pour copier le code d'exemple dans l'éditeur. diff --git a/translations/fr/try_ruby_200.md b/translations/fr/try_ruby_200.md index 9033f3d0..b14917b4 100644 --- a/translations/fr/try_ruby_200.md +++ b/translations/fr/try_ruby_200.md @@ -1,12 +1,12 @@ --- -lang: EN -title: Ready, Aim -answer: ^\n.ti tae ot (.+) +lang: FR +title: Prêt, Viser +answer: dnah ym morf nwolf sah tsaot yM load: prev -ok: Okay, sure. So the whole poem has been turned backwards. +ok: C'est plutôt logique. L'entièrement du poème a été inversé. error: --- -Here's a question: what happens when we reverse this whole poem? +Petite question : que se passe-t-il lorsque nous inversons entièrement "poem" (__poème__) ? poem.reverse diff --git a/translations/fr/try_ruby_210.md b/translations/fr/try_ruby_210.md index c819ace1..8d749c5b 100644 --- a/translations/fr/try_ruby_210.md +++ b/translations/fr/try_ruby_210.md @@ -1,17 +1,17 @@ --- -lang: EN -title: Too Much Reversal +lang: FR +title: Surplus d'inversion answer: ^\["More still did (.+) load: prev -ok: Yes, almost what we want +ok: Oui, c'est presque ce que nous voulons error: --- -So the whole poem's been turned backwards, letter-by-letter. I really wanted to just reverse the lines though. -Move the last line up to first and the first line down to last. +Tout le poème a donc été tourné à l'envers, lettre par lettre. Je voulais uniquement inverser les lignes. +Mettre la dernière ligne en première et la première ligne en dernière. -Backwards, but not __that__ backwards. +Inversé, mais pas __autant__ inversé. -Here's how: +Voici comment: poem.lines.reverse diff --git a/translations/fr/try_ruby_220.md b/translations/fr/try_ruby_220.md index e831019c..397d76c0 100644 --- a/translations/fr/try_ruby_220.md +++ b/translations/fr/try_ruby_220.md @@ -1,21 +1,21 @@ --- -lang: EN -title: Ringlets of Chained Methods -answer: ^More still did (.+) +lang: FR +title: Enchaînements de méthode en série +answer: My toast has flown from my hand load: prev -ok: Good show, my friend! The join method took that array of lines and put them together into a string. +ok: Bon travail, mon ami !
La méthode 'join' prend un liste (array) de chaîne de caractères (string) pour les a rassemblées en une seule string (chaîne de caractères). error: --- -So what do you see? What happened there? You typed __poem.lines.reverse__ and what happened? +Alors, qu'as-tu vu ? Qu'est-ce qui s'est passé là ? Tu as tapé __poem.lines.reverse__ et qu'est-ce qui s'est passé ? -Two things happened. You turned the poem into a list using lines. -Lines decides the way the string is split up and converts it into an Array. +Deux choses se sont produites. Tu as transformé le poème (__poem__) en une liste (__array__) en utilisant la méthode __lines__. +Lines décide de la manière dont la chaîne de caractères (__string__) est découpée et la convertit en un tableau (__array__). -Then, you reversed that list. You had each line. You reversed them. That's it. +Ensuite, tu as inversé (__reverse__) cette liste. Tu as pris chaque ligne et tu les as inversées. C'est tout. -Let's tack one more method on the end there: +Pour finir on à utilisé une autre méthode : puts poem.lines.reverse.join -Combining methods like this is called _method chaining_. \ No newline at end of file +Combiner des méthodes de cette manière s'appelle _l'enchaînement de méthodes (method chaining)_. \ No newline at end of file diff --git a/translations/fr/try_ruby_230.md b/translations/fr/try_ruby_230.md index 750633ab..68fb4f70 100644 --- a/translations/fr/try_ruby_230.md +++ b/translations/fr/try_ruby_230.md @@ -1,30 +1,28 @@ --- -lang: EN -title: Of All the Summaries, #3 is Here Now +lang: FR +title: De tous les résumés, #3 est là answer: \{\} class: stretcher chapmark load: prev -ok: You've made an empty hash ! -error: +ok: Tu as créé un hash vide ! +error: --- ### Exclamations -Methods may have exclamations (and also question marks) in their name. -These are just there to better explain what their function is. No big deal. +Les méthodes peuvent avoir des points d'exclamation (et aussi des points d'interrogation) dans leur nom. Ils sont juste là pour mieux expliquer quelle est leur fonction. Pas de problème. -### String manipulation -Search and change strings +### Manipulation de string +Recherche et modification de string -### Chaining -Chaining methods lets you get a lot more done. Break up a poem, reverse it, reassemble it: +### Enchaînement +L'enchaînement des méthodes vous permet de faire beaucoup plus de choses. Divisez un poème, inversez-le, réassemblez-le : __poem.lines.reverse.join__ -At this point, you may want to tinker with the poem a bit more. A complete list of all the String -methods is here. +À ce stade, vous pouvez vouloir bricoler un peu plus avec le poème. Une liste complète de toutes les méthodes de la classe String se trouve ici. -Go ahead and try a few, such as: poem.downcase or poem.swapcase +N'hésitez pas à essayer quelques-unes, comme : poem.downcase ou poem.swapcase -## Ready ? -When you feel ready to move on, type: +## Prêt ? +Quand tu te sens prêt à passer à autre chose, tape : - books = {} + livres = {} \ No newline at end of file diff --git a/translations/fr/try_ruby_240.md b/translations/fr/try_ruby_240.md index 3bb1fc32..bbc8cb29 100644 --- a/translations/fr/try_ruby_240.md +++ b/translations/fr/try_ruby_240.md @@ -1,27 +1,27 @@ --- -lang: EN -title: A Wee Blank Book -answer: ^(splendid|quite_good|mediocre|quite_not_good|abyssmal)$ -load: books = {} -ok: Yes that's a new review -error: Use one of splendid, quite_good, mediocre, quite_not_good, abyssmal. Don't forget the colon +lang: FR +title: La page blanche du livre +answer: ^(splendide|assez_bon|moyen|decu|catastrophique)$ +load: livres = {} +ok: Oui, c'est une nouvelle critique +error: Utilise l'un de ces mots splendide, assez_bon, moyen, decu, catastrophique.
N'oublie pas le deux-points (:). --- -You've made an empty __hash__. A hash is like an array, only every one of its elements has a name. +Tu as créé un __hash__ vide. Un hash est comme un tableau, sauf que chaque élément a un nom. -We're going to stuff some miniature book reviews in our new hash. Here's our rating system: +Nous allons mettre quelques critiques de livres dans notre nouveau hash. Voici notre système de notation : -- :splendid → a masterpiece -- :quite\_good → enjoyed, sure, yes -- :mediocre → equal parts great and terrible -- :quite\_not\_good → notably bad -- :abyssmal → steaming wreck +- :splendide → un chef-d'œuvre +- :assez_bon → apprécié, sûr, oui +- :moyen → ni bon, ni mauvais +- :decu → assez mauvais +- :catastrophique → un désastre fumant -To rate a book, put the title in square brackets and put the rating after the equals. For example: +Pour noter un livre, mets le titre entre crochets et mets la note après le signe égal. Par exemple : - books["Gravitys Rainbow"] = :splendid + livres["Harry Potter"] = :splendide -> By now I think it is only fair to tell you that all lessons in TryRuby are separate from each other. -> So if you go crazy typing book reviews here, you can only use 'em in this lesson. -> If you want to use your reviews in the next lesson you should copy/paste them. -> Don't worry about this too much, each lesson has plenty of predefined stuff for you to play around with. +> À ce stade, je pense qu'il est juste de te dire que toutes les leçons de TryRuby sont indépendantes les unes des autres. +> Donc, si tu deviens fou à taper des critiques de livres ici, tu ne pourras les utiliser que dans cette leçon. +> Si tu veux utiliser tes critiques dans la prochaine leçon, tu devrais les copier/coller. +> Ne t'inquiète pas trop à ce sujet, chaque leçon a plein de trucs prédéfinis pour que tu puisses jouer avec. \ No newline at end of file diff --git a/translations/fr/try_ruby_250.md b/translations/fr/try_ruby_250.md index 3b5c6b05..cbeafcde 100644 --- a/translations/fr/try_ruby_250.md +++ b/translations/fr/try_ruby_250.md @@ -1,28 +1,27 @@ --- -lang: EN -title: More Bite-Size Reviews +lang: FR +title: Encore plus de critiques answer: [3-9] -load: books = {"Gravitys Rainbow" => :splendid} -ok: See, the length method works on strings, array's and hashes. +load: livres = {"Harry Potter" => :splendide} +ok: See, the length method works on strings, arrays and hashes. error: --- -Keep going, fill it up with reviews. And, if you want to see the whole list, just type: __puts books__ +Continuons, remplis des critiques. Et si tu veux voir toute la liste, il te suffit de taper : __puts livres__ -Again, the ratings are: :splendid, :quite\_good, :mediocre, :quite\_not\_good and :abyssmal. +Encore une fois, les notations sont : :splendide, :assez_bon, :moyen, :decu, :catastrophique -These ratings are not strings. When you place a colon in front of a simple word, you get a __symbol__. -Symbols are cheaper than strings (in terms of computer memory.) If you use a word over and over in your program, -use a symbol. Rather than having thousands of copies of that word in memory, the computer will store the symbol only -__once__. +Ces notations ne sont pas des strings. Lorsque tu places un deux-points devant un mot simple, tu obtiens un __symbole__. +Les symboles sont moins coûteux en mémoire que les chaînes de caractères. Si tu utilises un mot encore et encore dans ton programme, +utilise un symbole. Plutôt que d'avoir des milliers de copies de ce mot en mémoire, l'ordinateur ne stockera le symbole qu'une seule fois. -More importantly, a symbol tells you that is not just any old word but has a meaning within your program. +Plus important encore, un symbole te dit que ce n'est pas juste un mot ordinaire mais qu'il a une signification dans ton programme. -Enter 2 more bookreviews, use __books.length__ to see how many reviews there are in the hash: +Ajoute encore 2 critiques de livres, utilise __livres.length__ pour voir combien de critiques il y a dans le hash : - books["The deep end"] = :abyssmal - books["Living colors"] = :mediocre + livres["The deep end"] = :catastrophique + livres["Living colors"] = :moyen - puts books + puts livres - puts books.length + puts livres.length diff --git a/translations/fr/try_ruby_260.md b/translations/fr/try_ruby_260.md index 5bb17c7e..b0a5ef74 100644 --- a/translations/fr/try_ruby_260.md +++ b/translations/fr/try_ruby_260.md @@ -1,20 +1,20 @@ --- -lang: EN -title: Wait, Did I Like Gravity's Rainbow? -answer: ^(splendid|quite_good|mediocre|quite_not_good|abyssmal)$ -load: books = {"Gravitys Rainbow" => :splendid, "The deep end" => :abyssmal, "Living colors" => :mediocre} -ok: I liked it a lot +lang: FR +title: Attends, ai-je aimé Harry Potter ? +answer: ^(splendide|assez_bon|moyen|decu|catastrophique)$ +load: livres = {"Harry Potter"=>:splendide, "The deep end"=>:catastrophique, "Living colors"=>:moyen} +ok: J'ai beaucoup aimé error: --- -One great thing about Ruby is that names are often reused, which means fewer names you need to remember. +Une des grandes choses à propos de Ruby est que les noms sont souvent réutilisés, ce qui signifie moins de noms à retenir. -Remember how we retrieved items from an array using a number: +Tu te souviens comment nous avons récupéré des éléments d'un array en utilisant un nombre : __puts ticket[1]__. -For a hash this works the same way, except we don't use a number to get an element but a name. +Pour un hash, ça fonctionne de la même manière, sauf que nous n'utilisons pas un nombre pour obtenir un élément mais un nom. -So, if you'd like to look up one of your old reviews, again put the title in the square. But leave off the equals. -Just like this: +Donc, si tu veux rechercher une de tes anciennes critiques, mets à nouveau le titre entre crochets. Mais ne mets pas le signe égal (=). +Comme ceci : - puts books["Gravitys Rainbow"] + puts livres["Harry Potter"] \ No newline at end of file diff --git a/translations/fr/try_ruby_270.md b/translations/fr/try_ruby_270.md index 11f43c99..23a3437f 100644 --- a/translations/fr/try_ruby_270.md +++ b/translations/fr/try_ruby_270.md @@ -1,19 +1,19 @@ --- -lang: EN -title: Hashes as Pairs +lang: FR +title: Les Hashs vont de paires answer: ^\[".*"\] load: prev -ok: You found the keys +ok: Tu as trouvé les clés error: --- -Keep in mind that hashes won't keep things in order. That's not their job. It'll just pair up -two things: a __key__ and a __value__. +Garde à l'esprit que les hashes ne conservent pas les choses dans l'ordre. Ce n'est pas leur rôle. Ils associent simplement +deux choses : une clé (__key__) et une valeur (__value__). -In your reviews, the book's title is the key and the rating is the value. +Dans tes critiques, le titre du livre est la clé et la notation est la valeur. -If you want to just see the titles of all the books you've reviewed: +Si tu veux simplement voir les titres de tous les livres que tu as critiqués : - books.keys + livres.keys -You can also try this with .values instead of .keys. \ No newline at end of file +Tu peux aussi essayer cela avec .values au lieu de .keys. \ No newline at end of file diff --git a/translations/fr/try_ruby_280.md b/translations/fr/try_ruby_280.md index edee0dba..b04e33ec 100644 --- a/translations/fr/try_ruby_280.md +++ b/translations/fr/try_ruby_280.md @@ -1,27 +1,26 @@ --- -lang: EN -title: Are You Harsh? -answer: "mediocre" -load: books = {"Gravitys Rainbow" => :splendid, "The deep end" => :abyssmal, "Living colors" => :mediocre, "Bumblebees" => :mediocre} -ok: Great, wow! You've made a scorecard of your ratings +lang: FR +title: Es-tu sévère ? +answer: :moyen +load: livres = {"Harry Potter"=>:splendide, "The deep end"=>:catastrophique, "Living colors"=>:moyen} +ok: Génial, wow ! Tu as fait une feuille de notation de tes évaluations error: --- -So are you giving out harsh, unfair reviews? Let's keep score with a new hash __ratings__: +Alors, tu donnes des critiques sévères et injustes ? Gardons une trace avec un nouveau hash __notations__ : -Then, okay, now let's count up your reviews. Just stay with me. Type: +Desormais, nous allons compter tes critiques. Reste avec moi. Écris : - ratings = Hash.new {0} + notations = Hash.new {0} - books.values.each { |rate| - ratings[rate] += 1 + livres.values.each { |note| + notations[note] += 1 } - puts ratings + puts notations -The straight line in the code is the pipe character, probably located right above the Enter key -on your keyboard. +La trait droite dans le code est le caractère pipe (|), probablement situé juste au-dessus de la touche 'T' OU 'Y' d'un clavier Windows Français. -That _+= 1_ line means: increase the value by 1. +Le _+= 1_ signifie : augmenter la valeur de 1. -Don't worry if you don't understand everything that is going on here. It will be revealed later. +Ne t'inquiète pas si tu ne comprends pas tout ce qui se passe ici. Tout sera expliqué plus tard. \ No newline at end of file diff --git a/translations/fr/try_ruby_290.md b/translations/fr/try_ruby_290.md index e41cd742..cf4c45ce 100644 --- a/translations/fr/try_ruby_290.md +++ b/translations/fr/try_ruby_290.md @@ -1,18 +1,15 @@ --- -lang: EN -title: A Tally +lang: FR +title: Un décompte answer: \w+ -ok: Yodelay! +ok: Houra! error: --- -One of the amazing new things we've just used is a __block__. We're going to explore these more -in this and the next lesson. But, basically, a block is a bit of Ruby code surrounded by curly -braces. +Une des choses étonnantes que nous venons d'utiliser est un bloc (__block__). Nous allons explorer cela plus en détail dans cette leçon et celle à venir. Mais, en gros, un bloc est un morceau de code Ruby entouré d'accolades '{' '}'. -Let's try another block: +Essayons un autre bloc : - 5.times { print "Odelay! " } + 3.times { print "Hip! " } -Blocks are always attached to methods. Like the __times__ method, which takes the block and runs -the code over and over. (In our example: five times.) \ No newline at end of file +Les blocs sont toujours attachés à des méthodes. Comme la méthode __times__, qui prend le bloc et exécute le code à plusieurs reprises. (Dans notre exemple : trois fois.) \ No newline at end of file diff --git a/translations/fr/try_ruby_30.md b/translations/fr/try_ruby_30.md index a504f1c7..5defc8bf 100644 --- a/translations/fr/try_ruby_30.md +++ b/translations/fr/try_ruby_30.md @@ -1,12 +1,12 @@ --- -lang: EN -title: Numbers and Math +lang: FR +title: Nombres et Mathématiques answer: ^[0-9\.,-]{1,}$ -ok: Good +ok: Parfait error: --- -Ruby recognizes numbers and mathematic symbols. You could try some other math like: +Ruby reconnaît les nombres et les symboles mathématiques. Tu peux essayer d'autres opérations mathématiques comme : 4 * 10 5 - 12 diff --git a/translations/fr/try_ruby_300.md b/translations/fr/try_ruby_300.md index 59198554..c0256ca3 100644 --- a/translations/fr/try_ruby_300.md +++ b/translations/fr/try_ruby_300.md @@ -1,23 +1,21 @@ --- -lang: EN -title: Have you got the time? +lang: FR +title: Tu as le 'time' ? answer: ^[0-9]$ -ok: You timed it just right! -error: Run the block 0 to 9 times +ok: Tu es parfaitement synchronisé ! +error: Lance le bloc de 0 à 9 fois --- -As we saw in the first example with a block (when counting ratings) we can pass a value to the block. Which -values are __passed__ is determined by the method that is running the block. +Comme nous l'avons vu dans le premier exemple avec un bloc (lors du décompte des notations), nous pouvons passer une valeur au bloc. Les valeurs qui sont __passées__ sont déterminées par la méthode qui exécute le bloc. -The values that are __received__ by the block are placed in the variable name at the beginning of the block, -between two pipe symbols: | +Les valeurs qui sont __reçues__ par le bloc sont placées dans la variable entre les deux symboles pipe au début du bloc : | -Let's try that with this block: +Essayons ça avec ce bloc : 5.times { |time| puts time } -Here, method __.times__ sends a value to variable __|time|__. But note that variable time is only known within the block. +Ici, la méthode __.times__ envoie une valeur à la variable __|time|__. Mais note que la variable time est uniquement connue à l'intérieur du bloc. -> Did you notice that you can split code over multiple lines. This makes it a bit easier to read. +> As-tu remarqué que tu peux répartir le code sur plusieurs lignes ? Cela rend la lecture un peu plus facile. \ No newline at end of file diff --git a/translations/fr/try_ruby_310.md b/translations/fr/try_ruby_310.md index b3bcd239..5fd6882b 100644 --- a/translations/fr/try_ruby_310.md +++ b/translations/fr/try_ruby_310.md @@ -1,24 +1,23 @@ --- -lang: EN -title: Now Arriving at Summary #4 +lang: FR +title: Nous arrivons au resumé #4 answer: class: stretcher chapmark ok: error: --- -This last lesson was a bit longer. You've probably used up three minutes learning about: +Cette dernière leçon était un peu plus longue. Tu as probablement utilisé environ trois minutes pour apprendre sur : ### Hashes -The little dictionary with the curly pages: __{}__ +Le petit dictionnaire avec les pages en boucle : __{}__ ### Symbols -Tiny, efficient code words with a colon, like: __:splendid__ +De petits mots de code efficaces avec un deux-points, comme : __:splendide__ ### Blocks -Chunks of code which can be tacked on to many of Ruby's methods. Here's the code you used to -build a scorecard: -__books.values.each { |rate| ratings[rate] += 1 }__ +Des morceaux de code qui peuvent être ajoutés à de nombreuses méthodes de Ruby. Voici le code que tu as utilisé pour construire une feuille de notation : +__livres.values.each { |note| notations[note] += 1 }__ -### Next -In the next lesson we will delve al little bit deeper into methods. +### La suite +Dans la prochaine leçon, nous plongerons un peu plus profondément dans les méthodes. \ No newline at end of file diff --git a/translations/fr/try_ruby_320.md b/translations/fr/try_ruby_320.md index 7e67a5e7..90d3eab4 100644 --- a/translations/fr/try_ruby_320.md +++ b/translations/fr/try_ruby_320.md @@ -1,38 +1,38 @@ --- lang: EN -title: To (be) or not to (be) -answer: +title: Être ou ne pas être +answer: load: poem = "My toast has flown from my hand\nAnd my toast has gone to the moon.\nYada yada yada\n" -ok: -error: +ok: +error: --- -One other little thing we haven't really talked about openly: method arguments. -Remember when we changed the poem a little bit ? We used: +Une autre petite chose que nous n'avons pas vraiment abordée ouvertement : les arguments/paramètres de méthode. +Tu te souviens quand nous avons modifié un peu le poème ? Nous avons utilisé : __poem.gsub("toast", "honeydew")__ - -The gsub method needs 2 arguments, which we passed to gsub by including two strings between -parenthesis. _Arguments tell the method exactly what to do._ -### Parenthesis -Actually, most of the time Ruby doesn't mind if you omit the parenthesis. So this would have -worked too: +La méthode gsub a besoin de 2 arguments, que nous avons passés à gsub en incluant deux strings entre +parenthèses. _Les arguments disent à la méthode exactement quoi faire_. + +### Parenthèses +En fait, la plupart du temps, Ruby n'est pas dérangé si tu ommets les parenthèses. Donc, cela aurait +également fonctionné : __poem.gsub "toast", "honeydew"__ -We have already used another method with a parameter. Many times in fact, though it was not very -obvious: +Finalement, nous avons déjà utilisé une autre méthode avec un seul paramètre. Beaucoup de fois en fait, même si ce n'était pas très +évident : puts "Hello" puts("Hello") - -Yes __puts__ is also a method. Using puts with or without parenthesis is the same to Ruby, but the -version without parenthesis is a bit easier to read. And it saves you valuable typing time ! -> So I guess the conclusion is that you can do whatever you like with parenthesis as long as your -> code reads nicely. +Oui, __puts__ est aussi une méthode. Utiliser puts avec ou sans parenthèses est la même chose pour Ruby, mais la +version sans parenthèses est un peu plus facile à lire. Et cela vous fait gagner du temps de frappe précieux ! + +> Du coup, on peut supposer que la conclusion est que tu peux faire ce que tu veux avec les parenthèses tant que ton +> code est lisible. -### to (be) or not to (be) -So if _to_ is a method and _be_ is an argument we now know the answer to this age old question. -It is really just a matter of preference whether you want _to be_ or _to(be)_. +### Être ou ne pas être +Donc, si _to_ est une méthode et _be_ est un argument, nous connaissons maintenant la réponse à cette question ancienne. +C'est vraiment juste une question de préférence si tu veux _to be_ ou _to(be)_. -Are you in the mood for more Shakespeare ? Read on. +As-tu envie de plus de Shakespeare ? Lisons. \ No newline at end of file diff --git a/translations/fr/try_ruby_330.md b/translations/fr/try_ruby_330.md index 1b1638ab..fb01d446 100644 --- a/translations/fr/try_ruby_330.md +++ b/translations/fr/try_ruby_330.md @@ -1,33 +1,33 @@ --- -lang: EN -title: The Taming of the Shrew +lang: FR +title: La Mégère apprivoisée answer: ^tame -ok: Good good ! -error: +ok: Bien bien ! +error: --- -You totally know how to use Ruby now. I mean you've got down the essentials. -You just need to keep learning more methods and try out more complex blocks. +Tu sais parfaitement comment utiliser Ruby maintenant. Je veux dire, tu as maîtrisé les bases. +Il te suffit simplement d'apprendre plus de méthodes et d'essayer des blocs plus complexes. -But there's one side of Ruby we haven't settled. Making your own methods. -__Ahem!__ Let's get it over with then. +Mais il y a un côté de Ruby que nous n'avons pas encore abordé. Créer tes propres méthodes. +__Hum !__ Allons-y alors. -Next to using Ruby's built in methods (like puts, sort, times) you can define -your own methods. Why is that a good idea? Two reasons: +En plus d'utiliser les méthodes intégrées de Ruby (comme puts, sort, times), tu peux définir +tes propres méthodes. Pourquoi est-ce une bonne idée ? Deux raisons : -### To make your program shorter -If you have to do the same thing in more than one part of your code it is easier -to put that code in a separate method. Your code will be shorter. +### Pour rendre ton programme plus court +Si tu dois faire la même chose à plusieurs endroits de ton code, il est plus facile +de mettre ce code dans une méthode séparée. Ton code sera plus court. -### To make your code easier to read -Suppose your program needs to do a lot of different things. -You __could__ stuff all code into one long piece. But it would be very difficult to -read and understand that code later. +### Pour rendre ton code plus facile à lire +Suppose que ton programme doit faire beaucoup de choses différentes. +Tu __pourrais__ tout entasser dans un seul long morceau de code. Mais il serait très difficile de +lire et comprendre ce code plus tard. -Instead you should cut up your code in different methods and give each method an easy to -understand English name. You will thank yourself later. +Au lieu de cela, tu devrais découper ton code en différentes méthodes et donner à chaque méthode un nom en anglais facile à +comprendre. Tu te remercieras plus tard. -So how do we define a method ? Like this: +Alors comment définissons-nous une méthode ? Comme ceci : def tame( number_of_shrews ) end diff --git a/translations/fr/try_ruby_340.md b/translations/fr/try_ruby_340.md index 0da857a1..34366f17 100644 --- a/translations/fr/try_ruby_340.md +++ b/translations/fr/try_ruby_340.md @@ -1,24 +1,24 @@ --- -lang: EN -title: In Ruby, Def Leppard means: define method Leppard +lang: FR +title: En Ruby, "Def Leppard" signifie: definir la méthode Leppard answer: ^tame -ok: Tame is not lame +ok: Apprivoiser n'est pas ennuyeux error: --- -Hey, okay, you done it. You're making your own method. You started with def, followed by the name of the method. -And a list of arguments which the method will need. This isn't too scary and dangerous! -All we have to do is fill it up with Ruby and finish it up with end. +Eh bien, d'accord, dans ce cas faissons le. Crées ta propre méthode eb commencant par __def__, suivi du nom de la méthode. +Puis une liste d'arguments dont la méthode aura besoin. Ce n'est pas trop effrayant et dangereux ! +Tout ce que nous avons à faire, c'est de la remplir avec du Ruby et de terminer avec __end__. + +Voici le code : -Here's the code: - def tame( number_of_shrews ) number_of_shrews.times { puts "Tamed a shrew" } end - + > __P.S.__ -> If you don't get the title of this chapter. +> Si tu ne comprends pas le titre de ce chapitre. > Def Leppard -> is the name of a, once famous, English rock band. +> est le nom d'un, autrefois célèbre, groupe de rock anglais. diff --git a/translations/fr/try_ruby_350.md b/translations/fr/try_ruby_350.md index 8d88d089..48df5818 100644 --- a/translations/fr/try_ruby_350.md +++ b/translations/fr/try_ruby_350.md @@ -1,12 +1,15 @@ --- -lang: EN -title: The Ripened Fruit of Your Own Creation +lang: FR +title: Le fruit mûr de ta création answer: ^Tamed a shrew -ok: That'll show those shrews +ok: Ça leur apprendra, ces mégères (shrew) error: load: def tame(number_of_shrews);number_of_shrews.times{puts "Tamed a shrew"};end; --- -A new method is born. Let us use it now: +Un nouveau méthode est née. Utilisons-la maintenant : tame 5 + +> __P.S.__ +> Tamed a shrew = Mégère apprivoisée \ No newline at end of file diff --git a/translations/fr/try_ruby_360.md b/translations/fr/try_ruby_360.md index a2b3d9d5..c481b288 100644 --- a/translations/fr/try_ruby_360.md +++ b/translations/fr/try_ruby_360.md @@ -1,13 +1,13 @@ --- -lang: EN -title: Give and take +lang: FR +title: Donner et prendre answer: \d+ -ok: Right on. Bravo. -error: +ok: Exactement. Bravo. +error: --- -Most methods do not only want some parameters as input, but will also __give something back__. -I have changed our method a bit so it will return a value to you. Try it: +La plupart des méthodes ne veulent pas uniquement quelques paramètres en entrée, mais elles peuvent aussi __donner quelque chose en retour__. +J'ai un peu modifié notre méthode pour qu'elle te retourne (__return__) une valeur. Essaie-la : def tame( number_of_shrews ) number_of_shrews.times { @@ -15,15 +15,15 @@ I have changed our method a bit so it will return a value to you. Try it: } return number_of_shrews end - + puts tame(3) ### Return -And, since you're getting so advanced and capable here, one other tip: -you can omit the word __return__ from the last line of the method. -Ruby will automagically return the last value that was used inside the method. +Et, puisque tu deviens si avancé et compétent ici, un autre conseil : +tu peux omettre le mot __return__ de la dernière ligne de la méthode. +Ruby retournera automatiquement la dernière valeur qui a été utilisée à l'intérieur de la méthode. -So we can change the last line to just: __number\_of\_shrews__. +Donc, nous pouvons changer la dernière ligne en juste : __number\_of\_shrews__. -But since method __.times__ also returns the _number\_of\_shrews_ we can -remove the entire last line. So in fact our original method already did what we wanted all along ! +Mais puisque la méthode __.times__ renvoie également le _number\_of\_shrews_, nous pouvons +supprimer toute la dernière ligne. En fait, notre méthode originale faisait déjà ce que nous voulions depuis le début ! \ No newline at end of file diff --git a/translations/fr/try_ruby_370.md b/translations/fr/try_ruby_370.md index 8098d3d5..74709d5b 100644 --- a/translations/fr/try_ruby_370.md +++ b/translations/fr/try_ruby_370.md @@ -1,27 +1,27 @@ --- -lang: EN -title: Hello, Who's There? And Summary #5 Waves Its Hat! -answer: +lang: FR +title: Bonjour, Qui est là ? Le résumé #5 fait signe de son chapeau ! +answer: class: stretcher chapmark -ok: -error: +ok: +error: --- -Well done, well done, well done, well done! +Bien joué, bien joué, bien joué, bien joué ! -Truly, truly, truly, truly, truuuuuuuuly! +Vraiment, vraiment, vraiment, vraiment, vraiiiiiiiiiment ! -Here's the last few minutes of your life in review: +Voici les dernières minutes de ta vie en revue : -### Methods -Methods can be defined with __def__ and have a name. Methods make your program shorter -and easier to read. +### Méthodes +Les méthodes peuvent être définies avec __def__ et ont un nom. Les méthodes rendent ton programme plus court +et plus facile à lire. -### Parameters -Methods can have parameters. +### Paramètres +Les méthodes peuvent avoir des paramètres. -### Return values -Methods (almost) always return a value. +### Valeurs de retour +Les méthodes (presque toujours) retournent une valeur. -## Now -To (be) or not to (be) is not a question to you anymore. Are you ready for some more Shakespeare ? +## Et Maintenant ? +Être ou ne pas être n'est plus une question pour toi. Es-tu prêt pour un peu plus de Shakespeare ? \ No newline at end of file diff --git a/translations/fr/try_ruby_380.md b/translations/fr/try_ruby_380.md index 88909568..1ee0ca79 100644 --- a/translations/fr/try_ruby_380.md +++ b/translations/fr/try_ruby_380.md @@ -1,33 +1,28 @@ --- -lang: EN -title: The world is our oyster +lang: FR +title: Le monde nous appartient answer: ^\{\"William -ok: Good. Bit difficult to read. +ok: Super. mais difficile a lire. error: -load: def get_shakey;JSON.parse("{\"William Shakespeare\": {\"1\": {\"title\": \"The Two Gentlemen of Verona\", \"finished\": 1591},\"2\": {\"title\": \"The Taming of the Shrew\", \"finished\": 1591},\"3\": {\"title\": \"Henry VI, Part 2\", \"finished\": 1591},\"4\": {\"title\": \"Henry VI, Part 3\", \"finished\": 1591},\"5\": {\"title\": \"Henry VI, Part 1\", \"finished\": 1592},\"6\": {\"title\": \"Titus Andronicus\", \"finished\": 1592},\"7\": {\"title\": \"Richard III\", \"finished\": 1593},\"8\": {\"title\": \"Edward III\", \"finished\": 1593},\"9\": {\"title\": \"The Comedy of Errors\", \"finished\": 1594},\"10\": {\"title\": \"Love's Labour's Lost\", \"finished\": 1595},\"11\": {\"title\": \"Love's Labour's Won\", \"finished\": 1596},\"12\": {\"title\": \"Richard II\", \"finished\": 1595},\"13\": {\"title\": \"Romeo and Juliet\", \"finished\": 1595},\"14\": {\"title\": \"A Midsummer Night's Dream\", \"finished\": 1595},\"15\": {\"title\": \"King John\", \"finished\": 1596},\"16\": {\"title\": \"The Merchant of Venice\", \"finished\": 1597},\"17\": {\"title\": \"Henry IV, Part 1\", \"finished\": 1597},\"18\": {\"title\": \"The Merry Wives of Windsor\", \"finished\": 1597},\"19\": {\"title\": \"Henry IV, Part 2\", \"finished\": 1598},\"20\": {\"title\": \"Much Ado About Nothing\", \"finished\": 1599},\"21\": {\"title\": \"Henry V\", \"finished\": 1599},\"22\": {\"title\": \"Julius Caesar\", \"finished\": 1599},\"23\": {\"title\": \"As You Like It\", \"finished\": 1600},\"24\": {\"title\": \"Hamlet\", \"finished\": 1601},\"25\": {\"title\": \"Twelfth Night\", \"finished\": 1601},\"26\": {\"title\": \"Troilus and Cressida\", \"finished\": 1602},\"27\": {\"title\": \"Sir Thomas More\", \"finished\": 1604},\"28\": {\"title\": \"Measure for Measure\", \"finished\": 1604},\"29\": {\"title\": \"Othello\", \"finished\": 1604},\"30\": {\"title\": \"All's Well That Ends Well\", \"finished\": 1605},\"31\": {\"title\": \"King Lear\", \"finished\": 1606},\"32\": {\"title\": \"Timon of Athens\", \"finished\": 1606},\"33\": {\"title\": \"Macbeth\", \"finished\": 1606},\"34\": {\"title\": \"Antony and Cleopatra\", \"finished\": 1606},\"35\": {\"title\": \"Pericles, Prince of Tyre\", \"finished\": 1608},\"36\": {\"title\": \"Coriolanus\", \"finished\": 1608},\"37\": {\"title\": \"The Winter's Tale\", \"finished\": 1611},\"38\": {\"title\": \"Cymbeline\", \"finished\": 1610},\"39\": {\"title\": \"The Tempest\", \"finished\": 1611},\"40\": {\"title\": \"Cardenio\", \"finished\": 1613},\"41\": {\"title\": \"Henry VIII\", \"finished\": 1613},\"42\": {\"title\": \"The Two Noble Kinsmen\", \"finished\": 1614}}}");end; +load: def get_shakey; {"William Shakespeare"=>{"1"=>{"title"=>"The Two Gentlemen of Verona", "finished"=>1591},"2"=>{"title"=>"The Taming of the Shrew", "finished"=>1591},"3"=>{"title"=>"Henry VI, Part 2", "finished"=>1591},"4"=>{"title"=>"Henry VI, Part 3", "finished"=>1591},"5"=>{"title"=>"Henry VI, Part 1", "finished"=>1592},"6"=>{"title"=>"Titus Andronicus", "finished"=>1592},"7"=>{"title"=>"Richard III", "finished"=>1593},"8"=>{"title"=>"Edward III", "finished"=>1593},"9"=>{"title"=>"The Comedy of Errors", "finished"=>1594},"10"=>{"title"=>"Love's Labour's Lost", "finished"=>1595},"11"=>{"title"=>"Love's Labour's Won", "finished"=>1596},"12"=>{"title"=>"Richard II", "finished"=>1595},"13"=>{"title"=>"Romeo and Juliet", "finished"=>1595},"14"=>{"title"=>"A Midsummer Night's Dream", "finished"=>1595},"15"=>{"title"=>"King John", "finished"=>1596},"16"=>{"title"=>"The Merchant of Venice", "finished"=>1597},"17"=>{"title"=>"Henry IV, Part 1", "finished"=>1597},"18"=>{"title"=>"The Merry Wives of Windsor", "finished"=>1597},"19"=>{"title"=>"Henry IV, Part 2", "finished"=>1598},"20"=>{"title"=>"Much Ado About Nothing", "finished"=>1599},"21"=>{"title"=>"Henry V", "finished"=>1599},"22"=>{"title"=>"Julius Caesar", "finished"=>1599},"23"=>{"title"=>"As You Like It", "finished"=>1600},"24"=>{"title"=>"Hamlet", "finished"=>1601},"25"=>{"title"=>"Twelfth Night", "finished"=>1601},"26"=>{"title"=>"Troilus and Cressida", "finished"=>1602},"27"=>{"title"=>"Sir Thomas More", "finished"=>1604},"28"=>{"title"=>"Measure for Measure", "finished"=>1604},"29"=>{"title"=>"Othello", "finished"=>1604},"30"=>{"title"=>"All's Well That Ends Well", "finished"=>1605},"31"=>{"title"=>"King Lear", "finished"=>1606},"32"=>{"title"=>"Timon of Athens", "finished"=>1606},"33"=>{"title"=>"Macbeth", "finished"=>1606},"34"=>{"title"=>"Antony and Cleopatra", "finished"=>1606},"35"=>{"title"=>"Pericles, Prince of Tyre", "finished"=>1608},"36"=>{"title"=>"Coriolanus", "finished"=>1608},"37"=>{"title"=>"The Winter's Tale", "finished"=>1611},"38"=>{"title"=>"Cymbeline", "finished"=>1610},"39"=>{"title"=>"The Tempest", "finished"=>1611},"40"=>{"title"=>"Cardenio", "finished"=>1613},"41"=>{"title"=>"Henry VIII", "finished"=>1613},"42"=>{"title"=>"The Two Noble Kinsmen", "finished"=>1614}}}; end; --- -So far we have been running programs that only use things that we have typed ourselves. -Which is nice, I mean that _Odelaying_ was epic, but this the internet era so it is about -time we included the rest of the world in our programming efforts. +Jusqu'à présent, nous avons exécuté des programmes qui n'utilisent que ce que nous avons écris nous-mêmes. +Ce qui est bien, je veux dire que le _Hip, hip houra !_ était épique, mais nous sommes à l'ère d'Internet, donc il est temps d'inclure le reste du monde dans nos efforts de programmation. -Many, many, many websites are available that you can ask for information. For instance -this link will give you all current Google news feeds -about Ruby. +De nombreux, nombreux sites Web sont disponibles où tu peux demander des informations. Par exemple, ce lien te donnera tous les flux d'actualités Google sur Ruby. -Your web browser will probably display it quite nicely for you. If you look at the source -(type: control-U) you will see a long string of strangely formatted text. In the Google example -it is in the __rss__ format. +Ton navigateur Web l'affichera probablement très bien pour toi. Si tu regardes le code source (tape : contrôle-U), tu verras une longue chaîne de texte étrangement formatée. Dans l'exemple de Google, c'est au format __rss__. ### Formats -There are many other formats, with strange names, available and used on the web, like: -html, xml and json. Yes, even this very website uses a couple of these. +Il existe de nombreux autres formats, avec des noms étranges, disponibles et utilisés sur le Web, comme : +html, xml et json. Oui, même ce site Web utilise quelques-uns de ces formats. -I have prepared a method for you that will fetch a list of the complete works of William -Shakespeare from the internet. -(Don't worry it actually comes from the same server that this website runs on, so -we're not bothering anyone.) +J'ai préparé une méthode pour toi qui récupérera une liste des œuvres complètes de William +Shakespeare depuis Internet. +(Ne t'inquiète pas, cela provient en fait du même serveur sur lequel ce site Web fonctionne, donc +nous ne dérangeons personne.) -Get the data with: +Obtiens les données avec : - get_shakey + get_shakey \ No newline at end of file diff --git a/translations/fr/try_ruby_390.md b/translations/fr/try_ruby_390.md index f6872930..74779d54 100644 --- a/translations/fr/try_ruby_390.md +++ b/translations/fr/try_ruby_390.md @@ -1,8 +1,8 @@ ---- -lang: EN +œ--- +lang: FR title: Noble Kinsmen answer: ^The Two Noble Kinsmen$ -ok: That's much better +ok: C'est bien mieux error: load: prev --- @@ -38,7 +38,7 @@ Looks like this: -To list the plays we first have to access the top "William Shakespeare" hash element by it's name. +To list the plays we first have to access the top "William Shakespeare" hash element by its name. Next we have to __iterate__ through each element below it. Ruby has a method for iterating. It is called __each__. We have seen it before when @@ -51,3 +51,49 @@ Everything that method __each__ returns is passed to a block: s["William Shakespeare"].each { |key, val| puts val["title"] } + + +Bien, maintenant nous avons une liste de pièces de théâtre provenant d'Internet. La liste est au format json. +Heureusement pour nous, Ruby fournit gentiment une méthode pour convertir les données json en un hash Ruby. +La méthode _get\_shakey_ l'a déjà fait pour nous. + +Mais comme la structure des données json est conservée dans le hash, il est encore un peu difficile à lire. +Écrivons une méthode pour afficher tout ça de manière agréable. + +Si tu inspectes attentivement la liste de pièces de théâtre, tu verras qu'elle a une sorte de structure imbriquée. +(C'est en fait assez courant dans les données que tu obtiens d'Internet.) +Ça ressemble à ça : + + + +Pour lister les pièces de théâtre, nous devons d'abord accéder à au premier l'élément du hash "William Shakespeare" par son nom. +Ensuite, nous devons __itérer__ à travers chaque élément suivant. + +Ruby a une méthode pour itérer. Elle s'appelle __each__. Nous l'avons déjà vue lorsque nous avons +créé notre système de notation des livres. + +Tout ce que la méthode __each__ retourne est passé à un bloc : + + s = get_shakey + + s["William Shakespeare"].each { |key, val| + puts val["title"] + } \ No newline at end of file diff --git a/translations/fr/try_ruby_40.md b/translations/fr/try_ruby_40.md index 106ca039..6b5ef48b 100644 --- a/translations/fr/try_ruby_40.md +++ b/translations/fr/try_ruby_40.md @@ -1,27 +1,27 @@ --- -lang: EN -title: Putting it differently +lang: FR +title: Afficher les choses autrement answer: ^[0-9\.,-]{1,}$ -ok: Well put +ok: Bien affiché error: --- -Did you notice that if you typed more than one formula you only saw the answer for the last one. -What is going on ? +As-tu remarqué que si tu écris plus d'une formule, tu n'as que la dernière réponse. +Comment ça se fait ? -> To make this website easier to use I have told Ruby to copy the result of your program to the -> output screen at the top. So when you type a formula you get to see the results. -> __But only the last result.__ And only if the output is still empty. +> Pour rendre ce site web simple à utiliser, j'ai demandé à Ruby de copier le résultat de ton programme dans la fenêtre de sortie. +> Donc, lorsque tu écris une formule, tu peux voir les résultats. +> __Mais seulement le dernier résultat.__ Et seulement si la sortie est encore vide. -So when you entered 2 or more formula's, Ruby only showed the result of the last formula. +Du coup si tu as saisi 2 formules ou plus, Ruby n'affiche que le résultat de la dernière formule. -Of course you have the power to control the screen ! Just type __puts__ before each formula -(with a space in between). Puts means: *'put something on the screen'*. +Bien sûr, tu as le pouvoir de contrôler l'écran ! Il suffit d'écrire __puts__ avant chaque formule +(separé d'un espace). "Puts" signifie : *'Afficher quelque chose à l'écran'*. -Try this: +Essaie ça : puts 4 * 10 puts 5 - 12 puts 30 / 4 -Now remove the puts from the last formula and see what happens. +Maintenant retire les "puts" progressivement et observe ce qui se passe. diff --git a/translations/fr/try_ruby_400.md b/translations/fr/try_ruby_400.md index b9bd7cda..0fac1b0e 100644 --- a/translations/fr/try_ruby_400.md +++ b/translations/fr/try_ruby_400.md @@ -1,24 +1,19 @@ --- -lang: EN -title: All together now +lang: FR +title: Tous ensemble désormais answer: ^4$ -ok: Yes, Shakespeare wrote 4 plays in 1591 -error: Answer for the year 1591 should be 4 +ok: Oui, Shakespeare a écrit 4 pièces en 1591 +error: La réponse pour l'année 1591 devrait être 4 load: prev --- -Now suppose we only want to know the names and number of plays written by Shakespeare -in a certain year. +Maintenant, supposons que nous voulions uniquement connaître les noms et le nombre de pièces écrites par Shakespeare au cours d'une année spécifique. -Ruby lets us __select__ values from a hash. The select method uses a block to let us -define what to select and returns what it found. +Ruby nous permet de sélectionner (__select__) des valeurs à partir d'un hash. La méthode select utilise un bloc pour nous permettre de définir ce que nous voulons sélectionner et retourne ce qu'elle a trouvé. -We can then use the results returned by __select__ in the __each__ method as before by -simply adding it after the select block. This is another example of method chaining, which we saw -earlier when reversing a poem. +Nous pouvons ensuite utiliser les résultats retournés par __select__ dans la méthode __each__ comme précédemment en les ajoutant simplement après le bloc select. C'est un autre exemple de chaînage de méthodes, que nous avons vu précédemment lors de l'inversion d'un poème. -I have prepared the __count\_plays__ method for you. See if you can find out how many plays -were written by Shakespeare in the year __1591__. Try this: +J'ai préparé la méthode __count\_plays__ pour toi. Essaye de trouver combien de pièces ont été écrites par Shakespeare en l'année __1591__. Essaie ceci : def count_plays(year) s = get_shakey @@ -33,9 +28,8 @@ were written by Shakespeare in the year __1591__. Try this: puts count_plays(0) -Did you notice that I chained the count method at the end of the each method. This gives -us a return value for the __count\_plays__ method. +As-tu remarqué que j'ai chaîné la méthode count à la fin de la méthode each ? Cela nous donne une valeur de retour pour la méthode __count\_plays__. -There is another possibility for chaining here. See that loney line __s = get_shakey__. -You could add the __["William Shakespeare"].select { |k, v|__ at the end of get_shakey -(no dot needed in this case). +Il y a une autre possibilité pour le chaînage ici. +Regarde cette ligne __s = get\_shakey__. +Tu pourrais retirer la variable __s__ et chaîner get_shakey avec le __["William Shakespeare"].select { |k, v|__ \ No newline at end of file diff --git a/translations/fr/try_ruby_410.md b/translations/fr/try_ruby_410.md index 1ec0b868..3e19ba4f 100644 --- a/translations/fr/try_ruby_410.md +++ b/translations/fr/try_ruby_410.md @@ -1,25 +1,24 @@ --- -lang: EN -title: All's Well That Ends Well +lang: FR +title: Tout est bien qui finit bien answer: All's Well That Ends Well -ok: True -error: Use 1605 as the second parameter +ok: Vrai +error: Utilisez 1605 en deuxième paramètre load: prev --- -Okay, we got some data from the internet, we selected what we wanted and printed it out. -What is left to improve? We could print the results a bit prettier. Like add the year -and align titles and years. +Bien, nous avons obtenu des données d'Internet, nous avons sélectionné ce que nous voulions et nous l'avons afficher. +Que reste-t-il à améliorer ? Nous pourrions afficher les résultats un peu plus joliment. Comme ajouter l'année et aligner les titres et les années. -This means printing several values on one line. Ruby has a neat way of doing -that. It is just like printing a string like: __puts "Hi, my name is Jimmy"__. -But instead of the literal value _Jimmy_ we use the value of a variable. +Cela signifie afficher plusieurs valeurs sur une seule ligne. Ruby a une manière astucieuse de le faire. +C'est comme afficher une chaîne de caractères comme ceci : __puts "Salut, je m'appelle Jimmy"__. +Mais au lieu de la valeur littérale _Jimmy_, nous utilisons la valeur d'une variable. -First replace __Jimmy__ with __#{}__. If Ruby sees a hash symbol # followed by a curly brace { -it looks for a variable between the first brace and the following closing brace }. -So we can use this: __"Hi, my name is \#{name}"__. +Remplacez d'abord _Jimmy_ par __#{}__. Si Ruby voit un symbole de hachage # suivi d'une accolade { +il cherche une variable entre la première accolade et l'accolade fermante suivante }. +Nous pouvons donc utiliser ceci : __"Salut, je m'appelle \#{name}"__. -Let's change our code a bit +Modifions un peu notre code : def print_plays(year_from, year_to) get_shakey["William Shakespeare"] @@ -27,14 +26,13 @@ Let's change our code a bit year_from <= v["finished"] && year_to >= v["finished"] }.each { |k, v| - puts "#{v["title"].ljust(30)} #{v["finished"]}" + puts "#{v["finished"]} -> #{v["title"]}" } end print_plays(1600, 1605) -I have added __.ljust(30)__ to the title. This way the title is _left justified_ with a minimum -length of 30 characters so the years align nicely. +J'ai ajouté __.ljust(30)__ au titre. De cette façon, le titre est justifié à gauche avec une longueur minimale de 30 caractères pour que les années s'alignent joliment. -See if you can change the ouput of the program so that it shows the plays like this: __1600 -> As You Like It__ +Voyez si vous pouvez changer la sortie du programme pour qu'elle affiche les pièces comme ceci : __1600 -> Comme il vous semble__ -__All's Well That Ends Well ?__ Hey we're not done yet, but the end is in sight ! +__Tout est bien qui finit bien ?__ Hé, nous n'avons pas encore terminé, mais la fin est proche ! \ No newline at end of file diff --git a/translations/fr/try_ruby_420.md b/translations/fr/try_ruby_420.md index ccda7ab9..84452955 100644 --- a/translations/fr/try_ruby_420.md +++ b/translations/fr/try_ruby_420.md @@ -1,25 +1,25 @@ --- -lang: EN -title: If only I new how to make a decision +lang: FR +title: Si seulement je savais comment prendre une décision answer: ok: error: --- -Decision making, in real life this can be a real problem. Not for us though. -Ruby makes it very easy to make decisions. +Prendre des décisions, dans la vie réelle, peut être un vrai problème. Pas pour nous cependant. +Ruby rend très facile de prendre des décisions. if 1 < 2 - puts "It is true: 1 is less than 2" + puts "C'est vrai : 1 est inférieur à 2" end -The key word here is __if__. If can be placed before a method or after a method, like so: +Le mot clé ici est __if__. If peut être placé avant une méthode ou après une méthode, comme ceci : - puts "It is true: 1 is less than 2" if 1 < 2 + puts "C'est vrai : 1 est inférieur à 2" if 1 < 2 -__If__ is a method that requires one parameter. That parameter can be any expression that you -want to test. The outcome of the expression must be either __true__ or __false__. -Here are a couple of expressions with their outcomes: +__If__ est une méthode qui nécessite un paramètre. Ce paramètre peut être n'importe quelle expression que vous +voulez tester. Le résultat de l'expression doit être soit __true__ soit __false__. +Voici quelques expressions avec leurs résultats : 5 <= 10 # => true 'abc' == 'def' # => false @@ -28,9 +28,9 @@ Here are a couple of expressions with their outcomes: 0 # => true nil # => false 'xyz'.empty? # => false - 'a' > 5 # => error: - # comparison of String with - # Numeric failed + 'a' > 5 # => erreur : + # la comparaison entre une chaîne de caractères et + # un nombre a échoué -The _if expression_ can take many forms. It can compare literal values (1 < 2), -variables (a < 1) and the return value of a method ('xyz'.empty?). +L'_expression if_ peut prendre de nombreuses formes. Elle peut comparer des valeurs littérales (1 < 2), +des variables (a < 1) et la valeur de retour d'une méthode ('xyz'.empty?). \ No newline at end of file diff --git a/translations/fr/try_ruby_430.md b/translations/fr/try_ruby_430.md index 7de3263c..9f981b54 100644 --- a/translations/fr/try_ruby_430.md +++ b/translations/fr/try_ruby_430.md @@ -1,34 +1,32 @@ --- -lang: EN -title: And Now For the Startling Conclusion -answer: is not equal to 100$ -ok: That's better -error: This can't be right +lang: FR +title: Et maintenant, la surprenante conclusion +answer: n'est pas égal à 100$ +ok: C'est mieux +error: Ce n'est pas possible --- -Did you see the 2 equal signs in __'abc' == 'def'__? +Avez-vous remarqué les 2 signes égaux dans __'abc' == 'def'__ ? -This __==__ means __is equal to__. -The single equal sign that we have seen before means __assign a value to a variable__. +Ce __==__ signifie __est égal à__. +Le simple signe égal que nous avons vu auparavant signifie __affecter une valeur à une variable__. -To make it more confusing: you can use the assignment after an if method like this: +Pour rendre les choses plus confuses : vous pouvez utiliser l'assignation après une méthode if comme ceci : a = 0 if a = 100 - puts "Expression is true, but a is now: #{a}" + puts "L'expression est vraie, mais a est maintenant : #{a}" else - puts "#{a} is not equal to 100" + puts "#{a} n'est pas égal à 100" end -Change the = into == and see what happens. +Changez le = en == et voyez ce qui se passe. -I can guarantee you that you will forget typing the second equal sign regularly. I also -still forget it sometimes. +Je peux vous garantir que vous oublierez régulièrement de taper le deuxième signe égal. Moi aussi, je l'oublie parfois. ### else -In the code above I have added an else expression. This part will be executed when the -__if test-expression__ evaluates to false. +Dans le code ci-dessus, j'ai ajouté une expression else. Cette partie sera exécutée lorsque l'__expression de test if__ s'évalue à faux. -> There are more variations to this if-then-else theme. You can read more -> here. +> Il existe plus de variations sur ce thème if-then-else. Vous pouvez en lire plus +> ici. \ No newline at end of file diff --git a/translations/fr/try_ruby_440.md b/translations/fr/try_ruby_440.md index 7c3c7d0e..5b551cdd 100644 --- a/translations/fr/try_ruby_440.md +++ b/translations/fr/try_ruby_440.md @@ -1,31 +1,33 @@ --- -lang: EN -title: Me hungry -answer: ^Me not hungry.$ -ok: Yes -error: No way am I hungry at 10 AM ! +lang: FR +title: Moi faim +answer: ^Moi pas faim +ok: Oui +error: NON, j'ai pas faim à 10h ! --- -Okay, this is coming along wonderfully. This is simple stuff for you, but keep in mind that you -didn't know __any Ruby whatsoever__ just fifteen minutes ago! +Vous avancez à merveille ! C'est simple pour vous, mais rappelez-vous que vous ne connaissiez __absolument rien en Ruby__ il y a seulement quinze minutes ! -Last step. Let's tie it all together, you know? Let's make it chime together like a very nice set -of glistening chimes on the beach in the maginificent sunlight! +Dernière étape. Mettons tout cela ensemble, d'accord ? Faisons en sorte que tout sonne ensemble comme un très joli ensemble de carillons scintillants sur la plage, sous la magnifique lumière du soleil ! -We'll define two methods first and then take a decision: +Nous allons d'abord définir deux méthodes, puis prendre une décision : - def hungry?(time_of_day_in_hours) - puts "Me hungry." - true + def faim?(heure_de_la_journée_en_heures) + if heure_de_la_journée_en_heures < 12 + puts "Moi pas faim" + false + else + puts "Moi faim" + true + end end - def eat_an(what) - puts "Me eat #{what}.\n" + def manger(aliment) + puts "Moi manger #{aliment}\n" end - eat_an 'apple' if hungry?(14) + manger 'pomme' if faim?(14) - eat_an 'apple' if hungry?(10) + manger 'pomme' if faim?(10) -Now see if you can change the method __hungry?__ to display __"Me not hungry"__ and returning false -when the time is less than 12. +Voyez si vous pouvez changer la méthode __faim?__ pour afficher __"Moi pas faim"__ et retourner faux __false__ lorsque l'heure est inférieure à 12. \ No newline at end of file diff --git a/translations/fr/try_ruby_450.md b/translations/fr/try_ruby_450.md index 0b263950..ecd5ee40 100644 --- a/translations/fr/try_ruby_450.md +++ b/translations/fr/try_ruby_450.md @@ -1,33 +1,31 @@ --- -lang: EN -title: Summary #6 Which Means You've Come So Far +lang: FR +title: Résumé #6 Autrement dit, tu as parcouru du un long chemin answer: \{\} class: stretcher chapmark -ok: Ok, that's an empty hash -error: +ok: Bien, ceci est un hash vide. +error: --- -You're a level six Ruby cleric. I mean what a great job you've done. Let's review: +Tu es un prêtre niveau six en Ruby. Je veux dire, quel excellent travail tu as fait. Voyons voir : +### Données +Tu as chargé des données depuis internet, parcouru une structure de données et sélectionné des valeurs. -### Data -You loaded some data of the internet, traversed a data structure and selected values. +### Itération +Tu as itéré sur tous les éléments d'un hash et tu as chaîné encore plus de méthodes. -### Iterating -You iterated all elements of a hash and you chained some more methods. - -### Pretty printing -And if that wasn't enough, you formatted and printed some values in a way that is easy -to read for humans. In fact __you made a real program !__ +### Affichage agréable +Et si cela ne suffisait pas, tu as formaté et affiché des valeurs d'une manière facile à lire pour le commun des mortels. En fait, __tu as créé un véritable programme !__ ### IF -You learned to take control of your programs with __if__ and __else__ statements. +Tu as appris à prendre le contrôle de tes programmes avec des instructions __if__ et __else__. -## So -What could possibly be next? What could you possibly have to learn now? -Ha, this is the best part. You've come such a long way that we're going -to uncover classes. For two more short lessons and you're done. +## Donc +Qu'est-ce qui pourrait bien venir ensuite ? Que pourrais-tu encore avoir à apprendre maintenant ? +Ha, voici la meilleure partie. Tu as parcouru un si long chemin que nous allons maintenant découvrir les classes. +Après seulement deux leçons courtes de plus, tu auras terminé. -Earlier, we created a hash like this: +Plus tôt, nous avons créé un hash comme ceci : - Hash.new + Hash.new \ No newline at end of file diff --git a/translations/fr/try_ruby_460.md b/translations/fr/try_ruby_460.md index fcb68e5b..3e43666e 100644 --- a/translations/fr/try_ruby_460.md +++ b/translations/fr/try_ruby_460.md @@ -1,33 +1,33 @@ --- lang: EN -title: Not a School Class, a Working Class -answer: -ok: -error: +title: Pas une classe d'école, une classe ouvrière +answer: +ok: +error: --- -You see, the empty curly braces {} is a shortcut for Hash.new. The new method is used to make objects -of a certain class. Think "class" as in "working class" — a specific group of objects which -are similar, have the same jobs, the same shirts. -What use is a class ? +Vois-tu les accolades vides {} c'est un raccourci pour Hash.new. +La méthode new est utilisée pour créer des objets d'une certaine classe. +Pense à "classe" comme la "classe ouvrière" ; un groupe d'élément ayant les mêmes propriétés : mêmes emplois, mêmes maisons, même style vestimentaire. +Quel est l'utilité d'une classe ? ### BlurbalizerTM -You just had a brilliant idea for a new app. It is going to be __the__ next instant -messaging platform. You want an app where people can send each other short messages. You call -these messages BlurbsTM. A BlurbTM has a maximum length of just 40 characters. Let's do a mood setting too. +Tu viens juste d'avoir une idée brillante pour une nouvelle application. +Ce sera __LA__ prochaine plateforme de messagerie instantanée. +Tu veux une application où les gens peuvent s'envoyer des messages courts. +Tu appelles ces messages BlurbsTM. Un BlurbTM a une longueur maximale de seulement 40 caractères. +Ajoutons également definir son humeur (__mood__). - +### Par où commencer +Eh bien, tu pourrais stocker tes entrées BlurbsTM dans un fichier json, n'est-ce pas ? +Mais comment garderais-tu une trace du contenu de l'entrée et de l'heure à laquelle elle a été postée ? +Et lorsque tu chargerais le fichier, comment cela apparaîtrait-il en Ruby ? +Serait-ce un Hash ? Ou un Array ? Ou un Array de Arrays ? Ou autre chose ? -### Where to start -Well, you might store your BlurbsTM entries in a json file, right? -But how would you keep track of the content of the entry and the time it was posted? -And when you loaded the file, how would it look in Ruby? -Would it be a Hash? Or an Array? Or an Array of Arrays? Or something else? - -### Class -I really think you'll want to use a class. You are already familiar with many classes: -Hash, Array, String. -Let's make a new class (returns no output): +### Classe +Je pense vraiment que tu voudras utiliser une classe. +Tu es déjà familier avec de nombreuses classes : Hash, Array, String. +Créons une nouvelle classe (ne renvoie aucune sortie) : class Blurb - end + end \ No newline at end of file diff --git a/translations/fr/try_ruby_470.md b/translations/fr/try_ruby_470.md index 12cdde83..b79e6bf9 100644 --- a/translations/fr/try_ruby_470.md +++ b/translations/fr/try_ruby_470.md @@ -1,20 +1,20 @@ --- -lang: EN -title: The Stuff Apps are Made of +lang: FR +title: Les éléments qui font une application answer: ok: error: --- -You've opened up a new BlurbTM class. What is your blog entry made of? -The content, sure. Also, a time when the BlurbTM was posted. And a mood. +Tu as crées une nouvelle classe BlurbTM. De quoi sont faits les articles de blog ? +Le contenu (__content__), bien sûr. Mais aussi de l'heure à laquelle le BlurbTM a été publié (__time__). Et aussi une humeur (__mood__). -Okay, so you've got the first line of the class, here's the rest: +Bien, tu as la première ligne de la classe, voici la suite : class Blurb attr_accessor :content, :time, :mood end -Class names always begin with a capital letter. +Les noms de classe commencent toujours par une lettre majuscule. -(Still no output) +(Toujours pas de sortie) \ No newline at end of file diff --git a/translations/fr/try_ruby_480.md b/translations/fr/try_ruby_480.md index 049990cc..590bc1b7 100644 --- a/translations/fr/try_ruby_480.md +++ b/translations/fr/try_ruby_480.md @@ -1,25 +1,26 @@ --- -lang: EN -title: Accessors Are the Dangling Limbs +lang: FR +title: Les 'accessors' sont les membres pendouillants. answer: Blurb: -ok: My first Blurb +ok: Mon premier Blurb error: load: class Blurb;attr_accessor :content,:time,:mood;end --- -Hey, good class, man. You've got a new BlurbTM class. +Super classe, mon ami(e)! Tu as une nouvelle classe BlurbTM. -In the class definition, you used a method called attr\_accessor. -There are many __attr__ibute methods like this which add little settings to classes. -These attributes are just variables attached to a class. +Dans la définition de la classe, tu as utilisé une méthode appelée attr\_accessor. +Il existe de nombreuses méthodes d' __attr__ibut comme celle-ci qui permettent d'apporter de petites améliorations. +Ces attributs sont juste des variables attachées à une classe. -Think of it this way. A class is like a person. That star-shaped human thing out there. -And the attributes are the dangling limbs, the different parts that make up a body and -other people can shake hands with. +Pensez-y de cette manière. Une classe est comme une personne. +Cette chose en forme d'étoile est un humain. +Et les attributs sont les membres pendouillants, les différentes parties qui composent un corps et +que d'autres personnes peuvent se serrer la main avec. -### Now -To create a BlurbTM and set the content: +### Maintenant +Pour créer un BlurbTM et définir le contenu : blurb1 = Blurb.new puts blurb1 - blurb1.content = "Today Mount Hood Was Stolen!" + blurb1.content = "Aujourd'hui, le Mont Blanc a été volé !" diff --git a/translations/fr/try_ruby_490.md b/translations/fr/try_ruby_490.md index 95e72478..7d10edfe 100644 --- a/translations/fr/try_ruby_490.md +++ b/translations/fr/try_ruby_490.md @@ -1,15 +1,15 @@ --- -lang: EN -title: An Object, That Neat Little Package +lang: FR +title: Un objet, ce petit paquet bien organisé. answer: Blurb: -ok: Blurb updated +ok: Blurb mis à jour error: -load: prev;blurb1=Blurb.new;blurb1.content="Today Mount Hood Was Stolen!" +load: prev;blurb1=Blurb.new;blurb1.content="Aujourd'hui, le Mont Blanc a été volé !" --- -Go ahead and set the BlurbTM time and mood: +A toi de jouer, définis le temps et l'humeur du BlurbTM : blurb1.time = Time.now - blurb1.mood = :sick + blurb1.mood = :triste - puts blurb1 + puts blurb1 \ No newline at end of file diff --git a/translations/fr/try_ruby_50.md b/translations/fr/try_ruby_50.md index 89c1485b..b0b705ba 100644 --- a/translations/fr/try_ruby_50.md +++ b/translations/fr/try_ruby_50.md @@ -1,13 +1,13 @@ --- -lang: EN -title: Say Your Name +lang: FR +title: Dis ton nom answer: [a-zA-Z]{1,1} -ok: Perfect, you've formed a string from the letters of your name +ok: Parfait, tu as formé une chaîne de caractères (string) à partir des lettres de ton nom. error: --- -Sure, computers are handy and fast for math. Let's move on. Want to see your name reversed? +Bien sûr, les ordinateurs sont pratiques et rapides pour les calculs. Passons à autre chose : Veux-tu voir ton nom à l'envers ? -First type your first name in quotes like this: +Écris d'abord ton prénom entre guillemets comme ceci : "Jimmy" diff --git a/translations/fr/try_ruby_500.md b/translations/fr/try_ruby_500.md index a18e0207..502db5f4 100644 --- a/translations/fr/try_ruby_500.md +++ b/translations/fr/try_ruby_500.md @@ -1,19 +1,18 @@ --- -lang: EN -title: Quickening it Up +lang: FR +title: Accélérons les choses answer: ^\d{4} -ok: Noted +ok: C'est noté error: --- -Cool, you're app is awesome. Hey, let's make things a bit easier on you. -You're not going to want to set the time like that every time you BlurbTM. +Super, ton application est géniale. Rendons les choses un peu plus simple pour toi. +Tu ne voudras pas définir le temps de cette façon à chaque fois que tu crées un BlurbTM. -You just want to type the content and set the mood, right? +Tu veux juste saisir le contenu (__content__) et définir l'humeur (__mood__), n'est-ce pas ? -Let's add an __initialize__ method to our class. This method is called whenever a new BlurbTM -is created. -At the same time we can limit the length of the BlurbTM content to 40 characters. +Ajoutons une méthode __initialize__ à notre classe. Cette méthode est appelée chaque fois qu'un nouveau BlurbTM est créé. +Par la méme occassion, nous pouvons limiter la longueur du contenu du BlurbTM à 40 caractères. class Blurb attr_accessor :content, :time, :mood @@ -25,7 +24,7 @@ At the same time we can limit the length of the BlurbTM content to 40 end end - Blurb.new.time + Blurb.new(:triste).time -(That parameter __content=""__ is there to make sure that we know content is a string, -even if no content parameter is passed to the initialize method.) +(Le paramètre __content=""__ est là pour s'assurer que nous savons que le contenu est une chaîne de caractères, +même si aucun paramètre 'content' n'est definie, il passe par la méthode __initialize__.) \ No newline at end of file diff --git a/translations/fr/try_ruby_510.md b/translations/fr/try_ruby_510.md index a1890dcb..bca6dfc6 100644 --- a/translations/fr/try_ruby_510.md +++ b/translations/fr/try_ruby_510.md @@ -1,28 +1,28 @@ --- -lang: EN -title: You've Taught Your App to Reject Worthless Things +lang: FR +title: Tu as appris à ton application à rejeter les choses sans valeur. answer: Blurb: -ok: Blurb added +ok: Blurb ajouté error: load: class Blurb;attr_accessor :content,:time,:mood;def initialize(mood, content="");@time=Time.now;@content=content[0..39];@mood=mood;end;end;blurb1=Blurb.new(:sick,"Today Mount Hood Was Stolen!") --- -Did you see how inside the class we used the at-symbols (@time). +As-tu remarqué comment à l'intérieur de la classe nous avons utilisé le arobase '@' (@time). -__Outside__ the class, we use accessors: +__À l'extérieur__ de la classe, nous utilisons des 'accessors' : > __blurb.time = Time.now__ -but __inside__ we use the __object's variables__: +mais __à l'intérieur__, nous utilisons les __variables de l'objet__ : > __@time = Time.now__ -They're the exact same thing, but expressed in two different places of your program. +Ce sont exactement la même chose, mais exprimée à deux endroits différents de ton programme. -### Create another BlurbTM -When a new BlurbTM is created, the initialize method is used to check for any -arguments to new. +### Crée un autre BlurbTM +Lorsqu'un nouveau BlurbTM est créé, la méthode initialize est utilisée pour vérifier s'il y a des +arguments à new. -Uh, we need two arguments: +Nous avons besoin de deux arguments : - Blurb2 = Blurb.new :confused, "I can not believe Mt. Hood was stolen!" + Blurb2 = Blurb.new :confus, "Je ne peux pas croire que le Mont Blanc a été volé !" \ No newline at end of file diff --git a/translations/fr/try_ruby_520.md b/translations/fr/try_ruby_520.md index d0fc133b..37536770 100644 --- a/translations/fr/try_ruby_520.md +++ b/translations/fr/try_ruby_520.md @@ -1,27 +1,26 @@ --- -lang: EN -title: A Giraffe Has Not Stolen Summary #7 +lang: FR +title: Une girafe n'a pas volé le résumé #7 answer: class: stretcher chapmark ok: error: -load: prev;blurb2=Blurb.new :confused, "I can not believe Mt. Hood was stolen!" +load: prev;blurb2=Blurb.new :confus, "Je ne peux pas croire que le Mont Blanc a été volé !" --- -Aha, you're here. And all in one piece. We're still going to make your app real, -but until then, let's review, okay? +Tu en es là. Et en un seul morceau, haha. Nous allons continuer de rendre l'application concrète, mais en attendant, faisons une révision, d'accord ? ### Classes -Everything in Ruby is some kind of object. Classes explain objects, how a certain object works. -For example, you made a few BlurbTM objects and these objects are explained in the Blurb -class. -In other words: you call them Blurb objects. -You can use classes to (kinda) model real life objects. +En Ruby, tout est en quelque sorte objet. +Les classes expliquent les objets et leur fonctionnement. +Par exemple, vous avez créé quelques objets BlurbTM et ces objets sont détaillés dans la classe Blurb. +En d'autres termes, on les appelle des objets Blurb. +Tu peux utiliser les classes pour modéliser (en quelque sorte) des objets de la vie réelle. ### Accessors -Accessors are variables attached to an object which can be used __outside__ the object. +Les accessors sont des variables attachées à un objet qui peuvent être utilisées à l'extérieur d'objet. (blurb2.time = Time.now) -### Object variables -Object variables are the same variables you're using for accessors, but __inside__ the object. +### Variables d'objet +Les variables d'objet sont les mêmes variables que tu utilises pour les accessors, mais à l'intérieur d'un objet. (@time = Time.now) diff --git a/translations/fr/try_ruby_530.md b/translations/fr/try_ruby_530.md index 85e2e25e..f87f18f5 100644 --- a/translations/fr/try_ruby_530.md +++ b/translations/fr/try_ruby_530.md @@ -1,39 +1,39 @@ --- -lang: EN -title: Your Own Turf +lang: FR +title: Ton propre territoire answer: Blurbalizer: -ok: My app created +ok: L'application est créée error: load: class Blurb;attr_accessor :content,:time,:mood;def initialize(mood, content="");@time=Time.now;@content=content[0..39];@mood=mood;end;end --- -Okay, let's wrap things up, kid. Here's the last chapter of the GRIPPING epic story of Try Ruby! -Now that you've got a taste of how it all works, how are you going to use it around the house -and in your grocer's freezer? -You're a great person (one of my favorites), but you need guidance. +Trés bien, concluons cela. Voici le dernier chapitre de l'histoire épique et PALPITANTE de Try Ruby ! +Maintenant que tu as eu un aperçu de comment tout cela fonctionne, comment vas-tu l'utiliser à la maison +et dans ton quotidien ? +Tu es une personne géniale (l'un de mes favoris), mais tu as encore un peu besoin d'être guidé. -### Let's finish your app -You have app entries, but no actual app. -It still needs a title, someplace to store all BlurbsTM and a timeline in order to work. +### Terminons l'application +Nous avons des entrées dans l'application, mais pas d'application à proprement parler. +Pour fonctionner, elle a encore besoin d'un titre, d'un endroit où stocker tous les BlurbsTM et d'une chronologie. -Guess what, we're going to use another class. I've given all the code for the new class in one go. -Just __take your time__ to study it. -I'm in no hurry, I'll wait for you in the next lesson. +Devine quoi, nous allons utiliser une autre classe. +Je te donne tout le code pour la nouvelle classe. +__Prends ton temps__ pour l'étudier. Je ne suis pas pressé, je t'attendrai à la prochaine leçon. class Blurbalizer def initialize(title) @title = title - @blurbs = [] # A fresh clean array - # for storing Blurbs + @blurbs = [] # Un tableau propre et vide + # pour stocker les Blurbs end def add_a_blurb(mood, content) - # The << means add to the end of the array + # Le << signifie ajouter à la fin du tableau @blurbs << Blurb.new(mood, content) end def show_timeline - puts "Blurbify: #{@title} has #{@blurbs.count} Blurbs" + puts "Blurbify: #{@title} contient #{@blurbs.count} Blurbs" @blurbs.sort_by { |t| t.time @@ -43,4 +43,4 @@ I'm in no hurry, I'll wait for you in the next lesson. end end - myapp = Blurbalizer.new "The Big Blurb" + myapp = Blurbalizer.new "Le Grand Blurb" \ No newline at end of file diff --git a/translations/fr/try_ruby_540.md b/translations/fr/try_ruby_540.md index 7b756365..9a0d3db1 100644 --- a/translations/fr/try_ruby_540.md +++ b/translations/fr/try_ruby_540.md @@ -1,24 +1,20 @@ --- -lang: EN -title: What's that Blurb all about? -answer: Today -ok: Bring on the blurbs -error: -load: prev;class Blurbalizer;attr_reader :title;def initialize(title);@title=title;@blurbs=[];end;def add_a_blurb(mood, content);@blurbs << Blurb.new(mood, content);@blurbs.each {|t| t.time -= 73};end;def show_timeline;puts "Blurbalizer: #{@title} has #{@blurbs.count} Blurbs\n";@blurbs.sort_by { |t| t.time}.reverse.each { |t| puts "#{t.content.ljust(40)} #{t.time}"};end;end;myapp = Blurbalizer.new "The Big Blurb";myapp.add_a_blurb :sick,"Today Mount Hood Was Stolen!";myapp.add_a_blurb :confused,"I can not believe Mt. Hood was stolen!";myapp.add_a_blurb :dazed,"I am speechless!";myapp.add_a_blurb :mad,"It was stolen by a giraffe !!";myapp.add_a_blurb :sad,"I Left my Hoodie on the Mountain!";myapp.add_a_blurb :mad,"I am never going back to that mountain." +lang: FR +title: Qu'est-ce que c'est tous ces Blurbs ? +answer: Aujourd'hui +ok: Apportez les blurps +error: +load: prev;class Blurbalizer;attr_reader :title;def initialize(title);@title=title;@blurbs=[];end;def add_a_blurb(mood, content);@blurbs << Blurb.new(mood, content);@blurbs.each {|t| t.time -= 73};end;def show_timeline;puts "Blurbalizer: #{@title} contient #{@blurbs.count} Blurbs\n";@blurbs.sort_by { |t| t.time}.reverse.each { |t| puts "#{t.content.ljust(40)} #{t.time}"};end;end;myapp = Blurbalizer.new "Le Grand Blurb";myapp.add_a_blurb :triste,"Aujourd'hui, le Mont Blanc a été volé !";myapp.add_a_blurb :confus,"Je ne peux pas croire que le Mont Blanc a été volé !";myapp.add_a_blurb :surpris,"Je suis sans voix !";myapp.add_a_blurb :colere,"Il a été volé par une girafe ! !!";myapp.add_a_blurb :degout,"J'ai laissé mon sweat à la montagne !";myapp.add_a_blurb :furieux,"Je ne retournerai jamais sur cette montagne." --- -There you are. Did you figure out what all that code in the BlurbalizerTM class does ? +Nous y voilà. Avez-vous compris ce que fait tout ce code dans la classe BlurbalizerTM ? -> In the BlurbalizerTM class are two __methods__ (add\_a\_blurb and show\_timeline). -> You can use a method outside the class, just like we did with accessors. +> Dans la classe BlurbalizerMC, il y a deux __méthodes__ (add\_a\_blurb et show\_timeline). Tu peux utiliser une méthode en dehors de la classe, tout comme nous l'avons fait avec les accessors. -Time to start using BlurbalizerTM. I've already loaded some BlurbsTM for you, -but feel free to add your own. +Il est temps de commencer à utiliser BlurbalizerTM. J'ai déjà chargé quelques BlurbsTM pour toi, mais n'hésite pas à ajouter les tiens. -We're no longer creating BlurbsTM directly, but we use the add\_a\_blurb __method__ of the -BlurbalizerTM class. This way we can be sure all our BlurbsTM are stored in the -myapp object. +Nous ne créons plus directement des BlurbsTM, mais nous utilisons la __méthode__ add\_a\_blurb de la classe BlurbalizerTM. De cette manière, nous pouvons être sûrs que tous nos BlurbsTM sont stockés dans l'objet myapp. + + myapp.add_a_blurb :humeur, "Ajouter un Blurp ici" - myapp.add_a_blurb :moody, "Add Blurb here" - myapp.show_timeline diff --git a/translations/fr/try_ruby_550.md b/translations/fr/try_ruby_550.md index c23462f1..2ffc91ed 100644 --- a/translations/fr/try_ruby_550.md +++ b/translations/fr/try_ruby_550.md @@ -1,58 +1,59 @@ --- -lang: EN -title: It's All About Combining +lang: FR +title: Tout est dans la combinaison answer: :- -ok: Moody ! -error: +ok: De l'humeur ! +error: load: prev --- -Some beautiful things can be done with the simple parts of Ruby, especially when you combine them -together into new things. -Here we've got an app made of a class containing another class. And, actually, Ruby really does good -with this kind of creature. It is called object oriented programming. +Il est possible de faire de très belles choses avec les éléments simples de Ruby, en particulier lorsqu'on les combine +pour créer de nouvelles choses. +Ici, nous avons une application composée d'une classe contenant une autre classe. +Et, en fait, Ruby se débrouille très bien +avec ce genre de créature. C'est ce qu'on appelle la programmation orientée objet. -We have arrived at the __last programming excercise__ of TryRuby. If you want, you can add some -more features to BlurbalizerTM. +Nous sommes arrivés au __dernier exercice de programmation__ de TryRuby. Si vous le souhaitez, +vous pouvez ajouter d'autres fonctionnalités à Blurbalizer.TM. -Maybe you want to print the mood as a smiley in the __show_timeline__ method. You could add -a _moodify_ method to the BlurbTM class and then use that method in the _show\_timeline_ method: +Peut-être que tu prefères afficher l'humeur sous forme de smiley dans la méthode __show_timeline__. Tu peux ajouter +une méthode _moodify_ dans la classe BlurbTM puis utiliser cette méthode dans la méthode _show\_timeline_ : class Blurb attr_accessor :content, :time, :mood - + def initialize(mood, content="") @time = Time.now @content = content[0..39] @mood = mood end - + def moodify - if @mood == :sad - return ":-(" - elsif @mood == :happy - return ":-)" - # Add other moods here + if @mood == :triste + return ":-(" + elsif @mood == :content + return ":-)" + # Ajoutez d'autres humeurs ici end - # The default mood + # L'humeur par défaut ":-|" end end - + class Blurbalizer def initialize(title) @title = title @blurbs = [] end - + def add_a_blurb(mood, content) @blurbs << Blurb.new(mood, content) end - + def show_timeline - puts "Blurbalizer: #{@title} has #{@blurbs.count} Blurbs" - + puts "Blurbalizer: #{@title} contient #{@blurbs.count} Blurbs" + @blurbs.sort_by { |t| t.time }.reverse.each { |t| @@ -60,5 +61,5 @@ a _moodify_ method to the BlurbTM class and then use that method in t } end end - - myapp.show_timeline + + myapp.show_timeline \ No newline at end of file diff --git a/translations/fr/try_ruby_560.md b/translations/fr/try_ruby_560.md index 746e124b..efedbdd8 100644 --- a/translations/fr/try_ruby_560.md +++ b/translations/fr/try_ruby_560.md @@ -1,31 +1,26 @@ --- -lang: EN -title: Summary #8, The Hey-Relax-You-Did-Good Summary -answer: +lang: FR +title: Resumé #8, Le Detente-Tu-As-Gérés Récapitulatif +answer: class: stretcher chapmark ok: error: -load: def ruby(f);puts "Go to www.ruby-lang.org to download Ruby";end;class K;attr_reader :rb;end;my_first_progam=K.new +load: def ruby(f);puts "Rendez-vous sur www.ruby-lang.org pour télécharger Ruby";end;class K;attr_reader :rb;end;mon_premier_programme=K.new --- -This last section took a moment to wind down, to give you some pointers as to how you can use Ruby. +Cette dernière partie a pris un moment pour se terminer, pour te donner quelques conseils sur la façon dont tu peux utiliser Ruby. -If you enjoyed yourself, you can continue with the TryRuby Playground -or download and install Ruby: -ruby-lang.org +Si tu as apprécié, tu peux continuer avec le TryRuby Playground ou télécharger et installer Ruby: ruby-lang.org -Once you have Ruby installed, you can create a file, let say _my\_first\_progam.rb_, with a text -editor, type some Ruby code and then run it by opening a command prompt and typing: +Une fois que tu as Ruby installé, tu peux créer un fichier, disons _mon\_premier\_programme.rb_, avec un éditeur de texte, taper du code Ruby, puis l'exécuter en ouvrant une invite de commande et en tapant : - ruby my_first_progam.rb + ruby mon_premier_programme.rb -There are many (free) development tools available that combine an editor, file browser and a -'ruby-runner'. +Il existe de nombreux outils de développement (gratuits) disponibles qui combinent un éditeur, un explorateur de fichiers et un 'ruby-runner'. -## Celebrate -You really deserve a double-layer cake with double-double frosting and a guy playing one of those guitars that's a double guitar. -I mean you finished, you really did! No doubt about it, you're a __certified red-blooded smartiac!__ +## Célébration +Tu mérites vraiment un gâteau à deux étages avec un double glaçage et un gars jouant de l'une de ces guitares qui est une double guitare. +Je veux dire, tu as terminé, tu l'as vraiment fait ! Pas de doute là-dessus, tu es vraiment __le génie que tu penses être__ -## More info -There are a couple of articles on this website. They can give you some pointers on where to -go from here. +## Plus d'infos +Il y a quelques articles sur ce site web. Ils peuvent te donner quelques indications sur où aller à partir de maintenant. \ No newline at end of file diff --git a/translations/fr/try_ruby_60.md b/translations/fr/try_ruby_60.md index c35a67c0..d9f58fb2 100644 --- a/translations/fr/try_ruby_60.md +++ b/translations/fr/try_ruby_60.md @@ -1,16 +1,16 @@ --- -lang: EN -title: Say Your Name Backwards +lang: FR +title: Dis ton nom à l'envers answer: \w+ -ok: dooG +ok: ! iuO error: --- -A string is a set of characters the computer can process. Imagine the letters are on a string of -laundry line and the quotes are clothespins holding the ends. The quotes mark the beginning and end. +Une chaîne de caractères (string) est un ensemble de caractères que l'ordinateur peut traiter. Imagine que les lettres sont sur une corde +à linge et que les guillemets sont des pinces à linge tenant les extrémités. Les guillemets marquent le début et la fin. -To reverse your name, type: +Pour inverser ton nom, écris: "Jimmy".reverse -(Don't forget the dot!) +(N'oublie pas le point !) diff --git a/translations/fr/try_ruby_70.md b/translations/fr/try_ruby_70.md index 21cc4912..a8403508 100644 --- a/translations/fr/try_ruby_70.md +++ b/translations/fr/try_ruby_70.md @@ -1,13 +1,13 @@ --- -lang: EN -title: Counting the Letters +lang: FR +title: Compter les lettres answer: ^\d+$ -ok: Yep. Length is also a 'method' +ok: Oui. Length est aussi une 'methode' error: --- -You have used the reverse __method__ on your name! By enclosing your name in quotes, you made a string. Then you called the reverse method, which works on strings to flip all the letters backwards. +Tu as utilisé la __méthode__ reverse (__inverse__) sur ton nom ! En mettant ton nom entre guillemets, tu as créé une chaîne de caractères (string). Pour enfin appelé la méthode reverse qui fonctionne sur des chaînes de caractères (string) pour retourner toutes les lettres à l'envers. -Now, let us see how many letters are in your name: +Maintenant, voyons combien de lettres il y a dans ton nom : "Jimmy".length diff --git a/translations/fr/try_ruby_80.md b/translations/fr/try_ruby_80.md index 94ac396d..94858e90 100644 --- a/translations/fr/try_ruby_80.md +++ b/translations/fr/try_ruby_80.md @@ -1,17 +1,17 @@ --- -lang: EN -title: On Repeat +lang: FR +title: Répétition answer: (\w+) -ok: Nice to meet you.Nice to meet you.Nice to meet you. +ok: EnchantéEnchantéEnchantéEnchantéEnchanté error: --- -Now, you're probably wondering what any of this is good for. +Maintenant, tu te demandes probablement à quoi tout cela peut servir. -Well, I'm sure you've been to a website that screamed, __Hey, your password is too short!__ +Et bien, je suis sûr que tu as déjà été sur un site web qui a gueulé : __Hé, ton mot de passe est trop court !__ -See, some programs use that simple __.length__ code. +Tu as deviné ? certains programmes utilisent la méthode __.length__ (__longueur__) dans leur code. -Watch this. Let's multiply your name by 5. +Voyons voir, et si essayait de multipler ton nom par 5. "Jimmy" * 5 diff --git a/translations/fr/try_ruby_90.md b/translations/fr/try_ruby_90.md index 624cc902..407db1f9 100644 --- a/translations/fr/try_ruby_90.md +++ b/translations/fr/try_ruby_90.md @@ -1,30 +1,30 @@ --- -lang: EN -title: Hey, Summary #1 Already -answer: ^NoMethodError(.*)$ +lang: FR +title: Hé, Résumé #1 Déjà +answer: NoMethodError|undefined class: stretcher chapmark -ok: Nope, it is not possible to reverse a number. Click 'next' +ok: Nop, ce n'est pas possible d'inverser un nombre. Clique sur 'next'. error: --- -Let's look at what you've learned in the first minute. +Regardons ce que tu as appris dans la première minute. -### The editor -Typing code into the editor and clicking on run gives you an answer in the ouput window. -(Almost) all code gives an answer. +### L'éditeur +Écrire du code dans l'éditeur et cliquer sur "Run" te donne une réponse dans la fenêtre de sortie. +(Presque) tout le code donne une réponse. -### Numbers and strings -Numbers and strings are Ruby's math and text objects. +### Nombres et chaîne de caractères +Les nombres et les chaînes de caractères sont des objets mathématiques et textuels de Ruby. -### Methods -You've used English-language methods like reverse and length. And symbolic methods like the -multiplication method: \* -__Methods mean action!__ +### Méthodes +Tu as utilisé des méthodes en anglais comme reverse (__inverse__) et length (__longueur__) . Et des méthodes symboliques comme la +méthode de multiplication : \* +__Méthodes signifie action !__ -This is the essence of your learning. Taking simple things, toying with them and turning them into -new things. Feeling comfortable yet? I promise you are. +C'est l'essence de ton apprentissage. Prendre des choses simples, jouer avec elles et les transformer en +nouvelles choses. Tu te sens déjà à l'aise ? Je te confirme que oui. ## Okay, -let's do something uncomfortable. Try reversing a number: +Essayons quelques choses de malaisant. Tente d'inverser un nombre : 40.reverse From 5e5803d7713388d7c504af5dc9c8f5f5f1b43b66 Mon Sep 17 00:00:00 2001 From: Idris TAKERBOUST Date: Tue, 14 May 2024 15:45:07 +0200 Subject: [PATCH 3/3] Add 'FR' missing --- app/try_ruby.rb | 2 ++ translations/fr/try_ruby_320.md | 2 +- translations/fr/try_ruby_460.md | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/try_ruby.rb b/app/try_ruby.rb index f4e39e75..fcfa70be 100644 --- a/app/try_ruby.rb +++ b/app/try_ruby.rb @@ -124,6 +124,8 @@ def get_language language = 'de' when 'tr' language = 'tr' + when 'fr' + language = 'fr' else language = 'en' end diff --git a/translations/fr/try_ruby_320.md b/translations/fr/try_ruby_320.md index 90d3eab4..ad982876 100644 --- a/translations/fr/try_ruby_320.md +++ b/translations/fr/try_ruby_320.md @@ -1,5 +1,5 @@ --- -lang: EN +lang: FR title: Être ou ne pas être answer: load: poem = "My toast has flown from my hand\nAnd my toast has gone to the moon.\nYada yada yada\n" diff --git a/translations/fr/try_ruby_460.md b/translations/fr/try_ruby_460.md index 3e43666e..10d5dfbc 100644 --- a/translations/fr/try_ruby_460.md +++ b/translations/fr/try_ruby_460.md @@ -1,5 +1,5 @@ --- -lang: EN +lang: FR title: Pas une classe d'école, une classe ouvrière answer: ok: