Browse Source

Added tw localization for file operation dialog

tobychui 4 years ago
parent
commit
38ccfd1cc6

+ 31 - 14
web/SystemAO/file_system/file_operation.html

@@ -1,12 +1,13 @@
 <html>
     <head>
-        <title>File Operation</title>
+        <title locale="title">File Operation</title>
         <meta charset="UTF-8">
         <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
         <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
         <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>
             .banner{
                 background-color:#4287f5;
@@ -40,13 +41,13 @@
     </head>
     <body>
         <div class="banner">
-            <div class="title">Calculating Operation</div>
+            <div class="title" locale="banner/title">Calculating Operation</div>
             <img id="opricon" src="img/loading.png" class="ui image"></img>
         </div>
         <div class="content">
-            <div class="info">From: <span id="src"></span></div>
-            <div class="info">To: <span id="dest"></span></div>
-            <div class="info">Progress: <span id="progress"> <i class="loading spinner icon"></i> Calculating</span></div>
+            <div class="info"><span locale="info/from">From:</span> <span id="src"></span></div>
+            <div class="info"><span locale="info/to">To:</span> <span id="dest"></span></div>
+            <div class="info"><span locale="info/progress">Progress:</span> <span id="progress"> <i class="loading spinner icon"></i> <span>Calculating</span></div>
             <div class="ui active small progress" style="margin-top:18px;">
                 <div id="progressbar" class="bar" style="width:100%; background-color:#4287f5;"></div>
             </div>
@@ -54,7 +55,7 @@
         <div class="ui modal" id="duplicateAction">
             <div class="content">
                 <div class="description" style="padding: 0px !important;">
-                    <p><i class="big exclamation triangle icon"></i> At least one file has the same filename with another existsing file. <b>Which action should be taken?</b></p><br>
+                    <p><i class="big exclamation triangle icon"></i> <span>At least one file has the same filename with another existsing file. <b>Which action should be taken?</b></span></p><br>
                 </div>
             </div>
             <div class="actions">
@@ -100,8 +101,24 @@
             //Initalized floatWindow events
             ao_module_setFixedWindowSize();
             ao_module_setWindowSize(400,220);
+            
+            if (applocale){
+                //Applocale found. Do localization
+                applocale.init("../locale/file_operation.json", function(){
+                    applocale.translate();
+                    init();
+                });
+            }else{
+                //Applocale not found. Is this a trim down version of ArozOS?
+                applocale = {
+                    getString: function(key, original){
+                        return original;
+                    }
+                }
+                init();
+            }
 
-            init();
+            
             function init(){
                 console.log("Checking launch parameters...");
                 if (window.location.hash.length > 0){
@@ -597,22 +614,22 @@ mainloop:
             function updateTitle(fileNumber, opr){
                 var title = "";
                 if (opr == "move"){
-                    title = "Moving ";
+                    title = applocale.getString("title/moving","Moving ");
                 }else if (opr == "copy"){
-                    title = "Copying ";
+                    title = applocale.getString("title/copying","Copying ");
                 }else if (opr == "zip" || opr == "zipAndDownload"){
-                    title = "Zipping ";
+                    title = applocale.getString("title/zipping","Zipping ");
                 }else if (opr == "download"){
-                    title = "Downloading ";
+                    title = applocale.getString("title/downloading","Downloading ");
                 }else if (opr == "unzip" || opr == "unzipAndOpen"){
-                    title = "Unzipping ";
+                    title = applocale.getString("title/unzipping","Unzipping ");
                 }
 
                 title += fileNumber + " ";
                 if (fileNumber == 1){
-                    title += " File";
+                    title += applocale.getString("title/file"," File");
                 }else{
-                    title += " Files";
+                    title += applocale.getString("title/files"," Files");
                 }
 
                 $(".title").text(title);

+ 67 - 9
web/SystemAO/file_system/file_selector.html

@@ -1,6 +1,6 @@
 <html>
     <head>
-        <title>File Selector</title>
+        <title locale="title">File Selector</title>
         <meta charset="UTF-8">
         <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
         <link rel="stylesheet" href="../../script/tocas/tocas.css">
@@ -8,6 +8,7 @@
         <script type="text/javascript" src="../../script/tocas/tocas.js"></script>
         <script type="text/javascript" src="../../script/jquery.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;
@@ -87,10 +88,10 @@
                 </div>
             </div>
 
-            <div id="newFolderInput" style="width:100%; margin-top:12px; display:none;" align="right">
+            <div id="newFolderInput" style="width:100%; margin-top:4px; display:none;" align="right">
                 <div  class="ts fluid action tiny input" style="width: calc(100% - 180px); float: right;">
                     <input id="foldername" type="text" placeholder="New Folder" value="">
-                    <button class="ts icon button" onclick="createFolder()"><i class="add icon"></i></button>
+                    <button class="ts icon button" onclick="createFolder()" title="Create Folder"><i class="add icon"></i></button>
                 </div>
             </div>
         </div>
@@ -98,7 +99,7 @@
             <div id="sidebarPadder" style="height:46px;"></div>
             <details class="ts accordion" open>
                 <summary>
-                    <i class="dropdown icon"></i> User
+                    <i class="dropdown icon"></i> <span locale="roots/user">User</span>
                 </summary>
                 <div class="content" >
                     <div class="ts list" id="userlist">
@@ -107,7 +108,7 @@
             </details>
             <details class="ts accordion" open>
                 <summary>
-                    <i class="dropdown icon"></i> Storage
+                    <i class="dropdown icon"></i> <span locale="roots/storage">Storage</span>
                 </summary>
                 <div class="content">
                     <div class="ts list" id="storagelist">
@@ -121,7 +122,7 @@
             <div class="fileListWrapper" style="min-height:300px; width:100%;">
                 <div id="folderList" class="ts segmented basic fluid list whiteTheme">
                     <div class="fileObject">
-                        <span class="fileInfo"><i class="loading spinner icon" style="margin-right:12px;"></i>  Loading</span>
+                        <span class="fileInfo"><i class="loading spinner icon" style="margin-right:12px;"></i>  <span locale="message/loading">Loading</span></span>
                     </div>
                 </div>
                 <div id="fileList" class="ts segmented fluid list whiteTheme">
@@ -132,7 +133,7 @@
             <br><br>
         </div>
         <div id="waitloader" class="ts active dimmer" style="display:none; z-index:999;">
-            <div id="waitloadertext" class="ts indeterminate text loader">Waiting Response</div>
+            <div id="waitloadertext" class="ts indeterminate text loader" locale="message/waitingResp">Waiting Response</div>
         </div>
         <script>
             var multiSelect = false;
@@ -146,8 +147,23 @@
             var listenerUUID = "";
             var fileOptions = {};
 
+            if (applocale){
+                //Applocale found. Do localization
+                applocale.init("../locale/file_selector.json", function(){
+                    applocale.translate();
+                    initRoots();
+                });
+            }else{
+                //Applocale not found. Is this a trim down version of ArozOS?
+                applocale = {
+                    getString: function(key, original){
+                        return original;
+                    }
+                }
+                initRoots();
+            }
+
             initSelectorObject();
-            initRoots();
             updateWindowResize();
 
             function initSelectorObject(){
@@ -638,13 +654,55 @@
                                 //Do not show hidden files
                                 continue;
                             }
-                            $('#userlist').append(`<div class="item extrapadding" filepath="${data[i]["Filepath"]}" onclick="openShortcut(this);"><i class="folder icon" style="margin-right:8px;"></i> ${data[i]["Filename"]}</div>`);
+
+                            //Get the icon and the localization of this user root
+                            var iconAndFolderName = getUserRootIcons(data[i]["Filename"]);
+                            console.log(iconAndFolderName);
+                            $('#userlist').append(`<div class="item extrapadding" filepath="${data[i]["Filepath"]}" onclick="openShortcut(this);"><i class="${iconAndFolderName[0]} icon" style="margin-right:8px;"></i> ${iconAndFolderName[1]}</div>`);
                         }
                         
                     }
                 });
             }
 
+            function getUserRootIcons(foldername){
+                var icon = "folder open";
+                var name = foldername;
+                foldername = foldername.toLowerCase();
+                if (foldername == "desktop"){
+                    icon = "computer";
+                    name = applocale.getString("sidebar/vroot/desktop", name);
+                }else if (foldername == "document"){
+                    icon = "file text outline";
+                    name = applocale.getString("sidebar/vroot/document", name);
+                }else if (foldername == "music" || foldername == "audio"){
+                    icon = "music";
+                    name = applocale.getString("sidebar/vroot/music", name);
+                }else if (foldername == "photo" || foldername == "picture"){
+                    icon = "image";
+                    name = applocale.getString("sidebar/vroot/photo", name);
+                }else if (foldername == "video" || foldername == "film"){
+                    icon = "video";
+                    name = applocale.getString("sidebar/vroot/video", name);
+                }else if (foldername == "trash" || foldername == "bin" || foldername == "rubbish"){
+                    icon = "trash"
+                    name = applocale.getString("sidebar/vroot/trash", name);
+                }else if (foldername == "download"){
+                    icon = "download"
+                    name = applocale.getString("sidebar/vroot/download", name);
+                }else if (foldername == "www" || foldername == "web" || foldername == "mysite"){
+                    icon = "globe"
+                    name = applocale.getString("sidebar/vroot/web", name);
+                }else if (foldername == "model"){
+                    icon = "cube"
+                    name = applocale.getString("sidebar/vroot/model", name);
+                }else if (foldername == "appdata"){
+                    icon = "code"
+                    name = applocale.getString("sidebar/vroot/appdata", name);
+                }
+                return [icon, name];
+            }
+
             function openShortcut(object){
                 var targetdir = $(object).attr("filepath");
                 targetdir = decodeURIComponent(targetdir);

+ 6 - 6
web/SystemAO/locale/file_explorer.json

@@ -120,8 +120,8 @@
                 "upload/count/pending": " 等待中",
 
                 "message/rename/success": "重新命名成功",
-                "message/copy/success": " 個檔案已準備複製",
-                "message/move/success": " 個檔案已準備移動",
+                "message/copy/success": " 個檔案已複製",
+                "message/move/success": " 個檔案已移動",
                 "message/paste/nothing": "沒有可貼上的檔案",
                 "message/remove/success": " 個檔案已被成功刪除",
                 "message/recycle/success": " 個檔案已被成功移動到資源回收箱",
@@ -294,8 +294,8 @@
                 "upload/count/pending": " 等待中",
 
                 "message/rename/success": "重新命名成功",
-                "message/copy/success": " 個檔案已準備複製",
-                "message/move/success": " 個檔案已準備移動",
+                "message/copy/success": " 個檔案已複製",
+                "message/move/success": " 個檔案已移動",
                 "message/paste/nothing": "沒有可貼上的檔案",
                 "message/remove/success": " 個檔案已被成功刪除",
                 "message/recycle/success": " 個檔案已被成功移動到資源回收箱",
@@ -468,8 +468,8 @@
                 "upload/count/pending": " 等待中",
 
                 "message/rename/success": "重新命名成功",
-                "message/copy/success": " 个文件已准备复制",
-                "message/move/success": " 个文件已准备移动",
+                "message/copy/success": " 个文件已复制",
+                "message/move/success": " 个文件已移动",
                 "message/paste/nothing": "没有可粘贴的文件",
                 "message/remove/success": " 个文件已被成功删除",
                 "message/recycle/success": " 个文件已被成功移动到资源回收箱",

+ 60 - 0
web/SystemAO/locale/file_operation.json

@@ -0,0 +1,60 @@
+{
+    "author": "tobychui",
+    "version": "1.0",
+    "keys": {
+        "zh-tw": {
+            "fwtitle" : "檔案操作 - 計算中",
+            "fontFamily":"\"Microsoft JhengHei\",\"SimHei\", \"Apple LiGothic Medium\", \"STHeiti\"",
+            "strings":{
+                "title":"檔案操作 - 計算中",
+                "banner/title":"正在計算檔案操作需時",
+                "info/from":"來源:",
+                "info/to":"目的地:",
+                "info/progress":"進度:",
+                "info/calculating":"計算中",
+                "dup/question":"目的地存在至少一個具有重複檔名的檔案。 <b>應對該檔案使用以下哪種操作?</b>",
+                "dup/overwrite":"覆寫",
+                "dup/skip":"跳過",
+                "dup/renameAndKeep":"更名並保留",
+                "title/moving":"正在移動 ",
+                "title/copying":"正在複製",
+                "title/zipping":"正在壓縮 ",
+                "title/downloading":"正在下載 ",
+                "title/unzipping":"正在解壓 ",
+                "title/file":" 個檔案",
+                "title/files":" 個檔案",
+                "":""
+            },
+            "titles":{
+
+            },
+            "placeholder":{
+
+            }
+        },
+        "zh-hk": {
+            "fwtitle" : "",
+            "strings":{
+
+            },
+            "titles":{
+
+            },
+            "placeholder":{
+
+            }
+        },
+        "zh-cn": {
+            "fwtitle" : "",
+            "strings":{
+
+            },
+            "titles":{
+
+            },
+            "placeholder":{
+
+            }
+        }
+    }
+}

+ 111 - 0
web/SystemAO/locale/file_selector.json

@@ -0,0 +1,111 @@
+{
+    "author": "tobychui",
+    "version": "1.0",
+    "keys": {
+        "zh-tw": {
+            "fwtitle" : "選擇檔案",
+            "fontFamily":"\"Microsoft JhengHei\",\"SimHei\", \"Apple LiGothic Medium\", \"STHeiti\"",
+            "strings":{
+                "title":"選擇檔案",
+                "roots/user":"使用者",
+                "roots/storage":"虛擬儲存裝置",
+                "message/loading":"載入中…",
+                "message/waitingResp":"正在確認選擇…",
+
+                "sidebar/vroot/desktop": "桌面",
+                "sidebar/vroot/document": "文件",
+                "sidebar/vroot/music": "音樂",
+                "sidebar/vroot/photo": "圖片",
+                "sidebar/vroot/video": "影片",
+                "sidebar/vroot/trash": "回收箱",
+                "sidebar/vroot/download": "下載",
+                "sidebar/vroot/web": "網頁",
+                "sidebar/vroot/model": "模型",
+                "sidebar/vroot/appdata": "程序數據",
+
+                "":""
+            },
+            "titles":{
+                "Back":"上一頁",
+                "Parent":"返回上層目錄",
+                "Refresh":"重新整理",
+                "Create Folder":"建立資料夾",
+                "New Folder":"新增資料夾"
+            },
+            "placeholder":{
+                "New Filename":"新增檔案",
+                "New Folder":"新增資料夾"
+            }
+        },
+        "zh-hk": {
+            "fwtitle" : "選擇檔案",
+            "fontFamily":"\"Microsoft JhengHei\",\"SimHei\", \"Apple LiGothic Medium\", \"STHeiti\"",
+            "strings":{
+                "title":"選擇檔案",
+                "roots/user":"使用者",
+                "roots/storage":"虛擬儲存裝置",
+                "message/loading":"載入中…",
+                "message/waitingResp":"正在確認選擇…",
+
+                "sidebar/vroot/desktop": "桌面",
+                "sidebar/vroot/document": "文件",
+                "sidebar/vroot/music": "音樂",
+                "sidebar/vroot/photo": "圖片",
+                "sidebar/vroot/video": "影片",
+                "sidebar/vroot/trash": "回收箱",
+                "sidebar/vroot/download": "下載",
+                "sidebar/vroot/web": "網頁",
+                "sidebar/vroot/model": "模型",
+                "sidebar/vroot/appdata": "程序數據",
+                
+                "":""
+            },
+            "titles":{
+                "Back":"上一頁",
+                "Parent":"返回上層目錄",
+                "Refresh":"重新整理",
+                "Create Folder":"建立資料夾",
+                "New Folder":"新增資料夾"
+            },
+            "placeholder":{
+                "New Filename":"新增檔案",
+                "New Folder":"新增資料夾"
+            }
+        },
+        "zh-cn": {
+            "fwtitle" : "选择文件",
+            "fontFamily":"\"Microsoft JhengHei\",\"SimHei\", \"Apple LiGothic Medium\", \"STHeiti\"",
+            "strings":{
+                "title":"选择文件",
+                "roots/user":"使用者",
+                "roots/storage":"虚拟储存装置",
+                "message/loading":"载入中…",
+                "message/waitingResp":"正在确认选择…",
+
+                "sidebar/vroot/desktop": "桌面",
+                "sidebar/vroot/document": "文件",
+                "sidebar/vroot/music": "音乐",
+                "sidebar/vroot/photo": "图片",
+                "sidebar/vroot/video": "影片",
+                "sidebar/vroot/trash": "回收箱",
+                "sidebar/vroot/download": "下载",
+                "sidebar/vroot/web": "网页",
+                "sidebar/vroot/model": "模型",
+                "sidebar/vroot/appdata": "程序数据",
+                
+                "":""
+            },
+            "titles":{
+                "Back":"上一页",
+                "Parent":"返回上层目录",
+                "Refresh":"重新整理",
+                "Create Folder":"建立资料夹",
+                "New Folder":"新增资料夹"
+            },
+            "placeholder":{
+                "New Filename":"新增档案",
+                "New Folder":"新增资料夹"
+            } 
+        }
+    }
+}