예제 #1
0
파일: Main.java 프로젝트: Cat7373/HMCL
 public static ImageIcon getIcon(String path) {
   try {
     return new ImageIcon(
         Main.class.getResource("/org/jackhuang/hellominecraft/launcher/" + path));
   } catch (Exception e) {
     HMCLog.err("Failed to load icon", e);
     return null;
   }
 }
예제 #2
0
  private Localization(Locale locale) {
    InputStream is =
        Localization.class.getResourceAsStream(
            String.format(ROOT_LOCATION, "_" + locale.getLanguage() + "_" + locale.getCountry()));
    if (is == null)
      is =
          Localization.class.getResourceAsStream(
              String.format(ROOT_LOCATION, "_" + locale.getLanguage()));
    if (is == null) is = Localization.class.getResourceAsStream(String.format(ROOT_LOCATION, ""));
    if (is == null) throw new RuntimeException("LANG FILE MISSING");

    this.lang = new HashMap<>();
    try {
      String[] strings = IOUtils.readFully(is).toString().split("\n");
      for (String s : strings)
        if (!s.isEmpty() && s.charAt(0) != 35) {
          int i = s.indexOf("=");
          if (i == -1) continue;
          lang.put(s.substring(0, i), s.substring(i + 1));
        }
    } catch (IOException ex) {
      HMCLog.err("LANG FILE MISSING", ex);
    }
  }