Java国际化
时间:2023-08-08 17:07:00
配置文件
FAULT_100 = 按下急停,否则急停坏了!,Emergency stop press,or emergency stop is broken! FAULT_106 = 阶段L1欠压!,Phase L1 Undervoltage! FAULT_101 = 阶段L3过电压,Phase L3 Overvoltage FAULT_105 = 阶段L1过电压,Phase L1 Overvoltage FAULT_103 = 阶段L2过电压,Phase L2 Overvoltage FAULT_104 = 阶段L2欠压,Phase L2 Undervoltage FAULT_102 = 阶段L3欠压,Phase L3 Undervoltage FAULT_110 = RCD漏电保护,RCD leakage protection FAULT_116 = PEN故障,PEN Fault FAULT_115 = PE故障,PE Fault FAULT_111 = 485故障,485 Fault FAULT_113 = A类交换机故障,Type A Switch Fault FAULT_114 = 继电器故障,Relay Fault FAULT_108 = 过流故障,Overcurrent Fault FAULT_112 = 防雷故障,Lightning Protection Fault FAULT_1000 = 紧急停止按压,Emergency stop press
通过获取配置文件实现国际化
private static Properties properties; static {
try {
properties = new Properties(); InputStreamReader is=new InputStreamReader(TUtils.class.getResourceAsStream("/config/charge_languge.properties"),"UTF-8"); properties.load(is); is.close(); } catch (IOException e) {
e.printStackTrace(); } } public static String getProp(String key){
return properties.getProperty(key); }
InputStreamReader :防止乱码
在配置文件中 用字符串切割 “,” 实现国际化