Browse Source

Added some localization for updates

Toby Chui 1 year ago
parent
commit
49beb9e079

+ 1 - 1
main.flags.go

@@ -29,7 +29,7 @@ var subserviceBasePort = 12810            //Next subservice port
 
 
 // =========== SYSTEM BUILD INFORMATION ==============
 // =========== SYSTEM BUILD INFORMATION ==============
 var build_version = "development"                      //System build flag, this can be either {development / production / stable}
 var build_version = "development"                      //System build flag, this can be either {development / production / stable}
-var internal_version = "0.2.018"                       //Internal build version, [fork_id].[major_release_no].[minor_release_no]
+var internal_version = "0.2.019"                       //Internal build version, [fork_id].[major_release_no].[minor_release_no]
 var deviceUUID string                                  //The device uuid of this host
 var deviceUUID string                                  //The device uuid of this host
 var deviceVendor = "IMUSLAB.INC"                       //Vendor of the system
 var deviceVendor = "IMUSLAB.INC"                       //Vendor of the system
 var deviceVendorURL = "http://imuslab.com"             //Vendor contact information
 var deviceVendorURL = "http://imuslab.com"             //Vendor contact information

+ 8 - 8
mod/iot/handlerManager.go

@@ -38,7 +38,7 @@ func NewIoTManager(sysdb *database.Database) *Manager {
 	}
 	}
 }
 }
 
 
-//Register the handler as one of the IoT Protocol Handler.
+// Register the handler as one of the IoT Protocol Handler.
 func (m *Manager) RegisterHandler(h ProtocolHandler) error {
 func (m *Manager) RegisterHandler(h ProtocolHandler) error {
 	//Try to start the handler
 	//Try to start the handler
 	err := h.Start()
 	err := h.Start()
@@ -53,7 +53,7 @@ func (m *Manager) RegisterHandler(h ProtocolHandler) error {
 	return nil
 	return nil
 }
 }
 
 
-//Handle listing of all avaible scanner and its stats
+// Handle listing of all avaible scanner and its stats
 func (m *Manager) HandleScannerList(w http.ResponseWriter, r *http.Request) {
 func (m *Manager) HandleScannerList(w http.ResponseWriter, r *http.Request) {
 	stats := []Stats{}
 	stats := []Stats{}
 	for _, scanner := range m.RegisteredHandler {
 	for _, scanner := range m.RegisteredHandler {
@@ -65,7 +65,7 @@ func (m *Manager) HandleScannerList(w http.ResponseWriter, r *http.Request) {
 	utils.SendJSONResponse(w, string(js))
 	utils.SendJSONResponse(w, string(js))
 }
 }
 
 
-//Get the device object by id
+// Get the device object by id
 func (m *Manager) GetDeviceByID(devid string) *Device {
 func (m *Manager) GetDeviceByID(devid string) *Device {
 	for _, dev := range m.cachedDeviceList {
 	for _, dev := range m.cachedDeviceList {
 		if dev.DeviceUUID == devid {
 		if dev.DeviceUUID == devid {
@@ -75,7 +75,7 @@ func (m *Manager) GetDeviceByID(devid string) *Device {
 	return nil
 	return nil
 }
 }
 
 
-//Handle listing of all avaible scanner and its stats
+// Handle listing of all avaible scanner and its stats
 func (m *Manager) HandleIconLoad(w http.ResponseWriter, r *http.Request) {
 func (m *Manager) HandleIconLoad(w http.ResponseWriter, r *http.Request) {
 	devid, err := utils.GetPara(r, "devid")
 	devid, err := utils.GetPara(r, "devid")
 	if err != nil {
 	if err != nil {
@@ -96,7 +96,7 @@ func (m *Manager) HandleIconLoad(w http.ResponseWriter, r *http.Request) {
 	}
 	}
 }
 }
 
 
-//Handle listing of all avaible scanner and its stats
+// Handle listing of all avaible scanner and its stats
 func (m *Manager) HandleExecute(w http.ResponseWriter, r *http.Request) {
 func (m *Manager) HandleExecute(w http.ResponseWriter, r *http.Request) {
 	devid, err := utils.PostPara(r, "devid")
 	devid, err := utils.PostPara(r, "devid")
 	if err != nil {
 	if err != nil {
@@ -142,7 +142,7 @@ func (m *Manager) HandleExecute(w http.ResponseWriter, r *http.Request) {
 	utils.SendJSONResponse(w, string(js))
 	utils.SendJSONResponse(w, string(js))
 }
 }
 
 
-//Get status of the given device ID
+// Get status of the given device ID
 func (m *Manager) HandleGetDeviceStatus(w http.ResponseWriter, r *http.Request) {
 func (m *Manager) HandleGetDeviceStatus(w http.ResponseWriter, r *http.Request) {
 	devid, err := utils.PostPara(r, "devid")
 	devid, err := utils.PostPara(r, "devid")
 	if err != nil {
 	if err != nil {
@@ -171,7 +171,7 @@ func (m *Manager) HandleGetDeviceStatus(w http.ResponseWriter, r *http.Request)
 	utils.SendErrorResponse(w, "Given device ID does not match any scanned devices")
 	utils.SendErrorResponse(w, "Given device ID does not match any scanned devices")
 }
 }
 
 
-//Handle IoT Scanning Request
+// Handle IoT Scanning Request
 func (m *Manager) HandleScanning(w http.ResponseWriter, r *http.Request) {
 func (m *Manager) HandleScanning(w http.ResponseWriter, r *http.Request) {
 	//Scan the devices
 	//Scan the devices
 	scannedDevices := m.ScanDevices()
 	scannedDevices := m.ScanDevices()
@@ -180,7 +180,7 @@ func (m *Manager) HandleScanning(w http.ResponseWriter, r *http.Request) {
 	utils.SendJSONResponse(w, string(js))
 	utils.SendJSONResponse(w, string(js))
 }
 }
 
 
-//Handle IoT Listing Request
+// Handle IoT Listing Request
 func (m *Manager) HandleListing(w http.ResponseWriter, r *http.Request) {
 func (m *Manager) HandleListing(w http.ResponseWriter, r *http.Request) {
 
 
 	if m.cachedDeviceList == nil || len(m.cachedDeviceList) == 0 {
 	if m.cachedDeviceList == nil || len(m.cachedDeviceList) == 0 {

+ 3 - 0
web/SystemAO/locale/system_settings.json

@@ -23,6 +23,7 @@
                 "tab/info/Performance":"效能",
                 "tab/info/Performance":"效能",
                 "tab/info/Runtime":"運行環境",
                 "tab/info/Runtime":"運行環境",
                 "tab/info/Power":"電源",
                 "tab/info/Power":"電源",
+                "tab/info/Updates":"系統更新",
 
 
                 "tab/module/Add & Remove Module":"新增或移除模組",
                 "tab/module/Add & Remove Module":"新增或移除模組",
                 "tab/module/Subservices":"子服務",
                 "tab/module/Subservices":"子服務",
@@ -158,6 +159,7 @@
                 "tab/info/Performance":"效能",
                 "tab/info/Performance":"效能",
                 "tab/info/Runtime":"運行環境",
                 "tab/info/Runtime":"運行環境",
                 "tab/info/Power":"電源",
                 "tab/info/Power":"電源",
+                "tab/info/Updates":"系統更新",
 
 
                 "tab/module/Add & Remove Module":"新增或移除模組",
                 "tab/module/Add & Remove Module":"新增或移除模組",
                 "tab/module/Subservices":"子服務",
                 "tab/module/Subservices":"子服務",
@@ -292,6 +294,7 @@
                 "tab/info/Performance":"效能",
                 "tab/info/Performance":"效能",
                 "tab/info/Runtime":"运行环境",
                 "tab/info/Runtime":"运行环境",
                 "tab/info/Power":"电源",
                 "tab/info/Power":"电源",
+                "tab/info/Updates":"系统升级",
 
 
                 "tab/module/Add & Remove Module":"新增或移除模组",
                 "tab/module/Add & Remove Module":"新增或移除模组",
                 "tab/module/Subservices":"子服务",
                 "tab/module/Subservices":"子服务",

+ 40 - 0
web/SystemAO/locale/system_settings/updates.json

@@ -0,0 +1,40 @@
+{
+    "author": "tobychui",
+    "version": "1.0",
+    "keys": {
+        "zh-tw": {
+            "name": "繁體中文(台灣)",
+            "fontFamily":"\"Microsoft JhengHei\",\"SimHei\", \"Apple LiGothic Medium\", \"STHeiti\"",
+            "strings":{
+                "header/title/systemUpdate": "系統更新",
+                "header/title/subHeader": "更新本機的 ArozOS 至最新版本",
+                "warning/title": "警告!",
+                "warning/desc": "更新前請先備份所有重要檔案",
+                "checking/title": "正在連接到下載伺服器",
+                "checking/desc": "系統正在載入更新資源",
+                "confirm/title": "確認更新到最新版本?",
+                "confirm/update/willUse": "本更新將會使用 ",
+                "confirm/update/ofSpace": " 的儲存空間",
+                "confirm/update/confirm": "確認更新",
+                "confirm/update/cancel": "取消更新",
+                "confirm/update/reminder": "請確保您在開始前已備份所有重要的檔案及設定",
+                "download/title": "正在準備更新",
+                "download/wsFallback": "無法與伺服器建立 WebSocket 連接。正在使用 AJAX 下載模式(無進度顯示屬正常狀態) <br>請等待下載完成並不要關閉本視窗。</br>",
+
+                "":""
+            },
+            "titles":{
+
+            },
+            "placeholder":{
+
+            }
+        },
+        "zh-hk": {
+            
+        },
+        "zh-cn": {
+            
+        }
+    }
+}

+ 21 - 17
web/SystemAO/updates/index.html

@@ -8,6 +8,7 @@
     <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
     <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/jquery.min.js"></script>
     <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
     <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
+    <script type="text/javascript" src="../../script/applocale.js"></script>
     <!-- <script type="text/javascript" src="../../script/ao_module.js"></script> -->
     <!-- <script type="text/javascript" src="../../script/ao_module.js"></script> -->
 </head>
 </head>
 
 
@@ -17,8 +18,8 @@
             <h3 class="ui header">
             <h3 class="ui header">
                 <i class="sync icon"></i>
                 <i class="sync icon"></i>
                 <div class="content">
                 <div class="content">
-                    System Update
-                    <div class="sub header">Update the ArozOS System to the latest version</div>
+                    <span locale="header/title/systemUpdate">System Update</span>
+                    <div class="sub header" locale="header/title/subHeader">Update the ArozOS System to the latest version</div>
                 </div>
                 </div>
             </h3>
             </h3>
             <div class="ui divider"></div>
             <div class="ui divider"></div>
@@ -27,42 +28,42 @@
                 <i class="red exclamation circle icon"></i>
                 <i class="red exclamation circle icon"></i>
                 <div class="content">
                 <div class="content">
                     <div class="header">
                     <div class="header">
-                        WARNING
+                        <span locale="warning/title">WARNING</span>
                     </div>
                     </div>
-                    <p>Backup all the important files before performing system update</p>
+                    <p locale="warning/desc">Backup all the important files before performing system update</p>
                 </div>
                 </div>
             </div>
             </div>
             <div id="checking" class="ui icon blue message" style="display:none;">
             <div id="checking" class="ui icon blue message" style="display:none;">
                 <i class="notched circle loading icon"></i>
                 <i class="notched circle loading icon"></i>
                 <div class="content">
                 <div class="content">
                     <div class="header">
                     <div class="header">
-                        Connecting to Download Server
+                        <span locale="checking/title">Connecting to Download Server</span>
                     </div>
                     </div>
-                    <p>We're fetching that content for you.</p>
+                    <p locale="checking/desc">We're fetching that content for you.</p>
                 </div>
                 </div>
             </div>
             </div>
             <div id="confirmDownload" class="ui icon yellow message" style="display:none;">
             <div id="confirmDownload" class="ui icon yellow message" style="display:none;">
                 <i class="yellow exclamation icon"></i>
                 <i class="yellow exclamation icon"></i>
                 <div class="content">
                 <div class="content">
                     <div class="header">
                     <div class="header">
-                        Confirm Update?
+                        <span locale="confirm/title">Confirm Update?</span>
                     </div>
                     </div>
-                    <p><span>This updates will take up </span><span id="spaceEst" style="font-weight: bold;"></span> <span>of space.</span></p>
-                    <p><b>Please make sure you have back up all important files and config files before you proceeds.</b></p>
+                    <p><span locale="confirm/update/willUse">This updates will take up </span><span id="spaceEst" style="font-weight: bold;"></span> <span locale="confirm/update/ofSpace">of space.</span></p>
+                    <p><b locale="confirm/update/reminder">Please make sure you have back up all important files and config files before you proceeds.</b></p>
                     <div class="ui buttons">
                     <div class="ui buttons">
-                        <button class="ui yellow button" onclick="confirmURLUpdate();">Confirm Update</button>
-                        <button class="ui button" onclick="cancelUpdateStatus();"><i class="ui remove icon"></i> Cancel Update</button>
+                        <button locale="confirm/update/confirm" class="ui yellow button" onclick="confirmURLUpdate();">Confirm Update</button>
+                        <button locale="confirm/update/cancel" class="ui button" onclick="cancelUpdateStatus();"><i class="ui remove icon"></i> Cancel Update</button>
                     </div>
                     </div>
                 </div>
                 </div>
             </div>
             </div>
             <div id="downloading" class="ui icon blue message" style="display:none;">
             <div id="downloading" class="ui icon blue message" style="display:none;">
                 <i class="notched circle loading icon"></i>
                 <i class="notched circle loading icon"></i>
                 <div class="content">
                 <div class="content">
-                    <div class="header" id="downloadStatusText">
+                    <div class="header" id="downloadStatusText" locale="download/title">
                         Starting Download Session
                         Starting Download Session
                     </div>
                     </div>
                     <br>
                     <br>
-                    <p id="fallbackmodeExp" style="display:none;">You are seeing this message is because the websocket connection to your host failed to establish. No worry, updates can still be done using AJAX fallback mode, just without the real time progress updates. <br>Please wait until the
+                    <p id="fallbackmodeExp" style="display:none;" locale="download/wsFallback">You are seeing this message is because the websocket connection to your host failed to establish. No worry, updates can still be done using AJAX fallback mode, just without the real time progress updates. <br>Please wait until the
                         download complete before closing this page.</br>
                         download complete before closing this page.</br>
                     </p>
                     </p>
                     <div class="ui blue active progress">
                     <div class="ui blue active progress">
@@ -180,10 +181,13 @@
         var vendorUpdateWebpackURL = "";
         var vendorUpdateWebpackURL = "";
         var vendorUpdateCheckSumURL = "";
         var vendorUpdateCheckSumURL = "";
 
 
-        $(".accordion").accordion();
-        initVendorUpdateInfo();
-        checkPendingUpdates();
-
+        applocale.init("../locale/system_settings/updates.json", function(){
+            $(".accordion").accordion();
+            initVendorUpdateInfo();
+            checkPendingUpdates();
+            applocale.translate();
+        });
+      
         function checkPendingUpdates() {
         function checkPendingUpdates() {
             $.get("../../system/update/checkpending", function(data) {
             $.get("../../system/update/checkpending", function(data) {
                 if (data == true) {
                 if (data == true) {