JS實現html國際化三

步驟一javascript

<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>

步驟二java

<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>

步驟三jquery

<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>
相關文章
相關標籤/搜索