Support internationalization

This commit is contained in:
JiaJu Zhuang
2023-06-22 20:40:10 +08:00
parent 3240cd695b
commit 834f916519
5 changed files with 8 additions and 12 deletions

View File

@ -6,14 +6,12 @@ package ai.chat2db.server.web.api.controller;
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
import ai.chat2db.server.tools.common.config.AliDbhubProperties;
import jakarta.annotation.Resource;
import ai.chat2db.server.tools.common.util.I18nUtils;
import ai.chat2db.spi.sql.SSHManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -34,8 +32,6 @@ public class SystemController {
@Autowired
private AliDbhubProperties aliDbhubProperties;
@Resource
private MessageSource messageSource;
/**
* 检测是否成功
@ -45,10 +41,8 @@ public class SystemController {
@GetMapping
public DataResult<String> get() {
log.info("locale:{}", LocaleContextHolder.getLocale());
log.info("error message:{}",
messageSource.getMessage("COMMON_SYSTEM_ERROR", null, LocaleContextHolder.getLocale()));
log.info("error message:{}",
messageSource.getMessage("COMMON_SYSTEM_ERROR2", null, LocaleContextHolder.getLocale()));
log.info("error message:{}", I18nUtils.getMessage("common.systemError"));
log.info("error message:{}", I18nUtils.getMessage("common.paramDetailError", new Object[] {"参数呀"}));
return DataResult.of("success");
}