This repository was archived by the owner on Jan 2, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
src/main/java/cn/enaium/joe/util Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments