Skip to content

Traduction de plugins.md #69

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

Merged
merged 4 commits into from
Jun 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions src/v2/guide/plugins.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
---
title: Plugins (En)
title: Plugins
type: guide
order: 18
---

## Writing a Plugin
## Écrire un plugin

<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><p>Plugins usually add global-level functionality to Vue. There is no strictly defined scope for a plugin - there are typically several types of plugins you can write:</p>
Les plugins sont habituellement ajoutés au niveau des fonctionnalités globales de Vue. Il y a un cadre strictement défini pour un plugin et il y a divers types de plugins que vous pouvez écrire pour :

1. Add some global methods or properties. e.g. [vue-custom-element](https://github.com/karol-f/vue-custom-element)
1. Ajouter plusieurs méthodes globales ou propriétés. Par ex. [vue-custom-element](https://github.com/karol-f/vue-custom-element)

2. Add one or more global assets: directives/filters/transitions etc. e.g. [vue-touch](https://github.com/vuejs/vue-touch)
2. Ajouter une ou plusieurs ressource global : directives, filters, transitions, etc. Par ex. [vue-touch](https://github.com/vuejs/vue-touch)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ressources globales


3. Add some component options by global mixin. e.g. [vuex](https://github.com/vuejs/vuex)
3. Ajouter plusieurs options de composant avec un mixin global. Par ex. [vuex](https://github.com/vuejs/vuex)

4. Add some Vue instance methods by attaching them to Vue.prototype.
4. Ajouter des méthodes d'instance de Vue en les reliant au prototype de Vue.

5. A library that provides an API of its own, while at the same time injecting some combination of the above. e.g. [vue-router](https://github.com/vuejs/vue-router)
5. Fournir une bibliothèque avec sa propre API, qui injecte en même temps certains éléments précédemment cités. Par ex. [vue-router](https://github.com/vuejs/vue-router)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Une bibliothèque qui fournit sa propre API, et qui en même temps injecte une combinaison des points précédents.


A Vue.js plugin should expose an `install` method. The method will be called with the `Vue` constructor as the first argument, along with possible options:
Un plugin Vue.js doit exposer une méthode `install`. Cette méthode sera appelée avec le constructeur de `Vue` en tant que premier argument, avec les options possibles suivantes :

``` js
MyPlugin.install = function (Vue, options) {
// 1. add global method or property
// 1. ajouter une méthode globale ou une propriété
Vue.myGlobalMethod = function () {
// something logic ...
// de la logique de code...
}

// 2. add a global asset
// 2. ajouter une ressource global

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

globale

Vue.directive('my-directive', {
bind (el, binding, vnode, oldVnode) {
// something logic ...
// de la logique de code...
}
...
})

// 3. inject some component options
// 3. injecter des options de composant
Vue.mixin({
created: function () {
// something logic ...
// de la logique de code...
}
...
})

// 4. add an instance method
// 4. ajouter une méthode d'instance
Vue.prototype.$myMethod = function (options) {
// something logic ...
// de la logique de code...
}
}
```

## Using a Plugin
## Utiliser un plugin

Use plugins by calling the `Vue.use()` global method:
Utiliser un plugin en appelant la méthode globale `Vue.use()` :

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Une fois n'est pas coutume, l'usage de l'infinitif fait de toutes ces phrases des phrases nominales, ce qui selon moi est en rupture avec le reste du guide. Je préfère largement l'usage de l'impératif, mais je pense qu'on aura du mal à se mettre d'accord

Copy link
Member Author

@MachinisteWeb MachinisteWeb Jun 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'y songe, j'y songe. Je médite, je médite. Naturellement j'utilise l'impératif alors pour le moment je reste consistant avec moi-même. Il me faudrait un chantier dédié (PR) pour bien cerner les nuances j'imagine. J'en ai également déjà parlé mais c'est pas ma priorité. Je m'inspirerais de l'API p-e car je pense bien que tu utilises l'infinitif.


``` js
// calls `MyPlugin.install(Vue)`
// appel `MyPlugin.install(Vue)`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appelle

Vue.use(MyPlugin)
```

You can optionally pass in some options:
Vous pouvez optionnellement passer certaines options :

``` js
Vue.use(MyPlugin, { someOption: true })
```

`Vue.use` automatically prevents you from using the same plugin more than once, so calling it multiple times on the same plugin will install the plugin only once.
`Vue.use` empêchera automatiquement l'utilisation du même plugin plusieurs fois. Ainsi appeler de multiple fois le même plugin ne l'installera qu'une fois.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(virgule après Ainsi : http://www.langue-fr.net/Aussi-Ainsi-difference-et-construction)

appeler cette fonction plusieurs fois sur le même plugin n'installera le plugin qu'une seule fois


Some plugins provided by Vue.js official plugins such as `vue-router` automatically calls `Vue.use()` if `Vue` is available as a global variable. However in a module environment such as CommonJS, you always need to call `Vue.use()` explicitly:
Certains plugins fournis officiellement par Vue.js comme `vue-router` appelle automatiquement `Vue.use()` si `Vue` est disponible en tant que variable globale. Cependant, dans un environnement modulaire comme avec CommonJS, vous devrez toujours manuellement appeler `Vue.use()` :

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appellent

explicitly => explicitement


``` js
// When using CommonJS via Browserify or webpack
// En utilisant CommonJS depuis Browserify ou webpack
var Vue = require('vue')
var VueRouter = require('vue-router')

// Don't forget to call this
// N'oubliez pas de l'appeler
Vue.use(VueRouter)
```

Checkout [awesome-vue](https://github.com/vuejs/awesome-vue#components--libraries) for a huge collection of community-contributed plugins and libraries.
Consultez [awesome-vue](https://github.com/vuejs/awesome-vue#components--libraries) pour une large collection de plugin et bibliothèque fournis par la contribution de la communauté.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plugins et bibliothèques