中国算力平台算力登记系统2.0
YZFG
2024-09-30 43dc2996fd2033991539ed35a0429238829a5417
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.odcc.cpzidc.common.utils;
 
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import com.odcc.cpzidc.common.utils.spring.SpringUtils;
 
/**
 * 获取i18n资源文件
 * 
 * @author ruoyi
 */
public class MessageUtils
{
    /**
     * 根据消息键和参数 获取消息 委托给spring messageSource
     *
     * @param code 消息键
     * @param args 参数
     * @return 获取国际化翻译值
     */
    public static String message(String code, Object... args)
    {
        MessageSource messageSource = SpringUtils.getBean(MessageSource.class);
        return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
    }
}