lxw
2023-04-19 78fe857e99a742a3ed7e49a6c5f30f7b7d2fcf32
src/main/java/com/whyc/util/MessageUtils.java
@@ -1,20 +1,13 @@
package com.whyc.util;
import com.whyc.config.I18nLocaleResolver;
import lombok.var;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpSession;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.Objects;
@Component
public class MessageUtils {
@@ -77,11 +70,13 @@
     * @return 国际化后内容信息
     */
    public static String getMessageSocket(String code, String lang) {
        Locale locale;
        if((lang.equals("zh"))){
            locale = Locale.SIMPLIFIED_CHINESE;
        }else{ //不是中文,则采用en_US
            locale = Locale.US;
        Locale locale = Locale.SIMPLIFIED_CHINESE;
        if (lang != null) {
            if ((lang.equals("zh"))) {
                locale = Locale.SIMPLIFIED_CHINESE;
            } else { //不是中文,则采用en_US
                locale = Locale.US;
            }
        }
        return getMessage(code, null, code, locale);
    }