国际化

This commit is contained in:
lzy
2023-09-12 16:27:16 +08:00
parent f1ecfbed87
commit d4906b285d
5 changed files with 21 additions and 5 deletions

View File

@ -44,8 +44,20 @@ public final class PatternConstant {
public static final String HTML_TITLE = "<h1 id=\"{0}\">{0}</h1>";
public static final String HTML_CATALOG = "<h2 id=\"{0}\">{1}</h2>";
public static final String HTML_INDEX_ITEM = "<a href=\"#{0}\" title=\"{0}\">{1}</a>";
public static String HTML_TABLE_HEADER = "<tr><th>序号</th><th>字段名</th><th>类型</th><th>长度</th><th>是否为空</th><th>默认值</th><th>小数位</th><th>注释</th></tr>";
public static String HTML_TABLE_HEADER = "<tr><th>" + I18nUtils.getMessage("main.fieldNo")
+ "</th><th>" + I18nUtils.getMessage("main.fieldName")
+ "</th><th>"+ I18nUtils.getMessage("main.fieldType")
+ "</th><th>" + I18nUtils.getMessage("main.fieldLength")
+ "</th><th>" + I18nUtils.getMessage("main.fieldIfEmpty")
+ "</th><th>" + I18nUtils.getMessage("main.fieldDefault")
+ "</th><th>" + I18nUtils.getMessage("main.fieldDecimalPlaces")
+ "</th><th>" + I18nUtils.getMessage("main.fieldNote")
+ "</th></tr>";
public static String HTML_TABLE_BODY = "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>";
public static String HTML_INDEX_TABLE_HEADER = "<tr><th>名称</th><th>字段</th><th>DDL</th><th>注释</th></tr>";
public static String HTML_INDEX_TABLE_HEADER = "<tr><th>" + I18nUtils.getMessage("main.indexName")
+ "</th><th>" + I18nUtils.getMessage("main.indexFieldName")
+ "</th><th>" + I18nUtils.getMessage("main.indexType")
+ "</th><th>" + I18nUtils.getMessage("main.indexMethod")
+ "</th><th>" + I18nUtils.getMessage("main.indexNote") + "</th></tr>";
public static String HTML_INDEX_TABLE_BODY = "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>";
}

View File

@ -3,6 +3,7 @@ package ai.chat2db.server.web.api.controller.rdb.doc.export;
import ai.chat2db.server.domain.api.enums.ExportFileSuffix;
import ai.chat2db.server.domain.api.enums.ExportTypeEnum;
import ai.chat2db.server.domain.api.model.TableParameter;
import ai.chat2db.server.tools.common.util.I18nUtils;
import ai.chat2db.server.web.api.controller.rdb.doc.DatabaseExportService;
import ai.chat2db.server.web.api.controller.rdb.doc.adaptive.CustomCellWriteHeightConfig;
import ai.chat2db.server.web.api.controller.rdb.doc.adaptive.CustomCellWriteWidthConfig;
@ -47,7 +48,7 @@ public class ExportExcelService extends DatabaseExportService {
.registerWriteHandler(new CustomCellWriteHeightConfig())
.registerWriteHandler(new CustomCellWriteWidthConfig())
.registerWriteHandler(new MyMergeExcel())
.sheet("表结构")
.sheet(I18nUtils.getMessage("main.sheetName"))
.doWrite(export);
}

View File

@ -4,6 +4,7 @@ import ai.chat2db.server.domain.api.enums.ExportFileSuffix;
import ai.chat2db.server.domain.api.enums.ExportTypeEnum;
import ai.chat2db.server.domain.api.model.IndexInfo;
import ai.chat2db.server.domain.api.model.TableParameter;
import ai.chat2db.server.tools.common.util.I18nUtils;
import ai.chat2db.server.web.api.controller.rdb.doc.DatabaseExportService;
import ai.chat2db.server.web.api.controller.rdb.doc.conf.ExportOptions;
import ai.chat2db.server.web.api.controller.rdb.doc.constant.PatternConstant;
@ -41,7 +42,7 @@ public class ExportMarkdownService extends DatabaseExportService {
for (Map.Entry<String, List<Map.Entry<String, List<TableParameter>>>> myMap : allMap.entrySet()) {
//数据库名
String database = myMap.getKey();
String title = String.format(PatternConstant.TITLE, "数据库:" + database);
String title = String.format(PatternConstant.TITLE, I18nUtils.getMessage("main.databaseText") + database);
fileWriter.write(title);
writeLineSeparator(fileWriter, 2);
for (Map.Entry<String, List<TableParameter>> parameterMap : myMap.getValue()) {