mirror of
https://gitee.com/huoyo/ko-time.git
synced 2025-12-06 16:58:26 +08:00
add language for the request path
This commit is contained in:
parent
3abd1b6436
commit
8bb5adb21f
@ -1,6 +1,7 @@
|
||||
package cn.langpy.kotime.constant;
|
||||
|
||||
import cn.langpy.kotime.util.Context;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
public class KoConstant {
|
||||
public final static String comMethodRange = "@annotation(cn.langpy.kotime.annotation.ComputeTime)";
|
||||
@ -14,8 +15,11 @@ public class KoConstant {
|
||||
public final static String kotimeViewerEn = "kotime-en.html";
|
||||
public final static String loginName = "kotimeUserName";
|
||||
|
||||
public static String getViewName() {
|
||||
if ("chinese".equals(Context.getConfig().getLanguage())) {
|
||||
public static String getViewName(String language) {
|
||||
if (!StringUtils.hasText(language)) {
|
||||
language = Context.getConfig().getLanguage();
|
||||
}
|
||||
if ("chinese".equals(language)) {
|
||||
return kotimeViewer;
|
||||
}else {
|
||||
return kotimeViewerEn;
|
||||
|
||||
@ -79,7 +79,7 @@ public class KoTimeController {
|
||||
|
||||
|
||||
@GetMapping
|
||||
public void index(String kotoken, String test,String charset, HttpServletResponse response, HttpServletRequest request) {
|
||||
public void index(String kotoken, String test,String charset, String language,HttpServletResponse response, HttpServletRequest request) {
|
||||
if (!Context.getConfig().getEnable()) {
|
||||
return;
|
||||
}
|
||||
@ -94,7 +94,7 @@ public class KoTimeController {
|
||||
charset = "utf-8";
|
||||
}
|
||||
response.setContentType("text/html;charset="+charset);
|
||||
ClassPathResource classPathResource = new ClassPathResource(KoConstant.getViewName());
|
||||
ClassPathResource classPathResource = new ClassPathResource(KoConstant.getViewName(language));
|
||||
try (
|
||||
InputStream inputStream = classPathResource.getInputStream();
|
||||
InputStreamReader streamReader = new InputStreamReader(inputStream, "utf-8");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user