Skip to content

Commit 78858b6

Browse files
committed
feat: i18n for editor
1 parent 3258468 commit 78858b6

File tree

11 files changed

+244
-46
lines changed

11 files changed

+244
-46
lines changed

front-end/h5/src/components/core/editor/canvas/edit.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,32 @@ import Shape from '../../support/shape'
33

44
const contextmenuOptions = [
55
{
6+
i18nLabel: 'editor.centerPanel.contextMenu.copy',
67
label: '复制',
78
value: 'copy'
89
},
910
{
11+
i18nLabel: 'editor.centerPanel.contextMenu.delete',
1012
label: '删除',
1113
value: 'delete'
1214
},
1315
{
16+
i18nLabel: 'editor.centerPanel.contextMenu.moveToTop',
1417
label: '置顶',
1518
value: 'move2Top'
1619
},
1720
{
21+
i18nLabel: 'editor.centerPanel.contextMenu.moveToBottom',
1822
label: '置底',
1923
value: 'move2Bottom'
2024
},
2125
{
26+
i18nLabel: 'editor.centerPanel.contextMenu.moveUp',
2227
label: '上移',
2328
value: 'addZindex'
2429
},
2530
{
31+
i18nLabel: 'editor.centerPanel.contextMenu.moveDown',
2632
label: '下移',
2733
value: 'minusZindex'
2834
}
@@ -231,7 +237,7 @@ export default {
231237
zIndex: 999
232238
}}
233239
>
234-
{ contextmenuOptions.map(option => <a-menu-item key={option.value} data-command={option.value}>{option.label}</a-menu-item>) }
240+
{ contextmenuOptions.map(option => <a-menu-item key={option.value} data-command={option.value}>{this.$t(option.i18nLabel)}</a-menu-item>) }
235241
</a-menu>
236242
: null
237243
}

front-end/h5/src/components/core/editor/edit-panel/action.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default {
1616
created () {},
1717
render (h) {
1818
const ele = this.editingElement
19-
if (!ele) return (<span>请先选择一个元素</span>)
19+
if (!ele) return (<span>{this.$t('editor.editPanel.common.empty')}</span>)
2020
return (<div>
2121
TODO
2222
</div>)

front-end/h5/src/components/core/editor/edit-panel/animation.js

+17-13
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,17 @@ export default {
106106
renderAnimationOptions (animationOption) {
107107
return (
108108
<a-form layout="horizontal">
109-
<a-form-item label="动画类型" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }}>
109+
<a-form-item label={this.$t('editor.editPanel.animation.type')} labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }}>
110110
{/* <a-popover placement="left" title="动画列表" trigger="click">
111111
<template slot="content">
112112
{this.renderAvaiableAnimations()}
113113
</template>
114114
<a-button type="primary">动画列表</a-button>
115115
</a-popover> */}
116-
<a-button type="link" size="small" icon="ordered-list" onClick={() => { this.drawerVisible = true }}>动画列表</a-button>
116+
{/* 动画列表 */}
117+
<a-button type="link" size="small" icon="ordered-list" onClick={() => { this.drawerVisible = true }}>{this.$t('editor.editPanel.animation.list')}</a-button>
117118
</a-form-item>
118-
<a-form-item label="动画时间" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
119+
<a-form-item label={this.$t('editor.editPanel.animation.duration')} labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
119120
<a-form-item style={{ display: 'inline-block', width: 'calc(50% - 12px)' }}>
120121
<a-slider
121122
defaultValue={2}
@@ -132,15 +133,15 @@ export default {
132133
min={0}
133134
max={20}
134135
size="small"
135-
formatter={value => `${value}秒`}
136+
formatter={value => `${value}(s)`}
136137
value={animationOption.duration}
137138
onChange={value => {
138139
animationOption.duration = value
139140
}}
140141
/>
141142
</a-form-item>
142143
</a-form-item>
143-
<a-form-item label="延迟时间" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
144+
<a-form-item label={this.$t('editor.editPanel.animation.type')} labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
144145
<a-form-item style={{ display: 'inline-block', width: 'calc(50% - 12px)' }}>
145146
<a-slider
146147
defaultValue={2}
@@ -157,15 +158,15 @@ export default {
157158
min={0}
158159
max={20}
159160
size="small"
160-
formatter={value => `${value}秒`}
161+
formatter={value => `${value}(s)`}
161162
value={animationOption.delay}
162163
onChange={value => {
163164
animationOption.delay = value
164165
}}
165166
/>
166167
</a-form-item>
167168
</a-form-item>
168-
<a-form-item label="运行次数" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
169+
<a-form-item label={this.$t('editor.editPanel.animation.iteration')} labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
169170
<a-form-item style={{ display: 'inline-block', width: 'calc(50% - 12px)' }}>
170171
<a-slider
171172
defaultValue={2}
@@ -182,15 +183,15 @@ export default {
182183
min={0}
183184
max={20}
184185
size="small"
185-
formatter={value => `${value}次`}
186+
formatter={value => `${value}(times)`}
186187
value={animationOption.interationCount}
187188
onChange={value => {
188189
animationOption.interationCount = value
189190
}}
190191
/>
191192
</a-form-item>
192193
</a-form-item>
193-
<a-form-item label="循环播放" labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
194+
<a-form-item label={this.$t('editor.editPanel.animation.inifinite')} labelCol={{ span: 5 }} wrapperCol={{ span: 16, offset: 2 }} style="margin-bottom:0;">
194195
<a-switch
195196
value={animationOption.infinite}
196197
onChange={value => {
@@ -204,12 +205,13 @@ export default {
204205
},
205206
render (h) {
206207
const ele = this.editingElement
207-
if (!ele) return (<span>请先选择一个元素</span>)
208+
if (!ele) return (<span>{this.$t('editor.editPanel.common.empty')}</span>)
208209
return (
209210
<div class="main-animate widget" id="animation-edit-panel">
210211
<a-button-group>
211-
<a-button type="primary" onClick={this.addAnimation}><a-icon type="plus" />添加动画</a-button>
212-
<a-button type="primary" onClick={this.runAnimate}>运行动画<a-icon type="right-circle" /></a-button>
212+
{/* 添加动画、运行动画 */}
213+
<a-button type="primary" onClick={this.addAnimation}><a-icon type="plus" />{this.$t('editor.editPanel.animation.add')}</a-button>
214+
<a-button type="primary" onClick={this.runAnimate}>{this.$t('editor.editPanel.animation.run')}<a-icon type="right-circle" /></a-button>
213215
</a-button-group>
214216
{
215217
// Q:这边为何这样写:this.animationQueue.length && ?
@@ -228,7 +230,9 @@ export default {
228230
this.animationQueue.map((addedAnimation, index) => (
229231
<a-collapse-panel key={`${index}`}>
230232
<template slot="header">
231-
<span>动画{index + 1}</span>
233+
{/* #!zh: 动画{index + 1} */}
234+
{/* #!en: Animation{index + 1}</span> */}
235+
<span>{this.$t('editor.editPanel.animation.title', { index: index + 1 })}</span>
232236
<a-tag color="orange">{animationValue2Name[addedAnimation.type] || addedAnimation.type }</a-tag>
233237
<a-icon type="delete" onClick={() => this.deleteAnimate(index)} title="删除动画"></a-icon>
234238
</template>

front-end/h5/src/components/core/editor/edit-panel/props.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default {
6969
},
7070
render (h) {
7171
const ele = this.editingElement
72-
if (!ele) return (<span>请先选择一个元素</span>)
72+
if (!ele) return (<span>{this.$t('editor.editPanel.common.empty')}</span>)
7373
this.mixinEnhancedPropsEditor(ele)
7474
return this.renderPropsEditorPanel(h, ele)
7575
}

front-end/h5/src/components/core/editor/edit-panel/script.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default {
4646
},
4747
render (h) {
4848
const ele = this.editingElement
49-
if (!ele) return (<span>请先选择一个元素</span>)
49+
if (!ele) return (<span>{this.$t('editor.editPanel.common.empty')}</span>)
5050
return <div>
5151
<a-button onClick={this.mixinScript} disabled>使用脚本</a-button>
5252
<div style={{ margin: '20px' }}></div>

front-end/h5/src/components/core/editor/index.js

+36-27
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,19 @@ import LangSelect from '@/components/common/header/LangSelect.vue'
2020

2121
const sidebarMenus = [
2222
{
23+
i18nLabel: 'editor.sidebar.components',
2324
label: '组件列表',
2425
value: 'pluginList',
2526
antIcon: 'bars'
2627
},
2728
{
29+
i18nLabel: 'editor.sidebar.pages',
2830
label: '页面管理',
2931
value: 'pageManagement',
3032
antIcon: 'snippets'
3133
},
3234
{
35+
i18nLabel: 'editor.sidebar.templates',
3336
label: '免费模板',
3437
value: 'freeTemplate',
3538
antIcon: 'appstore'
@@ -38,43 +41,50 @@ const sidebarMenus = [
3841

3942
const fixedTools = [
4043
{
44+
i18nTooltip: 'editor.fixedTool.undo',
4145
'tooltip': '撤消', // TODO 支持快捷键
4246
'text': '撤消',
4347
'icon': 'mail-reply',
4448
'action': () => undoRedoHistory.undo()
4549
},
4650
{
51+
i18nTooltip: 'editor.fixedTool.redo',
4752
'tooltip': '恢复',
4853
'text': '恢复',
4954
'icon': 'mail-forward',
5055
'action': () => undoRedoHistory.redo()
5156
},
5257
{
58+
i18nTooltip: 'editor.fixedTool.preview',
5359
'tooltip': '刷新预览',
5460
'text': '刷新预览',
5561
'icon': 'eye',
5662
'action': function () { this.previewVisible = true }
5763
},
5864
{
65+
i18nTooltip: 'editor.fixedTool.copyCurrentPage',
5966
'tooltip': '复制当前页',
6067
'text': '复制当前页',
6168
'icon': 'copy',
6269
'action': function () { this.pageManager({ type: 'copy' }) }
6370
},
6471
{
72+
i18nTooltip: 'editor.fixedTool.importPSD',
6573
'tooltip': '导入PSD',
6674
'text': 'Ps',
6775
'icon': '',
6876
'action': '',
6977
'disabled': true
7078
},
7179
{
80+
i18nTooltip: 'editor.fixedTool.zoomOut',
7281
'tooltip': '放大画布',
7382
'text': '放大画布',
7483
'icon': 'plus',
7584
'action': function () { this.scaleRate += 0.25 }
7685
},
7786
{
87+
i18nTooltip: 'editor.fixedTool.zoomIn',
7888
'tooltip': '缩小画布',
7989
'text': '缩小画布',
8090
'icon': 'minus',
@@ -139,15 +149,15 @@ export default {
139149
return (
140150
this.pages.map((page, index) => (
141151
<span style={{ display: 'flex', justifyContent: 'space-between', padding: '12px 0' }}>
142-
<span>{index + 1}</span>
152+
{/* #!en: Page<Index> */}
153+
{/* #!zh: 第<Index>页面 */}
154+
<span>{this.$t('editor.pageManager.title', { index })}</span>
143155
<a-dropdown trigger={['hover']} placement='bottomCenter'>
144-
<a class="ant-dropdown-link" href="#">
145-
<a-icon type="down" />
146-
</a>
156+
<a class="ant-dropdown-link" href="#"><a-icon type="down" /></a>
147157
<a-menu slot="overlay" onClick={({ key }) => { this.pageManager({ type: key }) }}>
148-
<a-menu-item key="add"><a-icon type="user" />新增页面</a-menu-item>
149-
<a-menu-item key="copy"><a-icon type="user" />复制页面</a-menu-item>
150-
<a-menu-item key="delete"><a-icon type="user" />删除页面</a-menu-item>
158+
<a-menu-item key="add"><a-icon type="user" />{this.$t('editor.pageManager.actions.add')}</a-menu-item>
159+
<a-menu-item key="copy"><a-icon type="user" />{this.$t('editor.pageManager.actions.copy')}</a-menu-item>
160+
<a-menu-item key="delete"><a-icon type="user" />{this.$t('editor.pageManager.actions.delete')}</a-menu-item>
151161
</a-menu>
152162
</a-dropdown>
153163
</span>
@@ -163,19 +173,22 @@ export default {
163173
<a-layout id="luban-editor-layout" style={{ height: '100vh' }}>
164174
<a-layout-header class="header">
165175
<LogoOfHeader />
176+
<LangSelect style="float: right;cursor: pointer;" />
166177
{/* TODO we can show the plugins shortcuts here */}
167178
<a-menu
168179
theme="dark"
169180
mode="horizontal"
170181
defaultSelectedKeys={['2']}
171182
style={{ lineHeight: '64px', float: 'right', background: 'transparent' }}
172183
>
173-
<a-menu-item key="1" class="transparent-bg"><a-button type="primary" size="small" onClick={() => { this.previewVisible = true }}>预览</a-button></a-menu-item>
174-
<a-menu-item key="2" class="transparent-bg"><a-button size="small" onClick={() => this.saveWork({ isSaveCover: true })} loading={this.saveWork_loading || this.uploadWorkCover_loading}>保存</a-button></a-menu-item>
184+
{/* 保存、预览、发布、设置为模板 */}
185+
<a-menu-item key="1" class="transparent-bg"><a-button type="primary" size="small" onClick={() => { this.previewVisible = true }}>{this.$t('editor.header.preview')}</a-button></a-menu-item>
186+
<a-menu-item key="2" class="transparent-bg"><a-button size="small" onClick={() => this.saveWork({ isSaveCover: true })} loading={this.saveWork_loading || this.uploadWorkCover_loading}>{this.$t('editor.header.save')}</a-button></a-menu-item>
175187
{/* <a-menu-item key="3" class="transparent-bg"><a-button size="small">发布</a-button></a-menu-item> */}
176188
<a-menu-item key="3" class="transparent-bg">
177189
<a-dropdown-button onClick={() => {}} size="small">
178-
发布
190+
{/* 发布 */}
191+
{this.$t('editor.header.publish')}
179192
<a-menu slot="overlay" onClick={({ key }) => {
180193
switch (key) {
181194
case 'setAsTemplate':
@@ -187,7 +200,8 @@ export default {
187200
}}>
188201
<a-menu-item key="setAsTemplate">
189202
<a-spin spinning={this.setWorkAsTemplate_loading} size="small">
190-
<a-icon type="cloud-upload" />设置为模板
203+
{/* 设置为模板 */}
204+
<a-icon type="cloud-upload" />{this.$t('editor.header.setAsTemplate')}
191205
</a-spin>
192206
</a-menu-item>
193207
{/* <a-menu-item key="2"><a-icon type="user" />2nd menu item</a-menu-item> */}
@@ -197,7 +211,6 @@ export default {
197211
</a-menu-item>
198212
</a-menu>
199213
<ExternalLinksOfHeader />
200-
<LangSelect />
201214
</a-layout-header>
202215
<a-layout>
203216
<a-layout-sider width="160" style="background: #fff" collapsed>
@@ -211,7 +224,8 @@ export default {
211224
sidebarMenus.map(menu => (
212225
<a-menu-item key={menu.value}>
213226
<a-icon type={menu.antIcon} />
214-
<span>{menu.label}</span>
227+
{/* <span>{menu.label}</span> */}
228+
<span>{this.$t(menu.i18nLabel)}</span>
215229
</a-menu-item>
216230
))
217231
}
@@ -234,8 +248,9 @@ export default {
234248
}
235249
}}
236250
>
237-
<a-radio-button label={false} value={false}>编辑模式</a-radio-button>
238-
<a-radio-button label={true} value={true}>预览模式</a-radio-button>
251+
{/* 编辑模式、预览模式 */}
252+
<a-radio-button label={false} value={false}>{this.$t('editor.centerPanel.mode.edit')}</a-radio-button>
253+
<a-radio-button label={true} value={true}>{this.$t('editor.centerPanel.mode.preview')}</a-radio-button>
239254
</a-radio-group>
240255
</div>
241256
<div class='canvas-wrapper' style={{ transform: `scale(${this.scaleRate})` }}>
@@ -256,7 +271,8 @@ export default {
256271
<a-button-group style={{ display: 'flex', flexDirection: 'column' }}>
257272
{
258273
fixedTools.map(tool => (
259-
<a-tooltip effect="dark" placement="left" title={tool.tooltip}>
274+
// <a-tooltip effect="dark" placement="left" title={tool.tooltip}>
275+
<a-tooltip effect="dark" placement="left" title={this.$t(tool.i18nTooltip)}>
260276
<a-button block class="transparent-bg" type="link" size="small" style={{ height: '40px', color: '#000' }} onClick={() => tool.action && tool.action.call(this) } disabled={!!tool.disabled}>
261277
{ tool.icon ? <i class={['shortcut-icon', 'fa', `fa-${tool.icon}`]} aria-hidden='true'/> : tool.text }
262278
</a-button>
@@ -278,17 +294,10 @@ export default {
278294
ElementUI:label
279295
Ant Design Vue:tab
280296
*/}
281-
<a-tab-pane key="属性">
282-
<span slot="tab">
283-
<a-icon type="apple" />
284-
属性
285-
</span>
286-
{/* { this.renderPropsEditorPanel(h) } */}
287-
<RenderPropsEditor/>
288-
</a-tab-pane>
289-
<a-tab-pane label="动画" key='动画' tab='动画'><RenderAnimationEditor /></a-tab-pane>
290-
<a-tab-pane label="动作" key='动作' tab='动作'>{this.activeTabKey === '动作'}{ this.activeTabKey === '动作' && <RenderActoionEditor/> }</a-tab-pane>
291-
<a-tab-pane label="脚本" key='脚本' tab='脚本'><RenderScriptEditor/></a-tab-pane>
297+
<a-tab-pane key="属性"><span slot="tab"><a-icon type="apple" />{this.$t('editor.editPanel.tab.prop')}</span><RenderPropsEditor/></a-tab-pane>
298+
<a-tab-pane label="动画" key='动画' tab={this.$t('editor.editPanel.tab.animation')}><RenderAnimationEditor /></a-tab-pane>
299+
<a-tab-pane label="动作" key='动作' tab={this.$t('editor.editPanel.tab.action')}>{ this.activeTabKey === '动作' && <RenderActoionEditor/> }</a-tab-pane>
300+
<a-tab-pane label="脚本" key='脚本' tab={this.$t('editor.editPanel.tab.script')}><RenderScriptEditor/></a-tab-pane>
292301
</a-tabs>
293302
</a-layout-sider>
294303

front-end/h5/src/components/core/editor/shortcuts-panel/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import ShortcutButton from './shortcut-button'
2+
import langMixin from '@/mixins/i18n'
23
export default {
4+
mixins: [langMixin],
35
props: {
46
pluginsList: {
57
required: false,
@@ -91,7 +93,8 @@ export default {
9193
<a-col span={12} style={{ marginTop: '10px' }}>
9294
<ShortcutButton
9395
clickFn={this.onClickShortcut.bind(this, plugin)}
94-
title={plugin.title}
96+
// title={plugin.title}
97+
title={plugin.i18nTitle[this.currentLang] || plugin.title}
9598
faIcon={plugin.icon}
9699
disabled={plugin.disabled}
97100
/>

0 commit comments

Comments
 (0)