11package com .nbs .tools ;
22
3- import UI .ConstantsUI ;
4- import com .nbs .utils .FormatCnst ;
53import org .apache .commons .lang3 .StringUtils ;
6- import org .apache .commons .lang3 .time .DateFormatUtils ;
7- import org .apache .commons .lang3 .time .DateUtils ;
4+
85import org .slf4j .Logger ;
96import org .slf4j .LoggerFactory ;
107
@@ -28,7 +25,9 @@ public class ConfigHelper {
2825 * 系统当前路径
2926 */
3027 public final static String CURRENT_DIR = System .getProperty ("user.dir" );
28+ public final static String OS_FILE_SEPARATOR = File .separator ;
3129 public static final String CONF_ROOT = CURRENT_DIR + File .separator +"config" + File .separator ;
30+ private static final String CONF_FILE = "nbs-conf.properties" ;
3231 public static final String PROFILE_ROOT = CURRENT_DIR + File .separator +"profile" + File .separator ;
3332 public static final String NBS_FILES_ROOT_PATH = CURRENT_DIR + File .separator +"nbs" + File .separator ;
3433 public static final String NBS_FILES_IPFS_ROOT = NBS_FILES_ROOT_PATH + "ipfs" + File .separator ;
@@ -37,7 +36,7 @@ public class ConfigHelper {
3736 */
3837 public static final String NBS_TEMP_ROOT = NBS_FILES_ROOT_PATH + "_temp" + File .separator ;
3938 public static final String NBS_CACHE_AVATAR_ROOT_PATH = NBS_FILES_ROOT_PATH +"cache" + File .separator + "avatar" + File .separator ;
40- private static final String CONF_FILE = "nbs-conf.properties" ;
39+
4140
4241 public static final String PK_CFG_IPFS_ADDR = "nbs.server.address" ;
4342 private static final String CLIENT_ADD_FILE_ROOT = "nbs.client.merkle.root" ;
@@ -49,13 +48,13 @@ public class ConfigHelper {
4948 public static String JSON_AVATAR_NAME_KEY = "avatar-name" ;
5049 public static String JSON_AVATAR_SUFFIX_KEY = "suffix" ;
5150
52-
5351 private static Properties env = new Properties ();
52+ private static Properties i18nProps = new Properties ();
5453 static {
5554 InputStream is = null ;
5655 try {
5756 is = new BufferedInputStream (new FileInputStream (
58- CnstTools . PROPS_ROOT_PATH + CONF_FILE ));
57+ CONF_ROOT + CONF_FILE ));
5958 env .load (is );
6059 is .close ();
6160 }catch (IOException ioe ){
@@ -67,6 +66,18 @@ public class ConfigHelper {
6766 }
6867 }
6968 }
69+ if (is != null )is =null ;
70+ /**
71+ * i18n
72+ */
73+ try {
74+ is = new BufferedInputStream (new FileInputStream (
75+ CONF_ROOT + "zh-cn.properties" ));
76+ i18nProps .load (is );
77+ is .close ();
78+ }catch (Exception e ){
79+ logger .error ("load i18n config error." );
80+ }
7081 }
7182
7283 /**
@@ -196,4 +207,40 @@ public static boolean storeClientAddFileRootHash(String hash,String comments) th
196207 public static String getAddLogFileName (){
197208 return env .getProperty ("nbs.client.merkle.add.log.name" ,"" );
198209 }
210+
211+ /**
212+ * 控制显示会员
213+ * @return
214+ */
215+ public static boolean subWorldPeers (){
216+ String stats = env .getProperty ("nbs.client.im.topic.subworld" ,"enabled" );
217+ return (stats .equalsIgnoreCase ("enabled" )
218+ || stats .equalsIgnoreCase ("true" )
219+ || stats .equalsIgnoreCase ("1" )
220+ ) ? true : false ;
221+ }
222+
223+ public static String getI18nResourceHome (){
224+ String i18nHome = env .getProperty ("nbs.client.i18n.home" ,"zh_cn" );
225+ return OS_FILE_SEPARATOR +"icon" +OS_FILE_SEPARATOR +i18nHome +OS_FILE_SEPARATOR ;
226+ }
227+
228+ /**
229+ *
230+ * @param key
231+ * @return
232+ */
233+ public static String getI18nProperty (String key ){
234+ return i18nProps .getProperty (key );
235+ }
236+
237+ /**
238+ *
239+ * @param key
240+ * @param defaultVal
241+ * @return
242+ */
243+ public static String getI18nProperty (String key ,String defaultVal ){
244+ return i18nProps .getProperty (key ,defaultVal );
245+ }
199246}
0 commit comments