mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-06 20:38:35 +00:00
update 使用全局国际化过滤器 GlobalI18nFilter 优化 Gateway 国际化处理
This commit is contained in:
@@ -3,6 +3,7 @@ package com.ruoyi.common.core.utils;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.NoSuchMessageException;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
/**
|
||||
@@ -23,6 +24,10 @@ public class MessageUtils {
|
||||
* @return 获取国际化翻译值
|
||||
*/
|
||||
public static String message(String code, Object... args) {
|
||||
return MESSAGE_SOURCE.getMessage(code, args, LocaleContextHolder.getLocale());
|
||||
try {
|
||||
return MESSAGE_SOURCE.getMessage(code, args, LocaleContextHolder.getLocale());
|
||||
} catch (NoSuchMessageException e) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user