Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
f702fc7d
Commit
f702fc7d
authored
Jan 06, 2020
by
Bai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] dateRange插件支持i18n
parent
05adb4e9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
10 deletions
+29
-10
jumpserver.js
apps/static/js/jumpserver.js
+26
-4
_foot_js.html
apps/templates/_foot_js.html
+1
-4
command_list.html
apps/terminal/templates/terminal/command_list.html
+1
-1
session_list.html
apps/terminal/templates/terminal/session_list.html
+1
-1
No files found.
apps/static/js/jumpserver.js
View file @
f702fc7d
...
...
@@ -1237,7 +1237,7 @@ function toSafeDateISOStr(s) {
function
toSafeLocalDateStr
(
d
)
{
var
date
=
safeDate
(
d
);
var
date_s
=
date
.
toLocaleString
(
navigator
.
language
,
{
hour12
:
false
});
var
date_s
=
date
.
toLocaleString
(
getUserLang
()
,
{
hour12
:
false
});
return
date_s
.
split
(
"/"
).
join
(
'-'
)
}
...
...
@@ -1257,7 +1257,7 @@ function getTimeUnits(u) {
"m"
:
"分"
,
"s"
:
"秒"
,
};
if
(
navigator
.
language
===
"zh-CN"
)
{
if
(
getUserLang
()
===
"zh-CN"
)
{
return
units
[
u
]
}
return
u
...
...
@@ -1395,6 +1395,16 @@ function showCeleryTaskLog(taskId) {
window
.
open
(
url
,
''
,
'width=900,height=600'
)
}
function
getUserLang
(){
let
userLangZh
=
document
.
cookie
.
indexOf
(
'django_language=zh'
);
if
(
userLangZh
!==
-
1
){
return
'zh-CN'
}
else
{
return
'en-US'
}
}
function
initDateRangePicker
(
selector
,
options
)
{
if
(
!
options
)
{
options
=
{}
...
...
@@ -1408,6 +1418,15 @@ function initDateRangePicker(selector, options) {
daysOfWeek
:
[
"日"
,
"一"
,
"二"
,
"三"
,
"四"
,
"五"
,
"六"
],
//汉化处理
monthNames
:
[
"一月"
,
"二月"
,
"三月"
,
"四月"
,
"五月"
,
"六月"
,
"七月"
,
"八月"
,
"九月"
,
"十月"
,
"十一月"
,
"十二月"
],
};
var
enLocale
=
{
format
:
"YYYY-MM-DD HH:mm"
,
separator
:
" - "
,
applyLabel
:
"Apply"
,
cancelLabel
:
"Cancel"
,
resetLabel
:
"Reset"
,
daysOfWeek
:
[
"Su"
,
"Mo"
,
"Tu"
,
"We"
,
"Th"
,
"Fr"
,
"Sa"
],
monthNames
:
[
"January"
,
"February"
,
"March"
,
"April"
,
"May"
,
"June"
,
"July"
,
"August"
,
"September"
,
"October"
,
"November"
,
"December"
],
};
var
defaultOption
=
{
singleDatePicker
:
true
,
showDropdowns
:
true
,
...
...
@@ -1415,10 +1434,13 @@ function initDateRangePicker(selector, options) {
timePicker24Hour
:
true
,
autoApply
:
true
,
};
var
userLang
=
navigator
.
language
||
navigator
.
userLanguage
;
if
(
userLang
.
indexOf
(
'zh'
)
!==
-
1
)
{
if
(
getUserLang
()
===
'zh-CN'
)
{
defaultOption
.
locale
=
zhLocale
;
}
else
{
// en-US
defaultOption
.
locale
=
enLocale
;
}
options
=
Object
.
assign
(
defaultOption
,
options
);
return
$
(
selector
).
daterangepicker
(
options
);
}
...
...
apps/templates/_foot_js.html
View file @
f702fc7d
...
...
@@ -18,9 +18,6 @@ $(document).ready(function(){
if
(
$
(
'.tooltip'
)[
0
])
{
$
(
'.tooltip'
).
tooltip
();
}
var
userLang
=
navigator
.
language
||
navigator
.
userLanguage
;
if
(
userLang
.
indexOf
(
'zh'
)
!==
-
1
)
{
$
.
fn
.
select2
.
defaults
.
set
(
'language'
,
'zh-CN'
)
}
$
.
fn
.
select2
.
defaults
.
set
(
'language'
,
getUserLang
())
});
</script>
apps/terminal/templates/terminal/command_list.html
View file @
f702fc7d
...
...
@@ -86,7 +86,7 @@ $(document).ready(function () {
forceParse
:
false
,
calendarWeeks
:
true
,
autoclose
:
true
,
language
:
navigator
.
language
||
"en"
,
language
:
getUserLang
()
,
};
dateFromRef
.
datepicker
(
options
).
on
(
"changeDate"
,
function
()
{
var
value
=
$
(
this
).
val
()
+
' 0:0:0'
;
...
...
apps/terminal/templates/terminal/session_list.html
View file @
f702fc7d
...
...
@@ -193,7 +193,7 @@ $(document).ready(function() {
forceParse
:
false
,
calendarWeeks
:
true
,
autoclose
:
true
,
language
:
navigator
.
language
||
"en"
,
language
:
getUserLang
()
,
};
dateFromRef
.
datepicker
(
options
).
on
(
"changeDate"
,
function
()
{
if
(
!
$
(
this
).
val
())
{
...
...
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