소스 검색

初始化

zhengkaixin 3 년 전
부모
커밋
0c3ee31d00
5개의 변경된 파일22개의 추가작업 그리고 13개의 파일을 삭제
  1. 14 8
      assets/js/language.js
  2. 5 4
      html/lanhu/index.html
  3. 1 0
      i18n/strings.properties
  4. 0 0
      i18n/strings_zh.properties
  5. 2 1
      js/jquery.i18n.properties.js

+ 14 - 8
assets/js/language.js

@@ -1,16 +1,16 @@
 $(function(){
-	
-	function loadProperties() {
+	var default_value="en";
+	function loadProperties(val) {
 	            jQuery.i18n.properties({//加载资浏览器语言对应的资源文件
 	                name : 'strings', //资源文件名称
-	                path : '/i18n/', //资源文件路径
+	                path : '/lanhu-bootstrap/i18n/', //资源文件路径
 	                mode : 'map', //用Map的方式使用资源文件中的值
-	                language : 'zh-CH',
+	                language : val, // - 不支持  ,支持_
 	                callback : function() {//加载成功后设置显示内容
 	                    $('.i18n-text').each(function() {
-							console.log($(this).text())
-							
-	                        $(this).text($.i18n.prop($(this).text()));
+							var prop=$(this).attr('i18n')
+							var value=$.i18n.prop(prop)
+	                        $(this).text(value);
 	                    });
 						$('.i18n-input').each(function() {
 						    $(this).value($.i18n.prop($(this).text()));
@@ -19,5 +19,11 @@ $(function(){
 	                }
 	            });
 	        }
-			loadProperties();
+	$("#language").on("change",function(){
+		
+		loadProperties($(this).val());
+		
+	})
+	loadProperties(default_value);
+	
 })

+ 5 - 4
html/lanhu/index.html

@@ -11,11 +11,12 @@
 	<body>
 		<h1>1111</h1>
 		 <select id="language">
-		                <option value="zh-CN">中文简体</option>
-		                <option value="en">English</option>
-		            </select>
+					<option value="en">English</option>
+			
+		            <option value="zh">中文简体</option>
+		    </select>
 		<div>
-			<span   class="i18n-text">signOut</span>
+			<span   class="i18n-text" i18n="signOut"></span>
 		    <input type="search"  selectname="searchPlaceholder" selectattr="placeholder">
 		</div>
 	</body>

+ 1 - 0
i18n/strings.properties

@@ -0,0 +1 @@
+signOut=Login Out

+ 0 - 0
i18n/strings_zh-CH.properties → i18n/strings_zh.properties


+ 2 - 1
js/jquery.i18n.properties.js

@@ -333,13 +333,14 @@
         }
 
   	    if (filename !== null && typeof filename !== 'undefined') {
+			console.log(filename)
             $.ajax({
                 url: filename,
                 async: settings.async,
                 cache: settings.cache,
                 dataType: 'text',
                 success: function (data, status) {
-
+					
                     if (settings.debug) {
                         debug('Succeeded in downloading ' + filename + '.');
                         debug(data);