JS实现html国际化三
步骤一
<script type="text/javascript" src="../js/angular.min.js"></script> <script type="text/javascript" src="../js/jquery-2.1.0.min.js"></script> <script type="text/javascript" src="../js/jquery.i18n.properties-min-1.0.9.js"></script> <script type="text/javascript" src="../js/jsmart.js"></script>
步骤二
<script type="text/javascript"> var app = angular.module("translate",[]); //修改默认边界符 app.config(function($interpolateProvider) { $interpolateProvider.startSymbol(‘[‘); $interpolateProvider.endSymbol(‘]‘); }); function translate($scope){ $scope.info = null; $.i18n.properties({ name:‘messageResources‘, language:‘zh_CN‘, path:‘../resource/‘, mode:‘map‘, callback:function(){ $scope.info = $.i18n.map; } }); } </script>
步骤三
<body ng-controller="translate"> <div id="test"> <script id="jsmart_tpl" type="text/x-jsmart-tmpl"> <!--<div ng-bind="info.language"> </div>--> <div> [info.language] </div> </script> </div> <script type="text/javascript"> var data={aa:‘123‘,bb:‘1234‘}; var tpl = new jSmart(document.getElementById(‘jsmart_tpl‘).innerHTML); var res = tpl.fetch(data); $("#test").append(res); </script> </body>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。