package publicsWay; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Enumeration; import java.util.Locale; import java.util.PropertyResourceBundle; import java.util.ResourceBundle; import dell_targets.Dell_SystemConfiguration; public class Languages { // Ð޸ĺóµÄ×ÊÔ´¼ÓÔØ·½·¨ public static ResourceBundle getCurrentMessages() { // ¸ù¾ÝϵͳÅäÖþö¶¨ÓïÑÔ Locale locale = "1".equals(Dell_SystemConfiguration.language) ? Locale.ENGLISH : Locale.SIMPLIFIED_CHINESE; // ʹÓÃÓëWindows.javaÏàͬµÄ¼ÓÔØÂß¼­ String fileName = locale.equals(Locale.ENGLISH) ? "Messages_en.properties" : "Messages_zh.properties"; File langFile = new File("systemfile/" + fileName); if (!langFile.exists()) { System.err.println("ĬÈÏ×ÊÔ´ÎļþδÕÒµ½: " + langFile.getAbsolutePath()); try { return ResourceBundle.getBundle("systemfile.Messages", locale); } catch (Exception e) { System.err.println("ºó±¸×ÊÔ´¼ÓÔØÊ§°Ü: " + e.getMessage()); // ·µ»Ø¿Õ°ü±ÜÃâ±ÀÀ£ return new ResourceBundle() { @Override protected Object handleGetObject(String key) { return "!" + key + "!"; } @Override public Enumeration getKeys() { return java.util.Collections.emptyEnumeration(); } }; } } try (InputStream inputStream = new FileInputStream(langFile)) { return new PropertyResourceBundle(inputStream); } catch (IOException e) { System.err.println("ÎÞ·¨¼ÓÔØ×ÊÔ´Îļþ: " + e.getMessage()); return ResourceBundle.getBundle("systemfile.Messages", locale); } } }