Prechádzať zdrojové kódy

Added localization on tarshbin

tobychui 3 rokov pred
rodič
commit
76cf5f1b7b

+ 1 - 1
file_system.go

@@ -123,7 +123,7 @@ func FileSystemInit() {
 		Version:      "1.0",
 		StartDir:     "SystemAO/file_system/trashbin.html",
 		SupportFW:    true,
-		InitFWSize:   []int{1080, 580},
+		InitFWSize:   []int{400, 200},
 		LaunchFWDir:  "SystemAO/file_system/trashbin.html",
 		SupportEmb:   false,
 		SupportedExt: []string{"*"},

+ 69 - 48
web/SystemAO/file_system/trashbin.html

@@ -7,6 +7,7 @@
         <script type="text/javascript" src="../../script/jquery.min.js"></script>
         <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
         <script type="text/javascript" src="../../script/ao_module.js"></script>
+        <script type="text/javascript" src="../../script/applocale.js"></script>
         <style>
             body{
                 background-color:white;
@@ -45,54 +46,56 @@
         <span class="normalview">
         <div class="ui menu">
             <div class="header item">
-               <img class="ui middle aligned mini image" src="trashbin_img/small_icon.png" style="margin-right:8px; height:28px; width:28px;"></img> Trash Bin
+               <img class="ui middle aligned mini image" src="trashbin_img/small_icon.png" style="margin-right:8px; height:28px; width:28px;"></img> <span locale="title/title">Trash Bin</span>
             </div>
             <div class="right item">
-                <button class="ui negative small button" onclick="clearAll();">Delete All</button>
+                <button class="ui negative small button" onclick="clearAll();" locale="button/deleteAll">Delete All</button>
             </div>
         </div>
         <div class="ui container">
             <div class="ui segment">
                 <table class="ui celled table">
                     <thead>
-                        <tr><th>Filename</th>
-                        <th>Delete Time</th>
-                        <th>Details</th>
-                        <th>Restore</th>
-                    </tr></thead>
+                        <tr>
+                            <th locale="list/filename">Filename</th>
+                            <th locale="list/deleteTime">Delete Time</th>
+                            <th locale="list/details">Details</th>
+                            <th locale="list/restore">Restore</th>
+                        </tr>
+                    </thead>
                     <tbody id="trashList">
                     </tbody>
                 </table>
                 <div class="ui message" id="scanning">
-                    <i class="loading spinner icon"></i> Scanning for trash in all disks...
+                    <i class="loading spinner icon"></i> <span locale="list/scanning">Scanning for trash in all disks...</span>
                 </div>
             </div>
         </div>
         </span>
         <div class="confirmRemove" style="display:none;">
             <div class="banner">
-                <div class="title">Move <span id="fcount">0 File</span> to Trash Bin?</div>
+                <div class="title"><span locale="opr/move">Move</span> <span id="fcount">0 File</span> <span locale="opr/toTrashBin">to Trash Bin?</span></div>
                 <img id="opricon" src="trashbin_img/trashopr.png" class="ui image"></img>
             </div>
             <div class="content">
-                <div class="info">Deleting: <span class="filename"></span></div>
+                <div class="info"><span locale="opr/delete">Deleting:</span> <span class="filename"></span></div>
                 <div style="position:absolute; bottom:8px;right:4px;">
-                    <button class="ui small button" onclick="ao_module_close();">Cancel</button>
-                    <button class="ui primary small button" onclick="confirmDelete();">Confirm</button>
+                    <button class="ui small button" onclick="ao_module_close();" locale="opr/cancel">Cancel</button>
+                    <button class="ui primary small button" onclick="confirmDelete();" locale="opr/confirm">Confirm</button>
                 </div>
             </div>
         </div>
         <div class="ui modal" style="overflow-y:auto; overflow-x:hidden;">
             <i class="close icon"></i>
-            <div class="header filename">
+            <div class="header filename" locale="message/nofileselected">
                 No File Selected
             </div>
             <div class="ui basic segment">
                 <table class="ui very basic celled table">
                     <thead>
                         <tr>
-                            <th>Property</th>
-                            <th>Value</th>
+                            <th locale="message/property">Property</th>
+                            <th locale="message/value">Value</th>
                         </tr>
                     </thead>
                     <tbody id="detailList">
@@ -101,7 +104,7 @@
                 </table>
             </div>
             <div class="actions">
-                <div class="ui icon blue button" onclick=" $('.ui.modal').modal('hide');">
+                <div class="ui button" onclick=" $('.ui.modal').modal('hide');" locale="detail/ok">
                  OK
                 </div>
             </div>
@@ -112,26 +115,44 @@
             var previousTrashbinFilelist = [];
             var legacyMode = !('WebSocket' in window || 'MozWebSocket' in window); 
 
-            if (deletePendingFiles != null && deletePendingFiles.length > 0){
-                //Handle trash treatment
-                console.log(deletePendingFiles);
-                ao_module_setFixedWindowSize();
-                ao_module_setWindowSize(400,200);
-                $(".normalview").hide();
-                $(".confirmRemove").show();
+            if (!applocale){
+                applocale = {
+                    init: function(json, callback){
+                        if (callback){
+                            callback();
+                        }
+                    }
+                }
+            }
+            applocale.init("../../SystemAO/locale/trashbin.json", function(){
+                applocale.translate();
 
-                //Update graphical information
-                var displayname = deletePendingFiles[0].filename;
-                $("#fcount").text("1 File");
-                if (deletePendingFiles.length > 1){
-                    displayname = displayname + " and " + (deletePendingFiles.length - 1) + " more";
-                    $("#fcount").text(deletePendingFiles.length + " Files");
+                if (deletePendingFiles != null && deletePendingFiles.length > 0){
+                    //Handle trash treatment
+                    console.log(deletePendingFiles);
+                    ao_module_setFixedWindowSize();
+                    //ao_module_setWindowSize(400,200);
+                    $(".normalview").hide();
+                    $(".confirmRemove").show();
+
+                    //Update graphical information
+                    var displayname = deletePendingFiles[0].filename;
+                    $("#fcount").text("1 " + applocale.getString("opr/file", "File"));
+                    if (deletePendingFiles.length > 1){
+                        displayname = displayname + applocale.getString("opr/and", " and ") + (deletePendingFiles.length - 1) + applocale.getString("opr/more", " more");
+                        $("#fcount").text(deletePendingFiles.length + " " + applocale.getString("opr/files", "Files"));
+                    }
+                    $(".filename").text(displayname);
+
+                }else{
+                    //List all trash mode
+                    ao_module_setWindowSize(1080, 580);
+                    initList();
                 }
-                $(".filename").text(displayname);
 
-            }else{
-                initList();
-            }
+            });
+
+           
 
             //Initialize the trash list
             function initList(){
@@ -155,8 +176,8 @@
                         $("#trashList").append(`<tr>
                             <td>${thisFile.OriginalFilename}</td>
                             <td>${thisFile.RemoveDate}</td>
-                            <td><button filedata="${filedata}" class="ui tiny button" onclick="showDetail(this);">Details</button></td>
-                            <td><button filedata="${filedata}" class="ui green tiny button" onclick="restore(this);">Restore</button></td>
+                            <td><button filedata="${filedata}" class="ui tiny button" onclick="showDetail(this);">${applocale.getString("button/details","Details")}</button></td>
+                            <td><button filedata="${filedata}" class="ui green tiny button" onclick="restore(this);">${applocale.getString("button/restore", "Restore")}</button></td>
                         </tr>`);
                         previousTrashbinFilelist.push(thisFile);
                     };
@@ -188,14 +209,14 @@
                                 $("#trashList").append(`<tr>
                                     <td>${thisFile.OriginalFilename}</td>
                                     <td>${thisFile.RemoveDate}</td>
-                                    <td><button filedata="${filedata}" class="ui tiny button" onclick="showDetail(this);">Details</button></td>
-                                    <td><button filedata="${filedata}" class="ui green tiny button" onclick="restore(this);">Restore</button></td>
+                                    <td><button filedata="${filedata}" class="ui tiny button" onclick="showDetail(this);">${applocale.getString("button/details","Details")}</button></td>
+                                    <td><button filedata="${filedata}" class="ui green tiny button" onclick="restore(this);">${applocale.getString("button/restore", "Restore")}</button></td>
                                 </tr>`);
                                 previousTrashbinFilelist.push(thisFile);
                             }
 
                             if (data.length == 0){
-                                $("#trashList").append(`<tr><td colspan="4"><i class="checkmark icon"></i> There are no files or folders in Trashbin.</td></tr>`);
+                                $("#trashList").append(`<tr><td colspan="4"><i class="checkmark icon"></i> ${applocale.getString("message/notrash","There are no files or folders in Trashbin.")}</td></tr>`);
                             }
                             $("#scanning").hide();
                         }
@@ -240,15 +261,15 @@
                 $(".filename").text(filedata.OriginalFilename);
                 $("#detailList").html("");
                 var keyMapping = {
-                    "Filename": "Storage Filename",
-                    "Filepath": "Storage Filepath",
-                    "FileExt": "File Extension",
-                    "IsDir": "Is Directory",
-                    "Filesize": "File Size",
-                    "RemoveTimestamp": "Remove Timestamp",
-                    "RemoveDate": "Remove Datetime",
-                    "OriginalPath": "Original Path",
-                    "OriginalFilename": "Original Filename"
+                    "Filename": applocale.getString("detail/storageFilename", "Storage Filename"),
+                    "Filepath": applocale.getString("detail/storageFilepath","Storage Filepath"),
+                    "FileExt": applocale.getString("detail/fileExt","File Extension"),
+                    "IsDir": applocale.getString("detail/isDir","Is Directory"),
+                    "Filesize": applocale.getString("detail/filesize","File Size"),
+                    "RemoveTimestamp": applocale.getString("detail/removeTimestamp","Remove Timestamp"),
+                    "RemoveDate": applocale.getString("detail/removeDate","Remove Datetime"),
+                    "OriginalPath": applocale.getString("detail/originalPath","Original Path"),
+                    "OriginalFilename": applocale.getString("detail/originalFilename","Original Filename")
                 }
                 for (var [key, value] of Object.entries(filedata)) {
                     console.log(key, value);
@@ -278,7 +299,7 @@
             }
 
             function clearAll(){
-                if (confirm("Confirm deleting ALL FILE PERMANENTLY?")){
+                if (confirm(applocale.getString("message/confirmDelete", "Confirm deleting ALL FILE PERMANENTLY?"))){
                     $.get("../../system/file_system/clearTrash",function(data){
                         initList();
                     });

+ 159 - 0
web/SystemAO/locale/trashbin.json

@@ -0,0 +1,159 @@
+{
+    "author": "tobychui",
+    "version": "1.0",
+    "keys": {
+        "zh-tw": {
+            "fwtitle" : "垃圾箱",
+            "strings":{
+                "title/title":"垃圾箱",
+                
+                "button/deleteAll":"全部刪除",
+                "button/details":"詳情",
+                "button/restore":"恢復",
+
+                "list/filename":"檔案名稱",
+                "list/deleteTime":"刪除時間",
+                "list/details":"詳細資料",
+                "list/restore":"恢復檔案",
+                "list/scanning":"正在從所有虛擬磁碟區掃描回收檔案",
+                
+
+                "opr/move":"移動",
+                "opr/file":"檔案",
+                "opr/files":"檔案",
+                "opr/and":" 及 ",
+                "opr/more":" 等檔案",
+                "opr/toTrashBin":"到垃圾箱?",
+                "opr/delete":"刪除: ",
+                "opr/cancel":"取消",
+                "opr/confirm":"確認",
+                
+                "message/nofileselected":"沒有選擇任何檔案",
+                "message/property":"屬性",
+                "message/value":"數值",
+                "message/notrash":"垃圾箱內沒有檔案或資料夾",
+                "message/confirmDelete":"確認要 **永久刪除** 所有檔案?",
+
+                "detail/storageFilename":"檔案儲存名稱",
+                "detail/storageFilepath":"檔案虛擬儲存路徑",
+                "detail/fileExt":"副檔名",
+                "detail/isDir":"資料夾",
+                "detail/filesize":"檔案大小",
+                "detail/removeTimestamp":"刪除時間戳",
+                "detail/removeDate":"刪除日期",
+                "detail/originalPath":"原始檔案虛擬路徑",
+                "detail/originalFilename":"原始檔案名稱",
+                "detail/ok":"確定",
+                "":""
+            },
+            "titles":{
+
+            },
+            "placeholder":{
+
+            }
+        },
+        "zh-hk": {
+            "fwtitle" : "垃圾箱",
+            "strings":{
+                "title/title":"垃圾箱",
+                
+                "button/deleteAll":"全部刪除",
+                "button/details":"詳情",
+                "button/restore":"恢復",
+
+                "list/filename":"檔案名稱",
+                "list/deleteTime":"刪除時間",
+                "list/details":"詳細資料",
+                "list/restore":"恢復檔案",
+                "list/scanning":"正在從所有虛擬磁碟區掃描回收檔案",
+                
+
+                "opr/move":"移動",
+                "opr/file":"檔案",
+                "opr/files":"檔案",
+                "opr/and":" 及 ",
+                "opr/more":" 等檔案",
+                "opr/toTrashBin":"到垃圾箱?",
+                "opr/delete":"刪除: ",
+                "opr/cancel":"取消",
+                "opr/confirm":"確認",
+                
+                "message/nofileselected":"沒有選擇任何檔案",
+                "message/property":"屬性",
+                "message/value":"數值",
+                "message/notrash":"垃圾箱內沒有檔案或資料夾",
+                "message/confirmDelete":"確認要 **永久刪除** 所有檔案?",
+
+                "detail/storageFilename":"檔案儲存名稱",
+                "detail/storageFilepath":"檔案虛擬儲存路徑",
+                "detail/fileExt":"副檔名",
+                "detail/isDir":"資料夾",
+                "detail/filesize":"檔案大小",
+                "detail/removeTimestamp":"刪除時間戳",
+                "detail/removeDate":"刪除日期",
+                "detail/originalPath":"原始檔案虛擬路徑",
+                "detail/originalFilename":"原始檔案名稱",
+                "detail/ok":"確定",
+                "":""
+            },
+            "titles":{
+
+            },
+            "placeholder":{
+
+            }
+        },
+        "zh-cn": {
+            "fwtitle" : "垃圾箱",
+            "strings":{
+                "title/title":"垃圾箱",
+                
+                "button/deleteAll":"全部删除",
+                "button/details":"详情",
+                "button/restore":"恢复",
+
+                "list/filename":"文件名称",
+                "list/deleteTime":"删除时间",
+                "list/details":"详细资料",
+                "list/restore":"恢复文件",
+                "list/scanning":"正在从所有虚拟磁碟区扫描回收文件",
+                
+
+                "opr/move":"移动",
+                "opr/file":"文件",
+                "opr/files":"文件",
+                "opr/and":" 及 ",
+                "opr/more":" 等文件",
+                "opr/toTrashBin":"到垃圾箱?",
+                "opr/delete":"删除: ",
+                "opr/cancel":"取消",
+                "opr/confirm":"确认",
+                
+                "message/nofileselected":"没有选择任何文件",
+                "message/property":"属性",
+                "message/value":"数值",
+                "message/notrash":"垃圾箱内没有文件或资料夹",
+                "message/confirmDelete":"确认要 **永久删除** 所有文件? ",
+
+                "detail/storageFilename":"文件储存名称",
+                "detail/storageFilepath":"文件虚拟储存路径",
+                "detail/fileExt":"副档名",
+                "detail/isDir":"资料夹",
+                "detail/filesize":"文件大小",
+                "detail/removeTimestamp":"删除时间戳",
+                "detail/removeDate":"删除日期",
+                "detail/originalPath":"原始文件虚拟路径",
+                "detail/originalFilename":"原始文件名称",
+                "detail/ok":"确定",
+                "":"" 
+            },
+            "titles":{
+
+            },
+            "placeholder":{
+
+            }
+        }
+    }
+}

+ 1 - 1
web/desktop.system

@@ -12,7 +12,7 @@
     <script type="text/javascript" src="./script/ao_module.js"></script>
     <script type="text/javascript" src="./SystemAO/desktop/script/jsCalendar/source/jsCalendar.js"></script>
     <script type="text/javascript" src="./script/applocale.js"></script>
-    <script type="text/javascript" src="./script/html2canvas.min.js"></script>
+    <!-- <script type="text/javascript" src="./script/html2canvas.min.js"></script> -->
     <link rel="icon" href="img/system/favicon.png">
     <style>
         body {