Skip to content

Commit 8000512

Browse files
committed
feat: add parameter locale
1 parent a45621a commit 8000512

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ You can add custom components, save callback.
5757
| Props | Type | Description |
5858
| -------- | -------- | -------- |
5959
| value | `Object` | Editor initial value, you can pass the value of the save callback and resume the draft |
60+
| locale | `String` | Editor default locale. Now support 'cn' and 'en', default 'cn'. |
6061
| widgets | `Object` | Vue Components. Custom components for editor. see [Example](https://github.com/fireyy/vue-page-designer-widgets/blob/master/src/index.js) |
6162
| save | `(data) => void` | When you click the Save button, feed back to you to save the data |
6263
| upload | `(files) => Promise` | Editor upload function, allowing you to implement your own upload-file's request |
@@ -102,6 +103,16 @@ export default {
102103
</script>
103104
```
104105

106+
Set locale to EN
107+
108+
```html
109+
<template>
110+
<div id="app">
111+
<vue-page-designer locale="en" />
112+
</div>
113+
</template>
114+
```
115+
105116
## Parameter: `save`
106117

107118
```html

example/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:widgets="widgets"
66
:upload="handleUpload"
77
:upload-option="uploadOption"
8+
locale="cn"
89
@save="handleSave" />
910
</div>
1011
</template>

src/App.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ export default {
5656
mixins: [vpd],
5757
props: {
5858
value: Object,
59+
locale: {
60+
type: String,
61+
default: 'cn'
62+
},
5963
widgets: Object,
6064
upload: Function,
6165
uploadOption: Object
@@ -71,6 +75,8 @@ export default {
7175
loadSprite('//unpkg.com/vue-page-designer@0.7.1/dist/icons.svg', 'svgspriteit')
7276
},
7377
created () {
78+
// 默认语言切换
79+
i18n.locale = this.locale
7480
// 注册 widgets
7581
Vue.use(widget, {
7682
widgets: this.widgets

0 commit comments

Comments
 (0)