Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.

Commit 1e428a5

Browse files
committed
fix language
1 parent d0ba29a commit 1e428a5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/java/cn/enaium/joe/util/LangUtil.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ public static String i18n(String key, Object... args) {
3838
}
3939
try {
4040

41-
String en = IOUtil.getString(LangUtil.class.getResourceAsStream("/lang/en_US.json"));
41+
String text;
4242

4343
URL url = LangUtil.class.getResource("/lang/" + lang + ".json");
4444

45-
if (url == null) {
46-
RuntimeException runtimeException = new RuntimeException(String.format("lang ' %s ' not Found!", lang));
47-
MessageUtil.error(runtimeException);
48-
throw runtimeException;
45+
if (url != null) {
46+
text = IOUtil.getString(url.openStream());
47+
} else {
48+
text = IOUtil.getString(LangUtil.class.getResourceAsStream("/lang/en_US.json"));
4949
}
5050

51-
JsonObject jsonObject = new Gson().fromJson(IOUtil.getString(url.openStream()), JsonObject.class);
51+
JsonObject jsonObject = new Gson().fromJson(text, JsonObject.class);
5252
try {
5353
return String.format(jsonObject.get(key).getAsString(), args);
5454
} catch (NullPointerException e) {
5555
Logger.warn(String.format("Lang not found \" %s \" ", key));
5656
try {
57-
return String.format(new Gson().fromJson(en, JsonObject.class).get(key).getAsString(), args);
57+
return String.format(new Gson().fromJson(text, JsonObject.class).get(key).getAsString(), args);
5858
} catch (NullPointerException ex) {
5959
MessageUtil.error(new NullPointerException(String.format("not found key ' %s ' in en_us", key)));
6060
}

0 commit comments

Comments
 (0)