提交 | 用户 | 时间
|
4d3533
|
1 |
/** |
潘 |
2 |
* Copyright (c) 2018 人人开源 All rights reserved. |
|
3 |
* |
|
4 |
* https://www.renren.io |
|
5 |
* |
|
6 |
* 版权所有,侵权必究! |
|
7 |
*/ |
|
8 |
|
|
9 |
package com.iailab.module.data.common.utils; |
|
10 |
|
|
11 |
import com.iailab.framework.common.util.spring.SpringContextUtils; |
|
12 |
import org.springframework.context.MessageSource; |
|
13 |
import org.springframework.context.i18n.LocaleContextHolder; |
|
14 |
|
|
15 |
/** |
|
16 |
* 国际化 |
|
17 |
* |
|
18 |
* @author Mark sunlightcs@gmail.com |
|
19 |
* @since 1.0.0 |
|
20 |
*/ |
|
21 |
public class MessageUtils { |
|
22 |
private static MessageSource messageSource; |
|
23 |
static { |
|
24 |
messageSource = (MessageSource) SpringContextUtils.getBean("messageSource"); |
|
25 |
} |
|
26 |
|
|
27 |
public static String getMessage(int code){ |
|
28 |
return getMessage(code, new String[0]); |
|
29 |
} |
|
30 |
|
|
31 |
public static String getMessage(int code, String... params){ |
|
32 |
return messageSource.getMessage(code+"", params, LocaleContextHolder.getLocale()); |
|
33 |
} |
|
34 |
} |