I18n(前端国际化)-jQuery.i18n.properties

  • 引入脚本文件   
<script type="text/javascript" src="jquery/jquery-1.8.3.min.js"></script>  
<script type="text/javascript" src="js/jquery.i18n.properties-min-1.0.9.js"></script>  
  • 编写前端代码
<body>  
    <label data-locale="hupu_username">用户名:</label><input type="text">  
    <label data-locale="hupu_password">密码:</label><input type="password">  
 </body>  
  • 编写国际化执行脚本
<script type="text/javascript">  
    loadProperties();  
    function loadProperties() {  
         $.i18n.properties({  
             name:'hupu-lang',  
             path:'i18n/',  
             mode:'map',  
             language:$.i18n.browserLang(),  
             callback:function(){  
                $("[data-locale]").each(function(){  
                    $(this).html($.i18n.prop($(this).data("locale")));  
                });  
             }  
         });  
     }  
</script>  

开源地址:https://github.com/jquery-i18n-properties/jquery-i18n-properties

Demo 地址:http://pan.baidu.com/s/1slCkUol

posted @ 2016-12-29 10:00  岁月静好_  阅读(266)  评论(0)    收藏  举报