Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
d60133cf
Commit
d60133cf
authored
Oct 11, 2016
by
Karol Fabjańczuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(translation): date/time picker translation possibility if using vue-i18n
parent
30003ec5
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
41 additions
and
22 deletions
+41
-22
packages/date-picker/src/basic/date-table.vue
packages/date-picker/src/basic/date-table.vue
+4
-2
packages/date-picker/src/basic/month-table.vue
packages/date-picker/src/basic/month-table.vue
+3
-1
packages/date-picker/src/panel/date-range.vue
packages/date-picker/src/panel/date-range.vue
+4
-4
packages/date-picker/src/panel/date.vue
packages/date-picker/src/panel/date.vue
+10
-7
packages/date-picker/src/panel/time-range.vue
packages/date-picker/src/panel/time-range.vue
+4
-4
packages/date-picker/src/panel/time.vue
packages/date-picker/src/panel/time.vue
+2
-2
packages/date-picker/src/util/i18n.js
packages/date-picker/src/util/i18n.js
+9
-1
packages/date-picker/src/util/index.js
packages/date-picker/src/util/index.js
+5
-1
No files found.
packages/date-picker/src/basic/date-table.vue
View file @
d60133cf
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
<td
<td
v-for=
"cell in row"
v-for=
"cell in row"
:class=
"getCellClasses(cell)"
:class=
"getCellClasses(cell)"
v-text=
"cell.type === 'today' ?
'今天'
: cell.text"
></td>
v-text=
"cell.type === 'today' ?
$t('datepicker.today')
: cell.text"
></td>
</tr>
</tr>
</tbody>
</tbody>
</table>
</table>
...
@@ -214,7 +214,9 @@
...
@@ -214,7 +214,9 @@
},
},
methods
:
{
methods
:
{
$t
:
$t
,
$t
(...
args
)
{
return
$t
.
apply
(
this
,
args
);
},
getCellClasses
(
cell
)
{
getCellClasses
(
cell
)
{
const
selectionMode
=
this
.
selectionMode
;
const
selectionMode
=
this
.
selectionMode
;
...
...
packages/date-picker/src/basic/month-table.vue
View file @
d60133cf
...
@@ -58,7 +58,9 @@
...
@@ -58,7 +58,9 @@
},
},
methods
:
{
methods
:
{
$t
:
$t
,
$t
(...
args
)
{
return
$t
.
apply
(
this
,
args
);
},
handleMonthTableClick
(
event
)
{
handleMonthTableClick
(
event
)
{
const
target
=
event
.
target
;
const
target
=
event
.
target
;
...
...
packages/date-picker/src/panel/date-range.vue
View file @
d60133cf
...
@@ -119,12 +119,12 @@
...
@@ -119,12 +119,12 @@
<div
class=
"el-picker-panel__footer"
v-if=
"showTime"
>
<div
class=
"el-picker-panel__footer"
v-if=
"showTime"
>
<!--
<a
<!--
<a
class=
"el-picker-panel__link-btn"
class=
"el-picker-panel__link-btn"
@
click=
"changeToToday"
>
{{
$t
(
'
datepicker.
today
'
)
}}
</a>
-->
@
click=
"changeToToday"
>
{{
$t
(
'
datepicker.
now
'
)
}}
</a>
-->
<button
<button
type=
"button"
type=
"button"
class=
"el-picker-panel__btn"
class=
"el-picker-panel__btn"
@
click=
"handleConfirm"
@
click=
"handleConfirm"
:disabled=
"btnDisabled"
>
确定
</button>
:disabled=
"btnDisabled"
>
{{
$t
(
'
datepicker.confirm
'
)
}}
</button>
</div>
</div>
</div>
</div>
</transition>
</transition>
...
@@ -140,11 +140,11 @@
...
@@ -140,11 +140,11 @@
},
},
leftLabel
()
{
leftLabel
()
{
return
this
.
date
.
getFullYear
()
+
'
年
'
+
(
this
.
date
.
getMonth
()
+
1
)
+
'
月
'
;
return
this
.
date
.
getFullYear
()
+
'
'
+
this
.
$t
(
'
datepicker.month
'
)
+
'
'
+
(
this
.
date
.
getMonth
()
+
1
)
+
'
'
+
this
.
$t
(
'
datepicker.month
'
)
;
},
},
rightLabel
()
{
rightLabel
()
{
return
this
.
rightDate
.
getFullYear
()
+
'
年
'
+
(
this
.
rightDate
.
getMonth
()
+
1
)
+
'
月
'
;
return
this
.
rightDate
.
getFullYear
()
+
'
'
+
this
.
$t
(
'
datepicker.month
'
)
+
'
'
+
(
this
.
rightDate
.
getMonth
()
+
1
)
+
'
'
+
this
.
$t
(
'
datepicker.month
'
)
;
},
},
leftYear
()
{
leftYear
()
{
...
...
packages/date-picker/src/panel/date.vue
View file @
d60133cf
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
<div
class=
"el-picker-panel__body"
>
<div
class=
"el-picker-panel__body"
>
<div
class=
"el-date-picker__time-header"
v-if=
"showTime"
>
<div
class=
"el-date-picker__time-header"
v-if=
"showTime"
>
<input
<input
placehoder=
"选择日期
"
:placehoder=
"$t('datepicker.selectDate')
"
type=
"text"
type=
"text"
v-model=
"visibleDate"
v-model=
"visibleDate"
class=
"el-date-picker__editor"
>
class=
"el-date-picker__editor"
>
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
<input
<input
@
focus=
"timePickerVisible = true"
@
focus=
"timePickerVisible = true"
v-model=
"visibleTime"
v-model=
"visibleTime"
placehoder=
"选择时间
"
:placehoder=
"$t('datepicker.selectTime')
"
type=
"text"
type=
"text"
class=
"el-date-picker__editor"
>
class=
"el-date-picker__editor"
>
<time-picker
<time-picker
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
@
click=
"showMonthPicker"
@
click=
"showMonthPicker"
v-show=
"currentView === 'date'"
v-show=
"currentView === 'date'"
class=
"el-date-picker__header-label"
class=
"el-date-picker__header-label"
:class=
"
{ active: currentView === 'month' }">
{{
month
+
1
}}
月
</span>
:class=
"
{ active: currentView === 'month' }">
{{
month
+
1
}}
{{
$t
(
'
datepicker.month
'
)
}}
</span>
<button
<button
type=
"button"
type=
"button"
@
click=
"nextYear"
@
click=
"nextYear"
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
<a
<a
href=
"JavaScript:"
href=
"JavaScript:"
class=
"el-picker-panel__link-btn"
class=
"el-picker-panel__link-btn"
@
click=
"changeToToday"
>
{{
$t
(
'
datepicker.
today
'
)
}}
</a>
@
click=
"changeToToday"
>
{{
$t
(
'
datepicker.
now
'
)
}}
</a>
<button
<button
type=
"button"
type=
"button"
class=
"el-picker-panel__btn"
class=
"el-picker-panel__btn"
...
@@ -148,7 +148,9 @@
...
@@ -148,7 +148,9 @@
},
},
methods
:
{
methods
:
{
$t
:
$t
,
$t
(...
args
)
{
return
$t
.
apply
(
this
,
args
);
},
resetDate
()
{
resetDate
()
{
this
.
date
=
new
Date
(
this
.
date
);
this
.
date
=
new
Date
(
this
.
date
);
...
@@ -383,11 +385,12 @@
...
@@ -383,11 +385,12 @@
yearLabel
()
{
yearLabel
()
{
const
year
=
this
.
year
;
const
year
=
this
.
year
;
if
(
!
year
)
return
''
;
if
(
!
year
)
return
''
;
const
yearTranslation
=
this
.
$t
(
'
datepicker.year
'
);
if
(
this
.
currentView
===
'
year
'
)
{
if
(
this
.
currentView
===
'
year
'
)
{
const
startYear
=
Math
.
floor
(
year
/
10
)
*
10
;
const
startYear
=
Math
.
floor
(
year
/
10
)
*
10
;
return
startYear
+
'
年
'
+
'
-
'
+
(
startYear
+
9
)
+
'
年
'
;
return
startYear
+
'
'
+
yearTranslation
+
'
-
'
+
(
startYear
+
9
)
+
'
'
+
yearTranslation
;
}
}
return
this
.
year
+
'
年
'
;
return
this
.
year
+
'
'
+
yearTranslation
;
},
},
hours
:
{
hours
:
{
...
...
packages/date-picker/src/panel/time-range.vue
View file @
d60133cf
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
class=
"el-time-range-picker el-picker-panel"
>
class=
"el-time-range-picker el-picker-panel"
>
<div
class=
"el-time-range-picker__content"
>
<div
class=
"el-time-range-picker__content"
>
<div
class=
"el-time-range-picker__cell"
>
<div
class=
"el-time-range-picker__cell"
>
<div
class=
"el-time-range-picker__header"
>
开始时间
</div>
<div
class=
"el-time-range-picker__header"
>
{{
$t
(
'
datepicker.startTime
'
)
}}
</div>
<div
class=
"el-time-range-picker__body el-time-panel__content"
>
<div
class=
"el-time-range-picker__body el-time-panel__content"
>
<time-spinner
<time-spinner
ref=
"minSpinner"
ref=
"minSpinner"
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
</div>
</div>
</div>
</div>
<div
class=
"el-time-range-picker__cell"
>
<div
class=
"el-time-range-picker__cell"
>
<div
class=
"el-time-range-picker__header"
>
结束时间
</div>
<div
class=
"el-time-range-picker__header"
>
{{
$t
(
'
datepicker.endTime
'
)
}}
</div>
<div
class=
"el-time-range-picker__body el-time-panel__content"
>
<div
class=
"el-time-range-picker__body el-time-panel__content"
>
<time-spinner
<time-spinner
ref=
"maxSpinner"
ref=
"maxSpinner"
...
@@ -37,12 +37,12 @@
...
@@ -37,12 +37,12 @@
<button
<button
type=
"button"
type=
"button"
class=
"el-time-panel__btn cancel"
class=
"el-time-panel__btn cancel"
@
click=
"handleCancel()"
>
取消
</button>
@
click=
"handleCancel()"
>
{{
$t
(
'
datepicker.cancel
'
)
}}
</button>
<button
<button
type=
"button"
type=
"button"
class=
"el-time-panel__btn confirm"
class=
"el-time-panel__btn confirm"
@
click=
"handleConfirm()"
@
click=
"handleConfirm()"
:disabled=
"btnDisabled"
>
确定
</button>
:disabled=
"btnDisabled"
>
{{
$t
(
'
datepicker.confirm
'
)
}}
</button>
</div>
</div>
</div>
</div>
</transition>
</transition>
...
...
packages/date-picker/src/panel/time.vue
View file @
d60133cf
...
@@ -18,11 +18,11 @@
...
@@ -18,11 +18,11 @@
<button
<button
type=
"button"
type=
"button"
class=
"el-time-panel__btn cancel"
class=
"el-time-panel__btn cancel"
@
click=
"handleCancel()"
>
取消
</button>
@
click=
"handleCancel()"
>
{{
$t
(
'
datepicker.cancel
'
)
}}
</button>
<button
<button
type=
"button"
type=
"button"
class=
"el-time-panel__btn confirm"
class=
"el-time-panel__btn confirm"
@
click=
"handleConfirm()"
>
确定
</button>
@
click=
"handleConfirm()"
>
{{
$t
(
'
datepicker.confirm
'
)
}}
</button>
</div>
</div>
</div>
</div>
</transition>
</transition>
...
...
packages/date-picker/src/util/i18n.js
View file @
d60133cf
export
default
{
export
default
{
datepicker
:
{
datepicker
:
{
today
:
'
此刻
'
,
now
:
'
此刻
'
,
today
:
'
今天
'
,
cancel
:
'
取消
'
,
clear
:
'
清空
'
,
clear
:
'
清空
'
,
confirm
:
'
确定
'
,
confirm
:
'
确定
'
,
selectDate
:
'
选择日期
'
,
selectTime
:
'
选择时间
'
,
startTime
:
'
开始时间
'
,
endTime
:
'
结束时间
'
,
year
:
'
年
'
,
month
:
'
月
'
,
week
:
'
周次
'
,
week
:
'
周次
'
,
weeks
:
{
weeks
:
{
sun
:
'
日
'
,
sun
:
'
日
'
,
...
...
packages/date-picker/src/util/index.js
View file @
d60133cf
...
@@ -176,7 +176,11 @@ export const limitRange = function(date, ranges) {
...
@@ -176,7 +176,11 @@ export const limitRange = function(date, ranges) {
import
i18n
from
'
./i18n
'
;
import
i18n
from
'
./i18n
'
;
export
const
$t
=
function
(
path
)
{
export
const
$t
=
function
(
path
,
options
)
{
const
vuei18n
=
Object
.
getPrototypeOf
(
this
).
$t
;
if
(
typeof
vuei18n
===
'
function
'
)
{
return
vuei18n
.
apply
(
this
,
[
path
,
options
]);
}
const
array
=
path
.
split
(
'
.
'
);
const
array
=
path
.
split
(
'
.
'
);
let
current
=
i18n
;
let
current
=
i18n
;
for
(
var
i
=
0
,
j
=
array
.
length
;
i
<
j
;
i
++
)
{
for
(
var
i
=
0
,
j
=
array
.
length
;
i
<
j
;
i
++
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment