diff --git a/common/src/main/java/com/usthe/common/util/ResourceBundleUtil.java b/common/src/main/java/com/usthe/common/util/ResourceBundleUtil.java index 3901f502eae..67c1995ec52 100644 --- a/common/src/main/java/com/usthe/common/util/ResourceBundleUtil.java +++ b/common/src/main/java/com/usthe/common/util/ResourceBundleUtil.java @@ -15,16 +15,40 @@ @Slf4j public class ResourceBundleUtil { + private static final ResourceBundleUtf8Control BUNDLE_UTF_8_CONTROL = new ResourceBundleUtf8Control(); + private static final Integer LANG_REGION_LENGTH = 2; + + static { + // set default locale by env + try { + String langEnv = System.getenv("LANG"); + if (langEnv != null) { + String[] langArr = langEnv.split("\\."); + if (langArr.length >= 1) { + String[] regionArr = langArr[0].split("_"); + if (regionArr.length == LANG_REGION_LENGTH) { + String language = regionArr[0]; + String region = regionArr[1]; + Locale locale = new Locale(language, region); + Locale.setDefault(locale); + } + } + } + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } + /** - * 根据bundle name 获取 resource bundle + * get resource bundle by bundle name * @param bundleName bundle name * @return resource bundle */ public static ResourceBundle getBundle(String bundleName) { try { - return ResourceBundle.getBundle(bundleName, new ResourceBundleUtf8Control()); + return ResourceBundle.getBundle(bundleName, BUNDLE_UTF_8_CONTROL); } catch (MissingResourceException resourceException) { - return ResourceBundle.getBundle(bundleName, Locale.US, new ResourceBundleUtf8Control()); + return ResourceBundle.getBundle(bundleName, Locale.US, BUNDLE_UTF_8_CONTROL); } } diff --git a/script/docker/server/Dockerfile b/script/docker/server/Dockerfile index 2f7660e11b4..01f6e7b7ea2 100644 --- a/script/docker/server/Dockerfile +++ b/script/docker/server/Dockerfile @@ -1,10 +1,11 @@ -FROM openjdk:11.0.15-jre-slim-buster +FROM openjdk:11.0.16-jre-slim-buster -MAINTAINER tomsun28 "tomsun28@outlook.com" +MAINTAINER tancloud "tomsun28@outlook.com" ADD hertzbeat-1.1.1.tar /opt/ ENV TZ=Asia/Shanghai +#ENV LANG=zh_CN.UTF-8 EXPOSE 1157