mirror of
https://gitee.com/huoyo/ko-time.git
synced 2025-12-06 08:48:30 +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;
|
package cn.langpy.kotime.constant;
|
||||||
|
|
||||||
import cn.langpy.kotime.util.Context;
|
import cn.langpy.kotime.util.Context;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
public class KoConstant {
|
public class KoConstant {
|
||||||
public final static String comMethodRange = "@annotation(cn.langpy.kotime.annotation.ComputeTime)";
|
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 kotimeViewerEn = "kotime-en.html";
|
||||||
public final static String loginName = "kotimeUserName";
|
public final static String loginName = "kotimeUserName";
|
||||||
|
|
||||||
public static String getViewName() {
|
public static String getViewName(String language) {
|
||||||
if ("chinese".equals(Context.getConfig().getLanguage())) {
|
if (!StringUtils.hasText(language)) {
|
||||||
|
language = Context.getConfig().getLanguage();
|
||||||
|
}
|
||||||
|
if ("chinese".equals(language)) {
|
||||||
return kotimeViewer;
|
return kotimeViewer;
|
||||||
}else {
|
}else {
|
||||||
return kotimeViewerEn;
|
return kotimeViewerEn;
|
||||||
|
|||||||
@ -79,7 +79,7 @@ public class KoTimeController {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping
|
@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()) {
|
if (!Context.getConfig().getEnable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ public class KoTimeController {
|
|||||||
charset = "utf-8";
|
charset = "utf-8";
|
||||||
}
|
}
|
||||||
response.setContentType("text/html;charset="+charset);
|
response.setContentType("text/html;charset="+charset);
|
||||||
ClassPathResource classPathResource = new ClassPathResource(KoConstant.getViewName());
|
ClassPathResource classPathResource = new ClassPathResource(KoConstant.getViewName(language));
|
||||||
try (
|
try (
|
||||||
InputStream inputStream = classPathResource.getInputStream();
|
InputStream inputStream = classPathResource.getInputStream();
|
||||||
InputStreamReader streamReader = new InputStreamReader(inputStream, "utf-8");
|
InputStreamReader streamReader = new InputStreamReader(inputStream, "utf-8");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user