Skip to content
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

Translate Plugins [DONE] #40

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
50 changes: 25 additions & 25 deletions src/v2/guide/plugins.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
---
title: Plugins
title: Module
type: guide
order: 304
---

## Writing a Plugin
## Crearea Unui Modul

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:
Modulele de obicei adaugă funcționalitate globale la Vue. Nu există un domeniu de aplicare strict definit pentru un modul - există de obicei mai multe tipuri de module pe care le puteți crea:

1. Add some global methods or properties. e.g. [vue-custom-element](https://github.com/karol-f/vue-custom-element)
1. Care adaugă anumite metode sau proprietăți, 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. Care adaugă obiecte globale: directive/filtre/tranziții etc., ex. [vue-touch](https://github.com/vuejs/vue-touch)

3. Add some component options by global mixin. e.g. [vue-router](https://github.com/vuejs/vue-router)
3. Care adaugă anumite opțiuni pentru componente prin mixul global, ex. [vue-router](https://github.com/vuejs/vue-router)

4. Add some Vue instance methods by attaching them to Vue.prototype.
4. Care adaugă anumite metode ale instanței Vue atașându-le la Vue.prototype.

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. O bibliotecă care oferă un API propriu și în același timp injectează o combinație a celor enumerate de mai sus, ex. [vue-router](https://github.com/vuejs/vue-router)

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 modul Vue.js trebuie să conțină metoda `install`. Metoda va fi apelată cu constructorul `Vue` ca primul argument, împreună cu opțiunile posibile:

``` js
MyPlugin.install = function (Vue, options) {
// 1. add global method or property
// 1. adăugarea unei metode sau proprietăți globale
Vue.myGlobalMethod = function () {
// something logic ...
// ceva logică ...
}

// 2. add a global asset
Vue.directive('my-directive', {
bind (el, binding, vnode, oldVnode) {
// something logic ...
// ceva logică ...
}
...
})

// 3. inject some component options
// 3. Injectarea unor opțiuni pentru componente
Vue.mixin({
created: function () {
// something logic ...
// ceva logică ...
}
...
})

// 4. add an instance method
// 4. adăugarea unei metode ale instanței
Vue.prototype.$myMethod = function (methodOptions) {
// something logic ...
// ceva logică ...
}
}
```

## Using a Plugin
## Utilizarea Modulelor

Use plugins by calling the `Vue.use()` global method:
Pentru a utiliza modulul, trebuie să apelați metoda globală `Vue.use()`:

``` js
// calls `MyPlugin.install(Vue)`
// apelează `MyPlugin.install(Vue)`
Vue.use(MyPlugin)
```

You can optionally pass in some options:
Când instalați modulul, puteți transmite parametri suplimentari:

``` 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` vă împiedică automat de la utilizarea aceluiași modul de mai multe ori, astfel apelarea metodei de mai multe ori pe același modul va instala pluginul doar o singură dată.

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:
Unele module oficiale Vue.js cum ar fi `vue-router`, apelează automat `Vue.use()` dacă `Vue` este disponibil ca variabilă globală. Cu toate acestea dacă utilizați instrumentele din mediul modular, cum ar fi CommonJS, este întotdeauna necesar să apelați explicit `Vue.use()`:

``` js
// When using CommonJS via Browserify or Webpack
// Atunci când utilizați CommonJS prin Browserify sau Webpack
var Vue = require('vue')
var VueRouter = require('vue-router')

// Don't forget to call this
// Nu uitați să apelați metoda dată
Vue.use(VueRouter)
```

Checkout [awesome-vue](https://github.com/vuejs/awesome-vue#components--libraries) for a huge collection of community-contributed plugins and libraries.
Vezi [awesome-vue](https://github.com/vuejs/awesome-vue#components--libraries) o colecție imensă de module și biblioteci din comunitatea Vue.