zoukankan      html  css  js  c++  java
  • java后台获取国际化资源文件


     //current属性,由于此属性只做赋值操作,不做取值操作,因此没有get方法
     private Locale current;

     public void setCurrent(Locale cur) {
      this.current = cur;
     }
     
     public Map<String, Locale> getLocales() throws UnsupportedEncodingException {
            Map<String, Locale> locales =new HashMap<String, Locale>(3);
            try {
             
             /*这里是根据当前用户选择的语言类型,获取指定资源文件,这一步非常重要
             (备注:资源文件如果不是放在src根目录下,需要加上path)*/
             
                ResourceBundle bundle = ResourceBundle.getBundle("com/wistron/wh/swpc/homesecurity/message" , current);
               if(bundle!=null){
                //设置工程支持的语言类型,key里的值对应资源文件里的key的值
                   locales.put(bundle.getString("hs_select_zh_tw"), Locale.TAIWAN);
                   //locales.put(bundle.getString("hs_select_zh_cn"), Locale.CHINA);
                   locales.put(bundle.getString("hs_select_zh_english"), Locale.US);
               }
              
            }catch(Exception ex){
             System.err.println("[Property]:Can't Load message_.properties");
             ex.printStackTrace();
            }
               
            return locales;
        }

  • 相关阅读:
    android自动登录
    【199】ArcGIS 添加自定义工具到工具箱
    【198】Synergy
    【197】PowerShell 通过 FTP 下载文件
    【196】Dell 移动工作站系统安装方法
    php如何同时连接多个数据库
    FreeRTOS学习笔记——任务间使用队列同步数据
    牛腩新闻发布系统之发布
    Linux散列表(二)——宏
    Excel导入数据库(三)——SqlBulkCopy
  • 原文地址:https://www.cnblogs.com/chubeautiful/p/3148935.html
Copyright © 2011-2022 走看看