An open API service indexing awesome lists of open source software.

https://github.com/jounqin/vue-translate

A translator directive for Vue.
https://github.com/jounqin/vue-translate

Last synced: 6 months ago
JSON representation

A translator directive for Vue.

Awesome Lists containing this project

README

          

# Vue Translate

A translator directive for Vue.

## The Basics

```js
var Vue = require('Vue');
var translate = require('vue-translate');
Vue.use(translate);

// the messages data
translate.messages = {
"hello": "你好"
};
```

## Use as directive

The `v-trans` directive will translate `title`, `arial-label`, `alt` and text content
automaticly.

```html

hello

你好

```

### Translate more attributes

If the message you want to translate is not on the default attributes, e.g. `data-message`,
you can pass it to `v-trans`.

```html

hello

你好

```

### Translate with variables

The translation messages can contain variables:

```js
translate.messages = {
"hello {{ name }}": "你好 {{ name }}"
};
```

If `{{ name }}` is `lepture`:

```html

hello {{ name }}

你好 lepture

```