Skip to content

Commit

Permalink
feat: I18n工具增强 (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
unknowIfGuestInDream committed Nov 17, 2022
1 parent 69fc590 commit bada8fd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/com/tlcsdm/common/util/AbstractI18nUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,27 @@ public Locale getLocale() {
return locale;
}

public void setLocale(Locale locale) {
if (supportLocale.contains(locale)) {
this.locale = locale;
}
}

public void setLocale(String l) {
switch (l.toLowerCase()) {
case "en":
locale = Locale.ENGLISH;
break;
case "zh":
locale = Locale.SIMPLIFIED_CHINESE;
break;
case "ja":
locale = Locale.JAPANESE;
break;
default:
}
}

/**
* gets the string with the given key from the resource bundle for the current locale and uses it as first argument
* to MessageFormat.format, passing in the optional args and returning the result.
Expand Down

0 comments on commit bada8fd

Please sign in to comment.