Copilot commented on code in PR #653:
URL: https://github.com/apache/fesod/pull/653#discussion_r2446590117


##########
fesod/src/main/java/org/apache/fesod/excel/util/ClassUtils.java:
##########
@@ -20,25 +20,7 @@
 package org.apache.fesod.excel.util;
 
 import cn.idev.excel.support.cglib.beans.BeanMap;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.concurrent.ConcurrentHashMap;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
+import lombok.*;

Review Comment:
   Replace wildcard import `lombok.*` with explicit imports. Wildcard imports 
reduce code clarity and can cause conflicts when new types are added to 
imported packages.
   ```suggestion
   // Lombok imports replaced with explicit imports below.
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/util/ClassUtils.java:
##########
@@ -50,16 +32,19 @@
 import org.apache.fesod.excel.converters.AutoConverter;
 import org.apache.fesod.excel.converters.Converter;
 import org.apache.fesod.excel.exception.ExcelCommonException;
+import org.apache.fesod.excel.il8n.ExcelMessageSource;
 import org.apache.fesod.excel.metadata.ConfigurationHolder;
 import org.apache.fesod.excel.metadata.FieldCache;
 import org.apache.fesod.excel.metadata.FieldWrapper;
-import org.apache.fesod.excel.metadata.property.DateTimeFormatProperty;
-import org.apache.fesod.excel.metadata.property.ExcelContentProperty;
-import org.apache.fesod.excel.metadata.property.FontProperty;
-import org.apache.fesod.excel.metadata.property.NumberFormatProperty;
-import org.apache.fesod.excel.metadata.property.StyleProperty;
+import org.apache.fesod.excel.metadata.GlobalConfiguration;
+import org.apache.fesod.excel.metadata.property.*;
 import org.apache.fesod.excel.write.metadata.holder.WriteHolder;

Review Comment:
   Replace wildcard import with explicit imports to improve code clarity and 
prevent potential naming conflicts.
   ```suggestion
   import org.apache.fesod.excel.metadata.property.ExcelContentProperty;
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/il8n/ExcelMessageSource.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fesod.excel.il8n;

Review Comment:
   Package name 'il8n' should be 'i18n' (internationalization abbreviation: i + 
18 letters + n).
   ```suggestion
   package org.apache.fesod.excel.i18n;
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/util/ClassUtils.java:
##########
@@ -50,16 +32,19 @@
 import org.apache.fesod.excel.converters.AutoConverter;
 import org.apache.fesod.excel.converters.Converter;
 import org.apache.fesod.excel.exception.ExcelCommonException;
+import org.apache.fesod.excel.il8n.ExcelMessageSource;
 import org.apache.fesod.excel.metadata.ConfigurationHolder;
 import org.apache.fesod.excel.metadata.FieldCache;
 import org.apache.fesod.excel.metadata.FieldWrapper;
-import org.apache.fesod.excel.metadata.property.DateTimeFormatProperty;
-import org.apache.fesod.excel.metadata.property.ExcelContentProperty;
-import org.apache.fesod.excel.metadata.property.FontProperty;
-import org.apache.fesod.excel.metadata.property.NumberFormatProperty;
-import org.apache.fesod.excel.metadata.property.StyleProperty;
+import org.apache.fesod.excel.metadata.GlobalConfiguration;
+import org.apache.fesod.excel.metadata.property.*;
 import org.apache.fesod.excel.write.metadata.holder.WriteHolder;
 
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.*;

Review Comment:
   Replace wildcard import with explicit imports to clearly document which Java 
utility classes are being used.
   ```suggestion
   import java.util.List;
   import java.util.Map;
   import java.util.Set;
   import java.util.HashMap;
   import java.util.HashSet;
   import java.util.LinkedHashMap;
   import java.util.LinkedHashSet;
   import java.util.Objects;
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/metadata/BasicParameter.java:
##########
@@ -26,6 +26,7 @@
 import lombok.Setter;
 import org.apache.fesod.excel.converters.Converter;
 import org.apache.fesod.excel.enums.CacheLocationEnum;
+import org.apache.fesod.excel.il8n.ExcelMessageSource;

Review Comment:
   Package name 'il8n' should be 'i18n' (internationalization abbreviation: i + 
18 letters + n).
   ```suggestion
   import org.apache.fesod.excel.i18n.ExcelMessageSource;
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/read/metadata/ReadWorkbook.java:
##########
@@ -35,6 +35,7 @@
 import org.apache.fesod.excel.enums.CellExtraTypeEnum;
 import org.apache.fesod.excel.enums.ReadDefaultReturnEnum;
 import org.apache.fesod.excel.event.AnalysisEventListener;
+import org.apache.fesod.excel.il8n.ExcelMessageSource;

Review Comment:
   Package name 'il8n' should be 'i18n' (internationalization abbreviation: i + 
18 letters + n).
   ```suggestion
   import org.apache.fesod.excel.i18n.ExcelMessageSource;
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/metadata/AbstractParameterBuilder.java:
##########
@@ -24,6 +24,7 @@
 import java.util.Objects;
 import org.apache.fesod.excel.converters.Converter;
 import org.apache.fesod.excel.enums.CacheLocationEnum;
+import org.apache.fesod.excel.il8n.ExcelMessageSource;

Review Comment:
   Package name 'il8n' should be 'i18n' (internationalization abbreviation: i + 
18 letters + n).
   ```suggestion
   import org.apache.fesod.excel.i18n.ExcelMessageSource;
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/util/ClassUtils.java:
##########
@@ -585,4 +571,16 @@ public static void removeThreadLocalCache() {
         CLASS_CONTENT_THREAD_LOCAL.remove();
         CONTENT_THREAD_LOCAL.remove();
     }
+
+    private static String[] getIl8nHeads(String[] heads, GlobalConfiguration 
globalConfiguration) {
+        ExcelMessageSource excelMessageSource = 
globalConfiguration.getMessageSource();
+        if (Objects.isNull(heads) || heads.length == 0 || 
Objects.isNull(excelMessageSource)) {
+            return heads;
+        }
+        String[] il8nHeads = new String[heads.length];
+        for (int i = 0; i < heads.length; i++) {
+            il8nHeads[i] = excelMessageSource.resolveCode(heads[i], 
globalConfiguration.getLocale());
+        }
+        return il8nHeads;

Review Comment:
   Variable name 'il8nHeads' should be 'i18nHeads' (internationalization 
abbreviation: i + 18 letters + n).
   ```suggestion
           String[] i18nHeads = new String[heads.length];
           for (int i = 0; i < heads.length; i++) {
               i18nHeads[i] = excelMessageSource.resolveCode(heads[i], 
globalConfiguration.getLocale());
           }
           return i18nHeads;
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/read/metadata/holder/ReadWorkbookHolder.java:
##########
@@ -214,6 +221,7 @@ public ReadWorkbookHolder(ReadWorkbook readWorkbook) {
         }
         this.hasReadSheet = new HashSet<Integer>();
         this.password = readWorkbook.getPassword();
+        this.messageSource=readWorkbook.getMessageSource();

Review Comment:
   Add space around the assignment operator for consistency with the project's 
code style: `this.messageSource = readWorkbook.getMessageSource();`
   ```suggestion
           this.messageSource = readWorkbook.getMessageSource();
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/util/ClassUtils.java:
##########
@@ -585,4 +571,16 @@ public static void removeThreadLocalCache() {
         CLASS_CONTENT_THREAD_LOCAL.remove();
         CONTENT_THREAD_LOCAL.remove();
     }
+
+    private static String[] getIl8nHeads(String[] heads, GlobalConfiguration 
globalConfiguration) {
+        ExcelMessageSource excelMessageSource = 
globalConfiguration.getMessageSource();
+        if (Objects.isNull(heads) || heads.length == 0 || 
Objects.isNull(excelMessageSource)) {
+            return heads;
+        }
+        String[] il8nHeads = new String[heads.length];
+        for (int i = 0; i < heads.length; i++) {
+            il8nHeads[i] = excelMessageSource.resolveCode(heads[i], 
globalConfiguration.getLocale());
+        }
+        return il8nHeads;

Review Comment:
   Variable name 'il8nHeads' should be 'i18nHeads' (internationalization 
abbreviation: i + 18 letters + n).
   ```suggestion
           String[] i18nHeads = new String[heads.length];
           for (int i = 0; i < heads.length; i++) {
               i18nHeads[i] = excelMessageSource.resolveCode(heads[i], 
globalConfiguration.getLocale());
           }
           return i18nHeads;
   ```



##########
fesod-examples/src/test/java/org/apache/fesod/excel/demo/write/WriteTest.java:
##########
@@ -58,16 +47,16 @@
 import org.apache.fesod.excel.write.metadata.style.WriteFont;
 import org.apache.fesod.excel.write.style.HorizontalCellStyleStrategy;
 import 
org.apache.fesod.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.FillPatternType;
-import org.apache.poi.ss.usermodel.IndexedColors;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.*;

Review Comment:
   Replace wildcard import with explicit imports to clearly document which POI 
classes are being used.
   ```suggestion
   import org.apache.poi.ss.usermodel.Cell;
   import org.apache.poi.ss.usermodel.CellStyle;
   import org.apache.poi.ss.usermodel.CreationHelper;
   import org.apache.poi.ss.usermodel.DataFormat;
   import org.apache.poi.ss.usermodel.FillPatternType;
   import org.apache.poi.ss.usermodel.Font;
   import org.apache.poi.ss.usermodel.HorizontalAlignment;
   import org.apache.poi.ss.usermodel.IndexedColors;
   import org.apache.poi.ss.usermodel.Row;
   import org.apache.poi.ss.usermodel.Sheet;
   import org.apache.poi.ss.usermodel.Workbook;
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/metadata/GlobalConfiguration.java:
##########
@@ -24,6 +24,7 @@
 import lombok.Getter;
 import lombok.Setter;
 import org.apache.fesod.excel.enums.CacheLocationEnum;
+import org.apache.fesod.excel.il8n.ExcelMessageSource;

Review Comment:
   Package name 'il8n' should be 'i18n' (internationalization abbreviation: i + 
18 letters + n).
   ```suggestion
   import org.apache.fesod.excel.i18n.ExcelMessageSource;
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/util/ClassUtils.java:
##########
@@ -50,16 +32,19 @@
 import org.apache.fesod.excel.converters.AutoConverter;
 import org.apache.fesod.excel.converters.Converter;
 import org.apache.fesod.excel.exception.ExcelCommonException;
+import org.apache.fesod.excel.il8n.ExcelMessageSource;

Review Comment:
   Package name 'il8n' should be 'i18n' (internationalization abbreviation: i + 
18 letters + n).
   ```suggestion
   import org.apache.fesod.excel.i18n.ExcelMessageSource;
   ```



##########
fesod-examples/src/test/java/org/apache/fesod/excel/demo/write/WriteTest.java:
##########
@@ -35,13 +27,10 @@
 import org.apache.fesod.excel.annotation.write.style.ColumnWidth;
 import org.apache.fesod.excel.annotation.write.style.ContentRowHeight;
 import org.apache.fesod.excel.annotation.write.style.HeadRowHeight;
+import org.apache.fesod.excel.demo.read.Il8nZhHeadDemoData;
 import org.apache.fesod.excel.enums.CellDataTypeEnum;
-import org.apache.fesod.excel.metadata.data.CommentData;
-import org.apache.fesod.excel.metadata.data.FormulaData;
-import org.apache.fesod.excel.metadata.data.HyperlinkData;
-import org.apache.fesod.excel.metadata.data.ImageData;
-import org.apache.fesod.excel.metadata.data.RichTextStringData;
-import org.apache.fesod.excel.metadata.data.WriteCellData;
+import org.apache.fesod.excel.demo.read.AutoMessageSource;
+import org.apache.fesod.excel.metadata.data.*;

Review Comment:
   Replace wildcard import with explicit imports to improve code clarity and 
prevent potential naming conflicts.
   ```suggestion
   import org.apache.fesod.excel.metadata.data.WriteCellData;
   import org.apache.fesod.excel.metadata.data.WriteRowData;
   import org.apache.fesod.excel.metadata.data.WriteSheetData;
   import org.apache.fesod.excel.metadata.data.WriteTableData;
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/read/metadata/holder/ReadWorkbookHolder.java:
##########
@@ -39,6 +39,7 @@
 import org.apache.fesod.excel.enums.ReadDefaultReturnEnum;
 import org.apache.fesod.excel.event.AnalysisEventListener;
 import org.apache.fesod.excel.exception.ExcelAnalysisException;
+import org.apache.fesod.excel.il8n.ExcelMessageSource;

Review Comment:
   Package name 'il8n' should be 'i18n' (internationalization abbreviation: i + 
18 letters + n).
   ```suggestion
   import org.apache.fesod.excel.i18n.ExcelMessageSource;
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/util/ClassUtils.java:
##########
@@ -585,4 +571,16 @@ public static void removeThreadLocalCache() {
         CLASS_CONTENT_THREAD_LOCAL.remove();
         CONTENT_THREAD_LOCAL.remove();
     }
+
+    private static String[] getIl8nHeads(String[] heads, GlobalConfiguration 
globalConfiguration) {
+        ExcelMessageSource excelMessageSource = 
globalConfiguration.getMessageSource();
+        if (Objects.isNull(heads) || heads.length == 0 || 
Objects.isNull(excelMessageSource)) {
+            return heads;
+        }
+        String[] il8nHeads = new String[heads.length];
+        for (int i = 0; i < heads.length; i++) {
+            il8nHeads[i] = excelMessageSource.resolveCode(heads[i], 
globalConfiguration.getLocale());
+        }
+        return il8nHeads;

Review Comment:
   Variable name 'il8nHeads' should be 'i18nHeads' (internationalization 
abbreviation: i + 18 letters + n).
   ```suggestion
           String[] i18nHeads = new String[heads.length];
           for (int i = 0; i < heads.length; i++) {
               i18nHeads[i] = excelMessageSource.resolveCode(heads[i], 
globalConfiguration.getLocale());
           }
           return i18nHeads;
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/util/ClassUtils.java:
##########
@@ -585,4 +571,16 @@ public static void removeThreadLocalCache() {
         CLASS_CONTENT_THREAD_LOCAL.remove();
         CONTENT_THREAD_LOCAL.remove();
     }
+
+    private static String[] getIl8nHeads(String[] heads, GlobalConfiguration 
globalConfiguration) {
+        ExcelMessageSource excelMessageSource = 
globalConfiguration.getMessageSource();
+        if (Objects.isNull(heads) || heads.length == 0 || 
Objects.isNull(excelMessageSource)) {
+            return heads;
+        }
+        String[] il8nHeads = new String[heads.length];
+        for (int i = 0; i < heads.length; i++) {
+            il8nHeads[i] = excelMessageSource.resolveCode(heads[i], 
globalConfiguration.getLocale());
+        }
+        return il8nHeads;

Review Comment:
   Method name 'getIl8nHeads' should be 'getI18nHeads' (internationalization 
abbreviation: i + 18 letters + n).
   ```suggestion
       private static String[] getI18nHeads(String[] heads, GlobalConfiguration 
globalConfiguration) {
           ExcelMessageSource excelMessageSource = 
globalConfiguration.getMessageSource();
           if (Objects.isNull(heads) || heads.length == 0 || 
Objects.isNull(excelMessageSource)) {
               return heads;
           }
           String[] i18nHeads = new String[heads.length];
           for (int i = 0; i < heads.length; i++) {
               i18nHeads[i] = excelMessageSource.resolveCode(heads[i], 
globalConfiguration.getLocale());
           }
           return i18nHeads;
   ```



##########
fesod-examples/src/test/java/org/apache/fesod/excel/demo/write/WriteTest.java:
##########
@@ -779,7 +768,31 @@ public void afterSheetDispose(SheetWriteHandlerContext 
context) {
                 .doWrite(this::data);
         System.out.println(fileName);
     }
+    @Test
+    public void sheetIl8nHeadWriteTest() {
+        List<Locale> locales=new ArrayList<>();

Review Comment:
   Add space around the assignment operator for consistency with Java code 
conventions: `List<Locale> locales = new ArrayList<>();`
   ```suggestion
           List<Locale> locales = new ArrayList<>();
   ```



##########
fesod-examples/src/test/java/org/apache/fesod/excel/demo/write/WriteTest.java:
##########
@@ -58,16 +47,16 @@
 import org.apache.fesod.excel.write.metadata.style.WriteFont;
 import org.apache.fesod.excel.write.style.HorizontalCellStyleStrategy;
 import 
org.apache.fesod.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.FillPatternType;
-import org.apache.poi.ss.usermodel.IndexedColors;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.streaming.SXSSFSheet;
 import org.junit.jupiter.api.Test;
 
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.*;

Review Comment:
   Replace wildcard import with explicit imports to clearly document which Java 
utility classes are being used.
   ```suggestion
   import java.util.ArrayList;
   import java.util.Date;
   import java.util.HashMap;
   import java.util.List;
   import java.util.Map;
   ```



##########
fesod/src/main/java/org/apache/fesod/excel/metadata/GlobalConfiguration.java:
##########
@@ -70,13 +71,17 @@ public class GlobalConfiguration {
      * default is false
      */
     private Boolean autoStrip;
-
+    /**
+     * Message source
+     */
+    private ExcelMessageSource messageSource;
     public GlobalConfiguration() {
         this.autoTrim = Boolean.TRUE;
         this.autoStrip = Boolean.FALSE;
         this.use1904windowing = Boolean.FALSE;
         this.locale = Locale.getDefault();
         this.useScientificFormat = Boolean.FALSE;
         this.filedCacheLocation = CacheLocationEnum.THREAD_LOCAL;
+        this.messageSource=null;

Review Comment:
   Add space around the assignment operator for consistency with the project's 
code style: `this.messageSource = null;`
   ```suggestion
           this.messageSource = null;
   ```



##########
fesod-examples/src/test/java/org/apache/fesod/excel/demo/read/AutoMessageSource.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fesod.excel.demo.read;
+
+import org.apache.fesod.excel.il8n.ExcelMessageSource;

Review Comment:
   Package name 'il8n' should be 'i18n' (internationalization abbreviation: i + 
18 letters + n).
   ```suggestion
   import org.apache.fesod.excel.i18n.ExcelMessageSource;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to