From e739732803a14bddb97e1563338f628a80c7ddfc Mon Sep 17 00:00:00 2001 From: Aaron3S Date: Wed, 10 Jul 2024 15:14:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20k8s=20=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E4=B8=8B=E6=97=A0=E6=B3=95=E5=8A=A0=E8=BD=BD=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=E6=96=87=E4=BB=B6=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jumpserver/chen/web/config/LocaleConfig.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/web/src/main/java/org/jumpserver/chen/web/config/LocaleConfig.java b/backend/web/src/main/java/org/jumpserver/chen/web/config/LocaleConfig.java index 79c138c..44f7dd3 100644 --- a/backend/web/src/main/java/org/jumpserver/chen/web/config/LocaleConfig.java +++ b/backend/web/src/main/java/org/jumpserver/chen/web/config/LocaleConfig.java @@ -3,13 +3,13 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.support.AbstractMessageSource; import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; import org.springframework.web.client.RestTemplate; import org.springframework.web.servlet.LocaleResolver; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; @@ -63,7 +63,14 @@ class JsonMessageSource extends AbstractMessageSource { public JsonMessageSource(@Value("${i18n.endpoint}") String endpoint) { - this.endpoint = endpoint; + // 首先从环境变量中读取 core 的地址 + + String coreHost = System.getenv("CORE_HOST"); + if (StringUtils.isNotBlank(coreHost)) { + this.endpoint = coreHost; + } else { + this.endpoint = endpoint; + } var languages = new String[]{ "en", "ja", "zh", "zh_hant" @@ -128,7 +135,7 @@ protected MessageFormat resolveCode(String code, Locale locale) { Map localeMessages = messages.get(languageTag); if (localeMessages != null) { String message = localeMessages.get(code); - if (StringUtils.hasText(message)) { + if (StringUtils.isNotBlank(message)) { return new MessageFormat(message, locale); } }