国际化

This commit is contained in:
sgjj 2020-09-22 10:45:08 +08:00
parent 5a360c5a74
commit 2fb1185cb6
5 changed files with 5 additions and 78 deletions

View File

@ -1,31 +0,0 @@
package net.mingsoft.config;
import com.jagregory.shiro.freemarker.ShiroTags;
import freemarker.template.TemplateException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
import java.io.IOException;
/**
* 读取国际化配置传递给freemker
*/
@Configuration
public class I18NConfig {
@Autowired
protected freemarker.template.Configuration configuration;
@Value("${ms.local.default:zh_CN}")
private String defaultLocal;
@Value("$ms.local.local-messages:zh_CN,en_US}")
private String localMessages;
@PostConstruct
public void init() throws IOException, TemplateException {
configuration.setSharedVariable("localDefault",defaultLocal);
configuration.setSharedVariable("localMessages",localMessages.split(","));
}
}

View File

@ -15,7 +15,7 @@ logging:
ms: ms:
local: local:
default: zh_CN #默认语言 default: zh_CN #默认语言
local-messages: zh_CN,en_US #全部语言 local-language: zh_CN,en_US #全部语言
# scheme: https #解决使用代理服务器代理应用时标签解析域名依旧为http的问题 # scheme: https #解决使用代理服务器代理应用时标签解析域名依旧为http的问题
swagger: swagger:
enable: true #启用swagger文档生产的时候务必关掉 enable: true #启用swagger文档生产的时候务必关掉

View File

@ -34,8 +34,7 @@
<el-table-column label="编号" width="120" prop="id"> <el-table-column label="编号" width="120" prop="id">
<template slot='header'>编号 <template slot='header'>编号
<el-popover placement="top-start" title="提示" trigger="hover" > <el-popover placement="top-start" title="提示" trigger="hover" >
<a href="http://doc.ms.mingsoft.net/plugs-cms/biao-qian/nei-rong-biao-qian-ms-field.html" target="_blank">{ms:field.typeid/}</a> <a href="http://doc.mingsoft.net/plugs-cms/biao-qian/lan-mu-lie-biao-ms-channel.html" target="_blank">${'$'}{field.id}</a>
<a href="http://doc.ms.mingsoft.net/plugs-cms/biao-qian/lan-mu-lie-biao-ms-channel.html" target="_blank">[field.typeid/]</a>
<i class="el-icon-question" slot="reference"></i> <i class="el-icon-question" slot="reference"></i>
</el-popover> </el-popover>
</template> </template>
@ -48,7 +47,7 @@
</el-table-column> </el-table-column>
<el-table-column label="链接地址" align="left" prop="categoryPath" show-overflow-tooltip> <el-table-column label="链接地址" align="left" prop="categoryPath" show-overflow-tooltip>
<template slot-scope="scope"> <template slot-scope="scope">
<span style="cursor: pointer" class="copyBtn" :data-clipboard-text="'{ms:global.url/}'+scope.row.categoryPath+'/index.html'" @click="copyUrl">{{"{ms:global.url/}"+scope.row.categoryPath+"/index.html"}}</span> <span style="cursor: pointer" class="copyBtn" :data-clipboard-text="'${'$'}{global.url}'+scope.row.categoryPath+'/index.html'" @click="copyUrl">{{"{ms:global.url/}"+scope.row.categoryPath+"/index.html"}}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="列表地址" align="left" prop="categoryListUrl" show-overflow-tooltip> <el-table-column label="列表地址" align="left" prop="categoryListUrl" show-overflow-tooltip>

View File

@ -63,8 +63,7 @@
<el-table-column label="编号" width="70" prop="id"> <el-table-column label="编号" width="70" prop="id">
<template slot='header'>编号 <template slot='header'>编号
<el-popover placement="top-start" title="提示" trigger="hover" > <el-popover placement="top-start" title="提示" trigger="hover" >
<a href="http://doc.ms.mingsoft.net/plugs-cms/biao-qian/nei-rong-biao-qian-ms-field.html" target="_blank">{ms:field.id/}</a> <a href="http://doc.mingsoft.net/plugs-cms/biao-qian/wen-zhang-lie-biao-ms-arclist.html" target="_blank">${'$'}{field.id}</a>
<a href="http://doc.ms.mingsoft.net/plugs-cms/biao-qian/wen-zhang-lie-biao-ms-arclist.html" target="_blank">[field.id/]</a>
<i class="el-icon-question" slot="reference"></i> <i class="el-icon-question" slot="reference"></i>
</el-popover> </el-popover>
</template> </template>
@ -80,8 +79,7 @@
<el-table-column label="点击量" width="90" align="right" prop="contentHit"> <el-table-column label="点击量" width="90" align="right" prop="contentHit">
<template slot='header'>点击量 <template slot='header'>点击量
<el-popover placement="top-start" title="提示" trigger="hover" > <el-popover placement="top-start" title="提示" trigger="hover" >
<a href="http://doc.ms.mingsoft.net/plugs-cms/biao-qian/nei-rong-biao-qian-ms-field.html" target="_blank">{ms:field.hit/}</a> <a href="http://doc.mingsoft.net/plugs-cms/biao-qian/wen-zhang-lie-biao-ms-arclist.html" target="_blank">${'$'}{field.hit}</a>
<a href="http://doc.ms.mingsoft.net/plugs-cms/biao-qian/wen-zhang-lie-biao-ms-arclist.html" target="_blank">[field.hit/]</a>
<i class="el-icon-question" slot="reference"></i> <i class="el-icon-question" slot="reference"></i>
</el-popover> </el-popover>
</template> </template>

View File

@ -1,39 +0,0 @@
<#list localMessages as item>
<script src="${base}/static/locale/lang/${modeldir}/${item}.js"></script>
</#list>
<script>
(function(window) {
var defaultLocal = '${localDefault}' //默认语言
var localeMessage = [] //添加语言
<#list localMessages as item>
localeMessage.push('${item}')
</#list>
window.indexlocale = {
language:defaultLocal
}
//获取后台index的语言
if(parent!=null&&parent.indexVue!=undefined&&parent.indexVue.locale!=undefined){
window.indexlocale = parent.indexVue.locale
}
window.i18n = new VueI18n({
locale: window.indexlocale.language, // 设置地区
fallbackLocale: defaultLocal,
})
//加载语言
localeMessage.forEach(function (value) {
if(window[value]!=undefined){
var message = window[value]
if(window['base_'+value]!=undefined){
message = Object.assign({},message,window['base_'+value])
}
i18n.setLocaleMessage(value,message)
}
})
var localElement = i18n.getLocaleMessage(i18n.locale)
if(Object.keys(localElement).indexOf("el")!=-1){
ELEMENT.locale(localElement)
}
})(window);
</script>