-
Notifications
You must be signed in to change notification settings - Fork 103
Traduction forms.md #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
0aa076f
8398675
ee28734
d2e9883
4d1dab4
9c4cd1d
1da096b
0ccb6dd
8bef84d
2dd5a79
357a6f8
beead5b
35d8430
46c88e6
acc0e8c
7d33cd3
ba8ac57
036bf2f
07f1f0d
80525f9
c6542c8
0598b8b
1541722
c169ed8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
--- | ||
title: Form Input Bindings | ||
title: Liaisons sur les champs de formulaire | ||
type: guide | ||
order: 10 | ||
--- | ||
|
||
## Basic Usage | ||
## Usage basique | ||
|
||
<p class="tip">**Cette page est en cours de traduction française. Revenez une autre fois pour lire une traduction achevée ou [participez à la traduction française ici](https://github.com/vuejs-fr/vuejs.org).**</p>You can use the `v-model` directive to create two-way data bindings on form input and textarea elements. It automatically picks the correct way to update the element based on the input type. Although a bit magical, `v-model` is essentially syntax sugar for updating data on user input events, plus special care for some edge cases. | ||
Vous pouvez utilisez la directive `v-model` pour créer une liaison de donnée bidirectionnelle sur les champs de formulaire. Elle choisira automatiquement la bonne manière de mettre à jour l'élément en fonction du type de champ. Bien qu'un peu magique, `v-model` est essentiellement un sucre syntaxique pour mettre à jour les données lors des évènements utilisateurs sur les champs, ainsi que quelques traitements spéciaux pour certains cas particuliers. | ||
|
||
<p class="tip">`v-model` doesn't care about the initial value provided to an input or a textarea. It will always treat the Vue instance data as the source of truth.</p> | ||
<p class="tip">`v-model` ne prend pas en compte la valeur initiale (attribut "value") fournie pour un champ. Elle traitera toujours les données de l'instance de vue comme la source de vérité.</p> | ||
|
||
<p class="tip" id="vmodel-ime-tip">For languages that require an [IME](https://en.wikipedia.org/wiki/Input_method) (Chinese, Japanese, Korean etc.), you'll notice that `v-model` doesn't get updated during IME composition. If you want to cater for these updates as well, use `input` event instead.</p> | ||
<p class="tip" id="vmodel-ime-tip">Pour les langues qui requièrent une [méthode de saisie (IME)](https://fr.wikipedia.org/wiki/M%C3%A9thode_d%27entr%C3%A9e) (chinois, japonais, coréen etc...), vous remarquerez que `v-model` ne sera pas mise à jour durant l'exécution de la méthode de saisie.</p> | ||
|
||
### Text | ||
### Texte | ||
|
||
``` html | ||
<input v-model="message" placeholder="edit me"> | ||
<p>Message is: {{ message }}</p> | ||
<input v-model="message" placeholder="modifiez moi"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. modifiez-moi |
||
<p>Le message est : {{ message }}</p> | ||
``` | ||
|
||
{% raw %} | ||
<div id="example-1" class="demo"> | ||
<input v-model="message" placeholder="edit me"> | ||
<p>Message is: {{ message }}</p> | ||
<input v-model="message" placeholder="modifiez moi"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. modifiez-moi |
||
<p>Le message est : {{ message }}</p> | ||
</div> | ||
<script> | ||
new Vue({ | ||
|
@@ -34,21 +34,21 @@ new Vue({ | |
</script> | ||
{% endraw %} | ||
|
||
### Multiline text | ||
### Texte multiligne | ||
|
||
``` html | ||
<span>Multiline message is:</span> | ||
<span>Le message multiligne est :</span> | ||
<p style="white-space: pre">{{ message }}</p> | ||
<br> | ||
<textarea v-model="message" placeholder="add multiple lines"></textarea> | ||
<textarea v-model="message" placeholder="ajoutez plusieurs lignes"></textarea> | ||
``` | ||
|
||
{% raw %} | ||
<div id="example-textarea" class="demo"> | ||
<span>Multiline message is:</span> | ||
<span>Le message multiligne est :</span> | ||
<p style="white-space: pre">{{ message }}</p> | ||
<br> | ||
<textarea v-model="message" placeholder="add multiple lines"></textarea> | ||
<textarea v-model="message" placeholder="ajoutez plusieurs lignes"></textarea> | ||
</div> | ||
<script> | ||
new Vue({ | ||
|
@@ -62,12 +62,13 @@ new Vue({ | |
|
||
|
||
{% raw %} | ||
<p class="tip">Interpolation on textareas (<code><textarea>{{text}}</textarea></code>) won't work. Use <code>v-model</code> instead.</p> | ||
<p class="tip">L'interpolation sur les textarea (<code><textarea>{{text}}</textarea></code>) ne fonctionnera pas. Utilisez <code>v-model</code> à la place.</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ou
|
||
{% endraw %} | ||
|
||
### Checkbox | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @forresst pourquoi pas, je veux bien un avis tierce avant de le faire :) |
||
|
||
Single checkbox, boolean value: | ||
Checkbox seule, valeur booléenne : | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cette ligne est a retirer |
||
|
||
``` html | ||
<input type="checkbox" id="checkbox" v-model="checked"> | ||
|
@@ -88,7 +89,7 @@ new Vue({ | |
</script> | ||
{% endraw %} | ||
|
||
Multiple checkboxes, bound to the same Array: | ||
Checkboxes multiples, liées au même tableau (Array): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Il manque un espace avant |
||
|
||
``` html | ||
<input type="checkbox" id="jack" value="Jack" v-model="checkedNames"> | ||
|
@@ -98,7 +99,7 @@ Multiple checkboxes, bound to the same Array: | |
<input type="checkbox" id="mike" value="Mike" v-model="checkedNames"> | ||
<label for="mike">Mike</label> | ||
<br> | ||
<span>Checked names: {{ checkedNames }}</span> | ||
<span>Noms cochés : {{ checkedNames }}</span> | ||
``` | ||
|
||
``` js | ||
|
@@ -119,7 +120,7 @@ new Vue({ | |
<input type="checkbox" id="mike" value="Mike" v-model="checkedNames"> | ||
<label for="mike">Mike</label> | ||
<br> | ||
<span>Checked names: {{ checkedNames }}</span> | ||
<span>Noms cochés : {{ checkedNames }}</span> | ||
</div> | ||
<script> | ||
new Vue({ | ||
|
@@ -135,23 +136,23 @@ new Vue({ | |
|
||
|
||
``` html | ||
<input type="radio" id="one" value="One" v-model="picked"> | ||
<label for="one">One</label> | ||
<input type="radio" id="one" value="Un" v-model="picked"> | ||
<label for="one">Un</label> | ||
<br> | ||
<input type="radio" id="two" value="Two" v-model="picked"> | ||
<label for="two">Two</label> | ||
<input type="radio" id="two" value="Deux" v-model="picked"> | ||
<label for="two">Deux</label> | ||
<br> | ||
<span>Picked: {{ picked }}</span> | ||
<span>Choisi : {{ picked }}</span> | ||
``` | ||
{% raw %} | ||
<div id="example-4" class="demo"> | ||
<input type="radio" id="one" value="One" v-model="picked"> | ||
<label for="one">One</label> | ||
<input type="radio" id="one" value="Un" v-model="picked"> | ||
<label for="one">Un</label> | ||
<br> | ||
<input type="radio" id="two" value="Two" v-model="picked"> | ||
<label for="two">Two</label> | ||
<input type="radio" id="two" value="Deux" v-model="picked"> | ||
<label for="two">Deux</label> | ||
<br> | ||
<span>Picked: {{ picked }}</span> | ||
<span>Choisi : {{ picked }}</span> | ||
</div> | ||
<script> | ||
new Vue({ | ||
|
@@ -165,15 +166,15 @@ new Vue({ | |
|
||
### Select | ||
|
||
Single select: | ||
Select à choix unique : | ||
|
||
``` html | ||
<select v-model="selected"> | ||
<option>A</option> | ||
<option>B</option> | ||
<option>C</option> | ||
</select> | ||
<span>Selected: {{ selected }}</span> | ||
<span>Sélectionné : {{ selected }}</span> | ||
``` | ||
{% raw %} | ||
<div id="example-5" class="demo"> | ||
|
@@ -182,7 +183,7 @@ Single select: | |
<option>B</option> | ||
<option>C</option> | ||
</select> | ||
<span>Selected: {{ selected }}</span> | ||
<span>Sélectionné : {{ selected }}</span> | ||
</div> | ||
<script> | ||
new Vue({ | ||
|
@@ -194,7 +195,7 @@ new Vue({ | |
</script> | ||
{% endraw %} | ||
|
||
Multiple select (bound to Array): | ||
Select à choix multiples (lié à un tableau) : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Puisque nous avions
Je propose de faire de même, ce qui nous permet de conserver Array entre parenthèse
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @haeresis je suis d'accord, j'ai juste suivi l'original au plus près plutôt que de l'améliorer. C'est une règle que je m'impose à tort ou à raison. Elaborer une charte de traduction avec 4 ou 5 règles qu'on suit ne nous ferait pas de mal... |
||
|
||
``` html | ||
<select v-model="selected" multiple> | ||
|
@@ -203,7 +204,7 @@ Multiple select (bound to Array): | |
<option>C</option> | ||
</select> | ||
<br> | ||
<span>Selected: {{ selected }}</span> | ||
<span>Sélectionné(s) : {{ selected }}</span> | ||
``` | ||
{% raw %} | ||
<div id="example-6" class="demo"> | ||
|
@@ -213,7 +214,7 @@ Multiple select (bound to Array): | |
<option>C</option> | ||
</select> | ||
<br> | ||
<span>Selected: {{ selected }}</span> | ||
<span>Sélectionné(s) : {{ selected }}</span> | ||
</div> | ||
<script> | ||
new Vue({ | ||
|
@@ -225,25 +226,25 @@ new Vue({ | |
</script> | ||
{% endraw %} | ||
|
||
Dynamic options rendered with `v-for`: | ||
Options dynamiques générées avec `v-for` : | ||
|
||
``` html | ||
<select v-model="selected"> | ||
<option v-for="option in options" v-bind:value="option.value"> | ||
{{ option.text }} | ||
</option> | ||
</select> | ||
<span>Selected: {{ selected }}</span> | ||
<span>Sélectionné : {{ selected }}</span> | ||
``` | ||
``` js | ||
new Vue({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Il faudrait traduire "One", "Two" et "Three" dans le tableau There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pushé |
||
el: '...', | ||
data: { | ||
selected: 'A', | ||
options: [ | ||
{ text: 'One', value: 'A' }, | ||
{ text: 'Two', value: 'B' }, | ||
{ text: 'Three', value: 'C' } | ||
{ text: 'Un', value: 'A' }, | ||
{ text: 'Deux', value: 'B' }, | ||
{ text: 'Trois', value: 'C' } | ||
] | ||
} | ||
}) | ||
|
@@ -255,41 +256,42 @@ new Vue({ | |
{{ option.text }} | ||
</option> | ||
</select> | ||
<span>Selected: {{ selected }}</span> | ||
<span>Sélectionné : {{ selected }}</span> | ||
</div> | ||
<script> | ||
new Vue({ | ||
el: '#example-7', | ||
data: { | ||
selected: 'A', | ||
options: [ | ||
{ text: 'One', value: 'A' }, | ||
{ text: 'Two', value: 'B' }, | ||
{ text: 'Three', value: 'C' } | ||
{ text: 'Un', value: 'A' }, | ||
{ text: 'Deux', value: 'B' }, | ||
{ text: 'Trois', value: 'C' } | ||
] | ||
} | ||
}) | ||
</script> | ||
{% endraw %} | ||
|
||
## Value Bindings | ||
## Liaisons des attributs value | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cette ligne est a retirer |
||
Pour les options de bouton radio, checkbox et select, les valeurs de liaison de `v-model` sont habituellement des chaînes de caractères statiques (ou des booléens pour une checkbox) : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pour les boutons radio, les cases à cocher et les listes d'options |
||
|
||
For radio, checkbox and select options, the `v-model` binding values are usually static strings (or booleans for checkbox): | ||
|
||
``` html | ||
<!-- `picked` is a string "a" when checked --> | ||
<!-- `picked` sera une chaîne de caractères "a" quand le bouton radio sera sélectionné --> | ||
<input type="radio" v-model="picked" value="a"> | ||
|
||
<!-- `toggle` is either true or false --> | ||
<!-- `toggle` est soit true soit false --> | ||
<input type="checkbox" v-model="toggle"> | ||
|
||
<!-- `selected` is a string "abc" when selected --> | ||
<!-- `selected` sera une chaîne de caractères "abc" quand l'option sera sélectionnée --> | ||
<select v-model="selected"> | ||
<option value="abc">ABC</option> | ||
</select> | ||
``` | ||
|
||
But sometimes we may want to bind the value to a dynamic property on the Vue instance. We can use `v-bind` to achieve that. In addition, using `v-bind` allows us to bind the input value to non-string values. | ||
Mais parfois nous pouvons souhaiter lier la valeur à une propriété dynamique de l'instance de Vue. Nous pouvons réaliser cela en utilisant `v-bind`. De plus, utiliser `v-bind` nous permet de lier la valeur de l'input à des valeurs qui ne sont pas des chaînes de caractères. | ||
|
||
### Checkbox | ||
|
||
|
@@ -303,9 +305,9 @@ But sometimes we may want to bind the value to a dynamic property on the Vue ins | |
``` | ||
|
||
``` js | ||
// when checked: | ||
// lorsque c'est coché : | ||
vm.toggle === vm.a | ||
// when unchecked: | ||
// lorsque que c'est décoché : | ||
vm.toggle === vm.b | ||
``` | ||
|
||
|
@@ -316,59 +318,59 @@ vm.toggle === vm.b | |
``` | ||
|
||
``` js | ||
// when checked: | ||
// Lorsque c'est choisi : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pas de majuscule |
||
vm.pick === vm.a | ||
``` | ||
|
||
### Select Options | ||
### Options des select | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ou
|
||
|
||
``` html | ||
<select v-model="selected"> | ||
<!-- inline object literal --> | ||
<!-- objet littéral en ligne --> | ||
<option v-bind:value="{ number: 123 }">123</option> | ||
</select> | ||
``` | ||
|
||
``` js | ||
// when selected: | ||
// Lorsque c'est sélectionné : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pas de majuscule |
||
typeof vm.selected // -> 'object' | ||
vm.selected.number // -> 123 | ||
``` | ||
|
||
## Modifiers | ||
## Modificateurs | ||
|
||
### `.lazy` | ||
|
||
By default, `v-model` syncs the input with the data after each `input` event (with the exception of IME composition as [stated above](#vmodel-ime-tip)). You can add the `lazy` modifier to instead sync after `change` events: | ||
Par défaut, `v-model` synchronise l'input avec les données après chaque évènement `input` (à l'exception de l'exécution d'une méthode de saisie comme [dit plus haut](#vmodel-ime-tip)). Vous pouvez ajouter le modificateur `lazy` pour synchroniser après les évènements `change` à la place : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. je traduirais « le champ » pour le premier input car ce mécanisme peut être ajouté à un textarea et je pense que là on parle de input au sens large.
Le second est bon puisqu'il fait référence à l'action de taper un caractère (en plus entre ` donc pas de soucis). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @haeresis je pense que ça fait référence à l'ensemble des évènements pour les inputs (voir ici : https://www.w3schools.com/js/js_events_examples.asp ) mais je suppose en effet que ça s'applique de la même manière au textarea, du coup j'ai appliqué la modif |
||
|
||
``` html | ||
<!-- synced after "change" instead of "input" --> | ||
<!-- synchronisé après le "change" au lieu du "input" --> | ||
<input v-model.lazy="msg" > | ||
``` | ||
|
||
### `.number` | ||
|
||
If you want user input to be automatically typecast as a number, you can add the `number` modifier to your `v-model` managed inputs: | ||
Si vous voulez que la saisie utilisateur soit automatiquement typée en tant que nombre, vous pouvez ajouter le modificateur `number` à vos input gérés par `v-model` : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "typée" n'équivaut pas exactement à la traduction de "cast". Le terme exact serait plutôt "transtypée" mais dans le vocabulaire courant on peut simplement écrire "convertie en nombre" vos champs ou vos éléments de saisie (pas juste les éléments input, ça couvre aussi textarea et select ici) |
||
|
||
``` html | ||
<input v-model.number="age" type="number"> | ||
``` | ||
|
||
This is often useful, because even with `type="number"`, the value of HTML input elements always returns a string. | ||
C'est souvent utile, parce que même avec `type="number"`, la valeur des éléments input HTML retourne toujours une chaîne de caractères. | ||
|
||
### `.trim` | ||
|
||
If you want user input to be trimmed automatically, you can add the `trim` modifier to your `v-model` managed inputs: | ||
c'est vous voulez que les saisies utilisateurs soit automatiquement nettoyées des espaces superflus, vous pouvez ajouter le modificateur `trim` à vos champs gérés par `v-model` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. les |
||
|
||
```html | ||
<input v-model.trim="msg"> | ||
``` | ||
|
||
## `v-model` with Components | ||
## `v-model` avec les composants | ||
|
||
> If you're not yet familiar with Vue's components, just skip this for now. | ||
> Si vous n'êtes pas encore familier avec les composants de Vue, passez cette section pour le moment. | ||
|
||
HTML's built-in input types won't always meet your needs. Fortunately, Vue components allow you to build reusable inputs with completely customized behavior. These inputs even work with `v-model`! To learn more, read about [custom inputs](components.html#Form-Input-Components-using-Custom-Events) in the Components guide. | ||
Les types de champ standards HTML ne couvriront pas toujours vos besoins. Heureusement, les composants de Vue vous permettent de construire des inputs avec un comportement complètement customisé. Ces inputs fonctionnent même avec `v-model` ! Pour en apprendre plus, lisez [inputs personnalisés](components.html#Form-Input-Components-using-Custom-Events) dans le guide des composants. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
car on parle de bien plus qu'un simple tag input ici. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @haeresis on traduira donc "inputs personnalisés" par "champs personnalisés" ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep ! |
||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sur les champs de formulaire (les éléments input et textarea). Elle choisira...
la bonne manière de mettre à jour l'élément en fonction du type de champ de formulaire. Bien qu'un...
v-model
est essentiellement du sucre syntaxiqueUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@forresst mon souci avec "input et textarea" c'est que ça ne couvre pas tout le spectre (il manque checkbox et select), c'est pour ça que je suis resté à champ => pour faire passer l'idée que ça marche sur tous les champs.
J'ai l'impression que "input" a un sens bien plus large en anglais (tout ce qui permet d'entrer une donnée) qui inclue du coup checkbox et select. Pourquoi pas le textarea ? mystère ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Peut-être qu'il faut demander sur le repo officiel (créer une issue) pour améliorer ou soulever le doute.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@forresst pour "sucre syntaxique" j'attends un avis tierce : j'ai souvent lu et entendu "un sucre syntaxique" ou "du sucre syntaxique" en français pour cette utilisation concernant non pas un ensemble mais juste une notation précise ( http://jargonf.org/wiki/sucre_syntaxique ) donc pour moi c'est bon en l'état
Comme tu dis, le lien wikipedia n'est pas dans l'original du coup je ne suis pas partisant de l'ajouter puisqu'une recherche google suffit à trouver en première résultat la page en question. Après si je suis le seul à être habitué à cette expression, il faudra changer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pour ma part :
On garde : un sucre syntaxique, du sucre syntaxique comme souvent lu sur des traductions pour ES6.
Pas de lien : pas de lien si pas dans le texte original, c'est le parti pris que nous avons suivi pour le moment. Pour ma part je ne suis pas contre mettre des liens mêmes s'ils ne sont pas dans l'original car beaucoup de traduction on souvent un exposant avec un numéro et un complément en pied de page qui n'existe pas dans l'original, mais ça fait parti d'un débat à ouvrir ailleurs :)
On ajoute : pour compléter ce que @forresst propose je mettrais plutôt :
car ce sont les 4 seules tag HTML pour les formulaire (checkbox, radio, etc. étant inclut dans input)
http://www.startyourdev.com/html/tag-html-balise-form