pull/6/head
xuxueli 7 years ago
parent 25c680a6bf
commit 84f093ab42

@ -1,5 +1,6 @@
package com.xxl.job.admin.core.util;
import com.xxl.job.core.util.JacksonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
@ -8,6 +9,8 @@ import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
@ -19,14 +22,12 @@ public class I18nUtil {
private static Logger logger = LoggerFactory.getLogger(I18nUtil.class);
private static final String i18n_file = "i18n/message.properties";
private static Properties prop = null;
private static boolean prop_cache = false;
private static Properties prop = null;
public static Properties loadI18nProp(){
if (prop_cache && prop != null) {
return prop;
if (prop != null) {
//return prop;
}
try {
Resource resource = new ClassPathResource(i18n_file);
EncodedResource encodedResource = new EncodedResource(resource,"UTF-8");
@ -37,8 +38,38 @@ public class I18nUtil {
return prop;
}
/**
* get val of i18n key
*
* @param key
* @return
*/
public static String getString(String key) {
return loadI18nProp().getProperty(key);
}
/**
* get mult val of i18n mult key, as json
*
* @param keys
* @return
*/
public static String getMultString(String... keys) {
Map<String, String> map = new HashMap<>();
Properties prop = loadI18nProp();
if (keys!=null && keys.length>0) {
for (String key: keys) {
map.put(key, prop.getProperty(key));
}
} else {
for (String key: prop.stringPropertyNames()) {
map.put(key, prop.getProperty(key));
}
}
String json = JacksonUtil.writeValueAsString(map);
return json;
}
}

@ -1,5 +1,6 @@
admin_name=任务调度中心
admin_name_full=分布式任务调度平台XXL-JOB
admin_version=1.9.1(快照版本)
## system
system_tips=系统提示

@ -29,6 +29,10 @@
<!-- pace -->
<link rel="stylesheet" href="${request.contextPath}/static/plugins/pace/themes/pace-theme-flash.css">
<#-- i18n -->
<#global I18n = I18nUtil.getMultString()?eval />
</#macro>
<#macro commonScript>
@ -55,14 +59,7 @@
<script src="${request.contextPath}/static/js/common.1.js"></script>
<script>
var base_url = '${request.contextPath}';
var system_tips = '${I18nUtil.getString("system_tips")}';
var system_ok = '${I18nUtil.getString("system_ok")}';
var system_close = '${I18nUtil.getString("system_close")}';
var logout_confirm = '${I18nUtil.getString("logout_confirm")}';
var logout_success = '${I18nUtil.getString("logout_success")}';
var logout_fail = '${I18nUtil.getString("logout_fail")}';
var I18n = ${I18nUtil.getMultString()};
</script>
</#macro>
@ -71,7 +68,7 @@
<header class="main-header">
<a href="${request.contextPath}/" class="logo">
<span class="logo-mini"><b>XXL</b></span>
<span class="logo-lg"><b>${I18nUtil.getString("admin_name")}</b></span>
<span class="logo-lg"><b>${I18n.admin_name}</b></span>
</a>
<nav class="navbar navbar-static-top" role="navigation">
<a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button"><span class="sr-only"></span></a>
@ -79,7 +76,7 @@
<ul class="nav navbar-nav">
<li class="dropdown user user-menu">
<a href=";" id="logoutBtn" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="hidden-xs">${I18nUtil.getString("logout_btn")}</span>
<span class="hidden-xs">${I18n.logout_btn}</span>
</a>
</li>
</ul>
@ -95,11 +92,11 @@
<section class="sidebar">
<!-- sidebar menu: : style can be found in sidebar.less -->
<ul class="sidebar-menu">
<#--<li class="header"></li>-->
<li class="nav-click <#if pageName == "jobinfo">active</#if>" ><a href="${request.contextPath}/jobinfo"><i class="fa fa-circle-o text-aqua"></i><span>${I18nUtil.getString("jobinfo_name")}</span></a></li>
<li class="nav-click <#if pageName == "joblog">active</#if>" ><a href="${request.contextPath}/joblog"><i class="fa fa-circle-o text-yellow"></i><span>${I18nUtil.getString("joblog_name")}</span></a></li>
<li class="nav-click <#if pageName == "jobgroup">active</#if>" ><a href="${request.contextPath}/jobgroup"><i class="fa fa-circle-o text-green"></i><span>${I18nUtil.getString("jobgroup_name")}</span></a></li>
<li class="nav-click <#if pageName == "help">active</#if>" ><a href="${request.contextPath}/help"><i class="fa fa-circle-o text-gray"></i><span>${I18nUtil.getString("job_help")}</span></a></li>
<li class="header"></li>
<li class="nav-click <#if pageName == "jobinfo">active</#if>" ><a href="${request.contextPath}/jobinfo"><i class="fa fa-circle-o text-aqua"></i><span>${I18n.jobinfo_name}</span></a></li>
<li class="nav-click <#if pageName == "joblog">active</#if>" ><a href="${request.contextPath}/joblog"><i class="fa fa-circle-o text-yellow"></i><span>${I18n.joblog_name}</span></a></li>
<li class="nav-click <#if pageName == "jobgroup">active</#if>" ><a href="${request.contextPath}/jobgroup"><i class="fa fa-circle-o text-green"></i><span>${I18n.jobgroup_name}</span></a></li>
<li class="nav-click <#if pageName == "help">active</#if>" ><a href="${request.contextPath}/help"><i class="fa fa-circle-o text-gray"></i><span>${I18n.job_help}</span></a></li>
</ul>
</section>
<!-- /.sidebar -->
@ -185,7 +182,7 @@
<#macro commonFooter >
<footer class="main-footer">
Powered by <b>XXL-JOB</b> 1.9.1SNAPSHOT
Powered by <b>XXL-JOB</b> ${I18n.admin_version}
<div class="pull-right hidden-xs">
<strong>Copyright &copy; 2015-${.now?string('yyyy')} &nbsp;
<a href="http://www.xuxueli.com/" target="_blank" >xuxueli</a>

@ -1,9 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>${I18nUtil.getString("admin_name")}</title>
<#import "/common/common.macro.ftl" as netCommon>
<@netCommon.commonStyle />
<title>${I18n.admin_name}</title>
</head>
<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">
<div class="wrapper">
@ -16,25 +16,19 @@
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>${I18nUtil.getString("job_help")}</h1>
<!--
<ol class="breadcrumb">
<li><a><i class="fa fa-dashboard"></i></a></li>
<li class="active">使</li>
</ol>
-->
<h1>${I18n.job_help}</h1>
</section>
<!-- Main content -->
<section class="content">
<div class="callout callout-info">
<h4>${I18nUtil.getString("admin_name_full")}</h4>
<h4>${I18n.admin_name_full}</h4>
<br>
<p>
<a target="_blank" href="https://github.com/xuxueli/xxl-job">github</a>&nbsp;&nbsp;&nbsp;&nbsp;
<iframe src="https://ghbtns.com/github-btn.html?user=xuxueli&repo=xxl-job&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px" style="margin-bottom:-5px;"></iframe>
<br><br>
<a target="_blank" href="http://www.xuxueli.com/xxl-job/">${I18nUtil.getString("job_help_document")}</a>
<a target="_blank" href="http://www.xuxueli.com/xxl-job/">${I18n.job_help_document}</a>
<br><br>
</p>

@ -1,11 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>${I18nUtil.getString("admin_name")}</title>
<#import "/common/common.macro.ftl" as netCommon>
<@netCommon.commonStyle />
<!-- daterangepicker -->
<link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/daterangepicker/daterangepicker.css">
<title>${I18n.admin_name}</title>
</head>
<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">
<div class="wrapper">
@ -18,7 +18,7 @@
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>${I18nUtil.getString("job_dashboard_name")}</h1>
<h1>${I18n.job_dashboard_name}</h1>
<!--
<h1><small></small></h1>
<ol class="breadcrumb">
@ -40,13 +40,13 @@
<span class="info-box-icon"><i class="fa fa-flag-o"></i></span>
<div class="info-box-content">
<span class="info-box-text">${I18nUtil.getString("job_dashboard_job_num")}</span>
<span class="info-box-text">${I18n.job_dashboard_job_num}</span>
<span class="info-box-number">${jobInfoCount}</span>
<div class="progress">
<div class="progress-bar" style="width: 100%"></div>
</div>
<span class="progress-description">${I18nUtil.getString("job_dashboard_job_num_tip")}</span>
<span class="progress-description">${I18n.job_dashboard_job_num_tip}</span>
</div>
</div>
</div>
@ -57,14 +57,14 @@
<span class="info-box-icon"><i class="fa fa-calendar"></i></span>
<div class="info-box-content">
<span class="info-box-text">${I18nUtil.getString("job_dashboard_trigger_num")}</span>
<span class="info-box-text">${I18n.job_dashboard_trigger_num}</span>
<span class="info-box-number">${jobLogCount}</span>
<div class="progress">
<div class="progress-bar" style="width: 100%" ></div>
</div>
<span class="progress-description">
${I18nUtil.getString("job_dashboard_trigger_num_tip")}
${I18n.job_dashboard_trigger_num_tip}
<#--<#if jobLogCount gt 0>
${(jobLogSuccessCount*100/jobLogCount)?string("0.00")}<small>%</small>
</#if>-->
@ -79,13 +79,13 @@
<span class="info-box-icon"><i class="fa ion-ios-settings-strong"></i></span>
<div class="info-box-content">
<span class="info-box-text">${I18nUtil.getString("job_dashboard_jobgroup_num")}</span>
<span class="info-box-text">${I18n.job_dashboard_jobgroup_num}</span>
<span class="info-box-number">${executorCount}</span>
<div class="progress">
<div class="progress-bar" style="width: 100%"></div>
</div>
<span class="progress-description">${I18nUtil.getString("job_dashboard_jobgroup_num_tip")}</span>
<span class="progress-description">${I18n.job_dashboard_jobgroup_num_tip}</span>
</div>
</div>
</div>
@ -97,7 +97,7 @@
<div class="col-md-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">${I18nUtil.getString("job_dashboard_report")}</h3>
<h3 class="box-title">${I18n.job_dashboard_report}</h3>
<#--<input type="text" class="form-control" id="filterTime" readonly >-->
<!-- tools box -->
@ -137,9 +137,6 @@
<@netCommon.commonFooter />
</div>
<@netCommon.commonScript />
<script>
var system_tips = '${I18nUtil.getString("system_tips")}';
</script>
<!-- daterangepicker -->
<script src="${request.contextPath}/static/adminlte/plugins/daterangepicker/moment.min.js"></script>
<script src="${request.contextPath}/static/adminlte/plugins/daterangepicker/daterangepicker.js"></script>

@ -1,11 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>${I18nUtil.getString("admin_name")}</title>
<#import "/common/common.macro.ftl" as netCommon>
<@netCommon.commonStyle />
<link rel="stylesheet" href="${request.contextPath}/static/plugins/codemirror/lib/codemirror.css">
<link rel="stylesheet" href="${request.contextPath}/static/plugins/codemirror/addon/hint/show-hint.css">
<title>${I18n.admin_name}</title>
<style type="text/css">
.CodeMirror {
font-size:16px;

@ -1,11 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>${I18nUtil.getString("admin_name")}</title>
<#import "/common/common.macro.ftl" as netCommon>
<@netCommon.commonStyle />
<!-- DataTables -->
<link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.css">
<title>${I18n.admin_name}</title>
</head>
<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">
<div class="wrapper">
@ -18,7 +18,7 @@
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>${I18nUtil.getString("jobgroup_name")}</h1>
<h1>${I18n.jobgroup_name}</h1>
</section>
<!-- Main content -->

@ -1,12 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>${I18nUtil.getString("admin_name")}</title>
<#import "/common/common.macro.ftl" as netCommon>
<@netCommon.commonStyle />
<!-- DataTables -->
<link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.css">
<title>${I18n.admin_name}</title>
</head>
<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if>">
<div class="wrapper">
@ -19,7 +18,7 @@
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>${I18nUtil.getString("jobinfo_name")}</h1>
<h1>${I18n.jobinfo_name}</h1>
<!--
<ol class="breadcrumb">
<li><a><i class="fa fa-dashboard"></i></a></li>

@ -1,9 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>${I18nUtil.getString("admin_name")}</title>
<#import "/common/common.macro.ftl" as netCommon>
<@netCommon.commonStyle />
<#import "/common/common.macro.ftl" as netCommon>
<@netCommon.commonStyle />
<title>${I18n.admin_name}</title>
</head>
<body class="hold-transition skin-blue layout-top-nav">

@ -1,13 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>${I18nUtil.getString("admin_name")}</title>
<#import "/common/common.macro.ftl" as netCommon>
<@netCommon.commonStyle />
<!-- DataTables -->
<link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.css">
<!-- daterangepicker -->
<link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/daterangepicker/daterangepicker.css">
<title>${I18n.admin_name}</title>
</head>
<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">
<div class="wrapper">
@ -20,7 +20,7 @@
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>${I18nUtil.getString("joblog_name")}</h1>
<h1>${I18n.joblog_name}</h1>
<!--
<ol class="breadcrumb">
<li><a><i class="fa fa-dashboard"></i></a></li>

@ -1,10 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>${I18nUtil.getString("admin_name")}</title>
<#import "/common/common.macro.ftl" as netCommon>
<@netCommon.commonStyle />
<link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/iCheck/square/blue.css">
<title>${I18n.admin_name}</title>
</head>
<body class="hold-transition login-page">
<div class="login-box">
@ -13,44 +13,31 @@
</div>
<form id="loginForm" method="post" >
<div class="login-box-body">
<p class="login-box-msg">${I18nUtil.getString("admin_name")}</p>
<p class="login-box-msg">${I18n.admin_name}</p>
<div class="form-group has-feedback">
<input type="text" name="userName" class="form-control" placeholder="${I18nUtil.getString("login_username_placeholder")}" value="admin" maxlength="18" >
<input type="text" name="userName" class="form-control" placeholder="${I18n.login_username_placeholder}" value="admin" maxlength="18" >
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" name="password" class="form-control" placeholder="${I18nUtil.getString("login_password_placeholder")}" value="123456" maxlength="18" >
<input type="password" name="password" class="form-control" placeholder="${I18n.login_password_placeholder}" value="123456" maxlength="18" >
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-8">
<div class="checkbox icheck">
<label>
<input type="checkbox" name="ifRemember" > ${I18nUtil.getString("login_remember_me")}
<input type="checkbox" name="ifRemember" >${I18n.login_remember_me}
</label>
</div>
</div><!-- /.col -->
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat">${I18nUtil.getString("login_btn")}</button>
<button type="submit" class="btn btn-primary btn-block btn-flat">${I18n.login_btn}</button>
</div>
</div>
</div>
</form>
</div>
<@netCommon.commonScript />
<script>
var system_tips = '${I18nUtil.getString("system_tips")}';
var system_ok = '${I18nUtil.getString("system_ok")}';
var login_username_empty = '${I18nUtil.getString("login_username_empty")}';
var login_username_lt_5 = '${I18nUtil.getString("login_username_lt_5")}';
var login_password_empty = '${I18nUtil.getString("login_password_empty")}';
var login_password_lt_5 = '${I18nUtil.getString("login_password_lt_5")}';
var login_success = '${I18nUtil.getString("login_success")}';
var login_fail = '${I18nUtil.getString("login_fail")}';
</script>
<script src="${request.contextPath}/static/plugins/jquery/jquery.validate.min.js"></script>
<script src="${request.contextPath}/static/adminlte/plugins/iCheck/icheck.min.js"></script>
<script src="${request.contextPath}/static/js/login.1.js"></script>

@ -2,18 +2,18 @@ $(function(){
// logout
$("#logoutBtn").click(function(){
layer.confirm(logout_confirm, {icon: 3, title:system_tips}, function(index){
layer.confirm( I18n.logout_confirm , {icon: 3, title: I18n.system_tips }, function(index){
layer.close(index);
$.post(base_url + "/logout", function(data, status) {
if (data.code == "200") {
layer.msg(logout_success);
layer.msg( I18n.logout_success );
setTimeout(function(){
window.location.href = base_url + "/";
}, 500);
/*layer.open({
title: '',
content: '',
title: I18n.system_tips ,
content: I18n.logout_success ,
icon: '1',
end: function(layero, index){
window.location.href = base_url + "/";
@ -21,9 +21,9 @@ $(function(){
});*/
} else {
layer.open({
title: system_tips,
btn: [system_ok, system_close],
content: (data.msg || logout_fail),
title: I18n.system_tips ,
btn: [ I18n.system_ok , I18n.system_close ],
content: (data.msg || I18n.logout_fail),
icon: '2'
});
}
@ -74,9 +74,9 @@ $(function(){
}, 100);
});
// 左侧菜单状态js + 后端 + cookie方式
// left menu status v: js + server + cookie
$('.sidebar-toggle').click(function(){
var xxljob_adminlte_settings = $.cookie('xxljob_adminlte_settings'); // 左侧菜单展开状态[xxljob_adminlte_settings]on=展开off=折叠
var xxljob_adminlte_settings = $.cookie('xxljob_adminlte_settings'); // on=openoff=close
if ('off' == xxljob_adminlte_settings) {
xxljob_adminlte_settings = 'on';
} else {
@ -84,11 +84,12 @@ $(function(){
}
$.cookie('xxljob_adminlte_settings', xxljob_adminlte_settings, { expires: 7 }); //$.cookie('the_cookie', '', { expires: -1 });
});
// 左侧菜单状态js + cookie方式遗弃
// left menu status v1: js + cookie
/*
var xxljob_adminlte_settings = $.cookie('xxljob_adminlte_settings');
if (xxljob_adminlte_settings == 'off') {
$('body').addClass('sidebar-collapse');
$('body').addClass('sidebar-collapse');
}
*/

@ -63,7 +63,7 @@ $(function () {
pieChartInit(data);
} else {
layer.open({
title: system_tips,
title: I18n.system_tips ,
content: (data.msg || ''),
icon: '2'
});

@ -1,12 +1,13 @@
$(function(){
// 复选框
// input iCheck
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' // optional
});
// 登录.规则校验
// login Form Valid
var loginFormValid = $("#loginForm").validate({
errorElement : 'span',
errorClass : 'help-block',
@ -25,12 +26,12 @@ $(function(){
},
messages : {
userName : {
required : login_username_empty,
minlength : login_username_lt_5
required : I18n.login_username_empty,
minlength : I18n.login_username_lt_5
},
password : {
required : login_password_empty ,
minlength : login_password_lt_5
required : I18n.login_password_empty ,
minlength : I18n.login_password_lt_5
/*,maxlength:"登录密码不应超过18位"*/
}
},
@ -47,13 +48,13 @@ $(function(){
submitHandler : function(form) {
$.post(base_url + "/login", $("#loginForm").serialize(), function(data, status) {
if (data.code == "200") {
layer.msg(login_success);
layer.msg( I18n.login_success );
setTimeout(function(){
window.location.href = base_url;
}, 500);
/*layer.open({
title: '',
content: '',
title: I18n.system_tips,
content: I18n.login_success,
icon: '1',
end: function(layero, index){
window.location.href = base_url;
@ -61,9 +62,9 @@ $(function(){
});*/
} else {
layer.open({
title: system_tips,
btn: [system_ok],
content: (data.msg || login_fail),
title: I18n.system_tips,
btn: [ I18n.system_ok ],
content: (data.msg || I18n.login_fail ),
icon: '2'
});
}

@ -0,0 +1,20 @@
package com.xxl.job.admin.util;
import com.xxl.job.admin.core.util.I18nUtil;
import org.junit.Test;
/**
* email util test
*
* @author xuxueli 2017-12-22 17:16:23
*/
public class I18nUtilTest {
@Test
public void test(){
System.out.println(I18nUtil.getString("admin_name"));
System.out.println(I18nUtil.getMultString("admin_name", "admin_name_full"));
System.out.println(I18nUtil.getMultString());
}
}
Loading…
Cancel
Save