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
f88cb3da
Unverified
Commit
f88cb3da
authored
Jan 06, 2020
by
BaiJiangJie
Committed by
GitHub
Jan 06, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3600 from jumpserver/dev_i18n
[Update] dateRange插件支持i18n
parents
05adb4e9
9f42dfb2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
11 deletions
+30
-11
jumpserver.js
apps/static/js/jumpserver.js
+26
-4
_foot_js.html
apps/templates/_foot_js.html
+2
-5
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 @
f88cb3da
...
...
@@ -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 @
f88cb3da
...
...
@@ -7,7 +7,7 @@
<script
src=
"{% static "
js
/
plugins
/
toastr
/
toastr
.
min
.
js
"
%}"
></script>
<script
src=
"{% static "
js
/
inspinia
.
js
"
%}"
></script>
<script
type=
"text/javascript"
src=
"{% url 'javascript-catalog' %}"
></script>
<script
src=
"{% static "
js
/
jumpserver
.
js
"
%}?
v=
6
"
></script>
<script
src=
"{% static "
js
/
jumpserver
.
js
"
%}?
v=
7
"
></script>
<script
src=
"{% static 'js/plugins/select2/select2.full.min.js' %}"
></script>
<script
src=
"{% static 'js/plugins/select2/i18n/zh-CN.js' %}"
></script>
<script>
...
...
@@ -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 @
f88cb3da
...
...
@@ -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 @
f88cb3da
...
...
@@ -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