Browse Source

新建文档语言选择显示语言自称

visuddhinanda 5 năm trước cách đây
mục cha
commit
efc962ab25
2 tập tin đã thay đổi với 21 bổ sung1 xóa
  1. 18 0
      app/lang/function.php
  2. 3 1
      app/studio/project.php

+ 18 - 0
app/lang/function.php

@@ -0,0 +1,18 @@
+<?php 
+class lang_enum{
+    public $arrLang; //语言列表
+    public function __construct() {
+        $this->arrLang=json_decode(file_get_contents("../lang/lang_list.json"));
+    }
+    
+    public function getName($id){
+        foreach ($this->arrLang as $key => $value) {
+            if($value->code==$id){
+                return array("name"=>$value->name,"english"=>$value->english);
+            }
+        }
+        return array("name"=>$id,"english"=>"unknow");
+    }
+}
+
+?>

+ 3 - 1
app/studio/project.php

@@ -19,6 +19,7 @@ require_once "../public/load_lang.php";
 require_once "./book_list_en.inc";
 require_once "../ucenter/function.php";
 require_once "../ucenter/setting_function.php";
+require_once "../lang/function.php";
 
 $user_setting = get_setting();
 
@@ -412,8 +413,9 @@ switch($op){
 			echo "<fieldset>";
 			echo "<legend>Language 语言</legend>";
 			echo "<select name='lang'>";
+			$lang_list = new lang_enum;
 			foreach ($user_setting['studio.translation.lang'] as $key => $value) {
-				echo "<option value='{$value}'>".$value."</option>";
+				echo "<option value='{$value}'>".$lang_list->getName($value)["name"]."</option>";
 			}
 			
 			echo "</select>";