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