From 4db3692de0001eea35f938c1224181746e72933a Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 27 十一月 2025 21:30:07 +0800
Subject: [PATCH] 支持创建阿拉伯语言的脚本文件夹

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlFileLogic.java |   85 +++++++++++++++++++-----------------------
 1 files changed, 38 insertions(+), 47 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlFileLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlFileLogic.java
index c3065ba..4f91804 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlFileLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlFileLogic.java
@@ -10,6 +10,8 @@
 import com.hdl.photovoltaic.HDLApp;
 import com.hdl.photovoltaic.config.ConstantManage;
 import com.hdl.photovoltaic.config.UserConfigManage;
+import com.hdl.photovoltaic.enums.Languages;
+import com.hdl.photovoltaic.ui.adapter.LanguageAdapter;
 import com.hdl.photovoltaic.utils.LocalManageUtil;
 
 import org.apache.commons.io.FileUtils;
@@ -23,6 +25,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -87,7 +90,7 @@
     }
 
     /**
-     * 鑾峰彇瀛樻斁銆愰┍鍔ㄦ枃浠跺す銆戞牴璺緞
+     * 鑾峰彇瀛樻斁椹卞姩銆愭枃浠跺す銆戞牴璺緞
      */
     public String getDriveRootPath() {
         return getAPPInternalStoreFilesPath() + "/upgrade/drive";
@@ -95,29 +98,26 @@
 
 
     /**
-     * 鑾峰彇瀛樻斁銆愬浐浠舵枃浠跺す銆戞牴璺緞
+     * 鑾峰彇瀛樻斁鍥轰欢銆愭枃浠跺す銆戞牴璺緞
      */
     public String getFirmwareRootPath() {
         return getAPPInternalStoreFilesPath() + "/upgrade/firmware";
     }
 
-    /**
-     * 鑾峰彇涓枃銆恓son璧勬簮鏂囦欢澶广�戝叏璺緞
-     */
-    public String getHdlESLocalJsonZhRootPath(String deviceModel) {
-        return getAPPInternalStoreFilesPath() + "/hdlESLocalJson/" + LocalManageUtil.zh + "/" + deviceModel;
-    }
 
     /**
-     * 鑾峰彇鑻辨枃銆恓son璧勬簮鏂囦欢澶广�戝叏璺緞
+     * 鑾峰彇json璧勬簮銆愭枃浠跺す銆戝叏璺緞
+     *
+     * @param language    璇█ 閫氳繃鏋氫妇绫籐anguages.en鑾峰彇
+     * @param deviceModel 璁惧鍨嬪彿
      */
-    public String getHdlESLocalJsonEnRootPath(String deviceModel) {
-        return getAPPInternalStoreFilesPath() + "/hdlESLocalJson/" + LocalManageUtil.en + "/" + deviceModel;
+    public String getHdlESLocalJsonRootPath(String language, String deviceModel) {
+        return getAPPInternalStoreFilesPath() + "/hdlESLocalJson/" + language + "/" + deviceModel;
     }
 
 
     /**
-     * 鑾峰彇銆愭棩蹇楁枃浠躲�戝叏璺緞
+     * 鑾峰彇鏃ュ織銆愭枃浠躲�戝叏璺緞
      */
     public String getLogFileNamePath() {
         return getCurrentHomeRootPath() + "/log.txt";
@@ -125,35 +125,28 @@
 
 
     /**
-     * 鑾峰彇銆愮敤鎴锋枃浠躲�戝叏璺緞
+     * 鑾峰彇鐢ㄦ埛銆愭枃浠躲�戝叏璺緞
      */
     public String getUserFilePath() {
         return getAPPInternalStoreFilesPath() + "/userConfigManage.txt";
     }
 
     /**
-     * 鑾峰彇涓枃銆恓son璧勬簮鏂囦欢銆戝叏璺緞
+     * 鑾峰彇鏈湴璇█json璧勬簮銆愭枃浠躲�戝叏璺緞
+     *
+     * @param language    璇█ 閫氳繃鏋氫妇绫籐anguages.en鑾峰彇
+     * @param deviceModel 璁惧鍨嬪彿
+     * @param fileName    鏂囦欢鍚�
      */
-    public String getHdlESLocalJsonZhFilePath(String deviceModel, String fileName) {
+    public String getHdlESLocalLanguageJsonFilePath(String language, String deviceModel, String fileName) {
         if (!fileName.endsWith(".json")) {
             fileName += ".json";
         }
-        return getAPPInternalStoreFilesPath() + "/hdlESLocalJson/" + LocalManageUtil.zh + "/" + deviceModel + "/" + fileName;
+        return getAPPInternalStoreFilesPath() + "/hdlESLocalJson/" + language + "/" + deviceModel + "/" + fileName;
     }
 
     /**
-     * 鑾峰彇鑻辨枃銆恓son璧勬簮鏂囦欢銆戝叏璺緞
-     */
-    public String getHdlESLocalJsonEnFilePath(String deviceModel, String fileName) {
-        if (!fileName.endsWith(".json")) {
-            fileName += ".json";
-        }
-        return getAPPInternalStoreFilesPath() + "/hdlESLocalJson/" + LocalManageUtil.en + "/" + deviceModel + "/" + fileName;
-    }
-
-
-    /**
-     * 鑾峰彇椹卞姩鍗囩骇鏂囦欢鍏ㄨ矾寰�
+     * 鑾峰彇椹卞姩鍗囩骇銆愭枃浠躲�戝叏璺緞
      *
      * @param driverCode 椹卞姩缂栫爜
      * @param version    椹卞姩鐗堟湰
@@ -165,7 +158,7 @@
     }
 
     /**
-     * 鑾峰彇鍥轰欢鍗囩骇鏂囦欢鍏ㄨ矾寰�
+     * 鑾峰彇鍥轰欢鍗囩骇銆愭枃浠躲�戝叏璺緞
      *
      * @param imageId 闀滃儚id
      * @param version 椹卞姩鐗堟湰
@@ -181,7 +174,7 @@
     //region    ---------銆愭枃浠跺す銆戞搷浣�-----------
 
     /**
-     * 棰勫垱寤烘枃浠跺す
+     * 棰勫垱寤恒�愭枃浠跺す銆�
      */
     public void createDirectory() {
         //瀛樻斁浣忓畢淇℃伅
@@ -190,28 +183,26 @@
         this.createFileDir(this.getDriveRootPath());
         //鍥轰欢鏂囦欢
         this.createFileDir(this.getFirmwareRootPath());
-
     }
 
     /**
-     * 棰勫垱寤簀son璧勬簮鏂囦欢澶�
+     * 棰勫垱寤鸿澶噅son璧勬簮銆愭枃浠跺す銆�
      */
-    public void createHdlESLocalJsonDirectory() {
-        //涓枃鏂囦欢澶�
-        this.createFileDir(this.getHdlESLocalJsonZhRootPath(HdlESLocalJsonLogic.deviceModel_ME_GSE_S5K));//閫嗗彉鍣�
-        this.createFileDir(this.getHdlESLocalJsonZhRootPath(HdlESLocalJsonLogic.deviceModel_ME_GSE_SPG63A));//璐熻浇涓績
-        this.createFileDir(this.getHdlESLocalJsonZhRootPath(HdlESLocalJsonLogic.deviceModel_ME_GSE_BMS15K));//BMS
-        this.createFileDir(this.getHdlESLocalJsonZhRootPath(HdlESLocalJsonLogic.deviceModel_ME_GSE_B5K));//鐢垫睜鍖�
-        //鑻辨枃鏂囦欢澶�
-        this.createFileDir(this.getHdlESLocalJsonEnRootPath(HdlESLocalJsonLogic.deviceModel_ME_GSE_S5K));
-        this.createFileDir(this.getHdlESLocalJsonEnRootPath(HdlESLocalJsonLogic.deviceModel_ME_GSE_SPG63A));
-        this.createFileDir(this.getHdlESLocalJsonEnRootPath(HdlESLocalJsonLogic.deviceModel_ME_GSE_BMS15K));
-        this.createFileDir(this.getHdlESLocalJsonEnRootPath(HdlESLocalJsonLogic.deviceModel_ME_GSE_B5K));
+    public void createHdlDeviceModelLocalJsonDirectory() {
+        List<LanguageAdapter.ItemData> languageList = LocalManageUtil.getLanguageList();
+        List<String> deviceModelList = HdlESLocalJsonLogic.getInstance().getModelList();
+        for (int i = 0; i < languageList.size(); i++) {
+            LanguageAdapter.ItemData languageModel = languageList.get(i);
+            for (int j = 0; j < deviceModelList.size(); j++) {
+                String deviceModel = deviceModelList.get(j);
+                this.createFileDir(this.getHdlESLocalJsonRootPath(languageModel.getLanguage(), deviceModel));//骞剁綉-閫嗗彉鍣�
+            }
+        }
 
     }
 
     /**
-     * 鍒涘缓鏂囦欢澶�
+     * 鍒涘缓銆愭枃浠跺す銆�
      *
      * @param fullPath fullPath 鍏ㄨ矾寰�
      * @return -
@@ -233,7 +224,7 @@
 
 
     /**
-     * 鍒犻櫎鏂囦欢澶�
+     * 鍒犻櫎銆愭枃浠跺す銆�
      *
      * @param fullPath 鍏ㄨ矾寰�
      */
@@ -267,7 +258,7 @@
     //region    ---------銆愭枃浠躲�戞搷浣�-----------
 
     /**
-     * 鍒涘缓鏂囦欢
+     * 鍒涘缓銆愭枃浠躲��
      *
      * @param fullPath 鍏ㄨ矾寰�
      * @return -
@@ -288,7 +279,7 @@
     }
 
     /**
-     * 鍒犻櫎鏂囦欢
+     * 鍒犻櫎銆愭枃浠躲��
      *
      * @param fullPath 鍏ㄨ矾寰�
      * @return -

--
Gitblit v1.8.0