Search in sources :

Example 1 with LanguageEnum

use of com.rogge.common.model.LanguageEnum in project spring-cloud by Rogge666.

the class Util method getCurrentLanguage.

/**
 * 获取当前会话语言(如果找不到默认返回中文)
 *
 * @return
 */
public static LanguageEnum getCurrentLanguage() {
    try {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        LanguageEnum language = (LanguageEnum) request.getSession().getAttribute(Constant.CURRENT_LANGUAGE);
        if (language != null) {
            return language;
        }
    } catch (Exception e) {
    }
    return LanguageEnum.zh_CN;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) LanguageEnum(com.rogge.common.model.LanguageEnum)

Aggregations

LanguageEnum (com.rogge.common.model.LanguageEnum)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 ServletRequestAttributes (org.springframework.web.context.request.ServletRequestAttributes)1