Skip to content

Commit

Permalink
refactor: I18nUtil & Result
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyzyykk committed Dec 16, 2024
1 parent 2934577 commit 26b9f9d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ public class Result {
// 返回数据
private String data;

// 国际化工具类
public static final I18nUtil i18nUtil = new I18nUtil();

// 国际化info属性
public void setInfo(String info) {
this.info = i18nUtil.getMessage(info);
this.info = I18nUtil.getMessage(info);
}

// 失败返回
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public class I18nUtil {
/**
* 获取国际化消息
*/
public String getMessage(String key) {
public static String getMessage(String key) {
return getMessage(key, locale.get());
}

public String getMessage(String key, String lang) {
public static String getMessage(String key, String lang) {
return messagesCache.get(lang) == null ? key : messagesCache.get(lang).getOrDefault(key, key);
}

Expand Down

0 comments on commit 26b9f9d

Please sign in to comment.