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.
- Host: GitHub
- URL: https://github.com/jounqin/vue-translate
- Owner: JounQin
- Created: 2015-08-12T10:12:35.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T02:26:34.000Z (almost 2 years ago)
- Last Synced: 2025-04-15T09:11:52.812Z (6 months ago)
- Size: 1.95 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
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
```