Skip to content

Commit

Permalink
修复多语言文档链接收集器空定位bug
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperIceCN committed Feb 5, 2023
1 parent a623669 commit 6c43678
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ public void render(@NotNull Renderer renderer, @NotNull Workflow workflow, @NotN
var linkObj = new JsonObject();
for (var lang : languages) {
var langStr = lang.getAsString();
var link = regexp.matcher(page.getOutputPath().toString()).replaceAll(langStr);
if (link != null) {
var tmp = Path.of(link);
if (Files.exists(Shared.OUTPUT_DIR.get().resolve(Shared.WORKING_DIR.get().relativize(tmp)))) {
linkObj.addProperty(langStr, page.getOutputPath().getParent().relativize(tmp).toString().replace('\\', '/'));
var outputLink = regexp.matcher(page.getOutputPath().toString()).replaceAll(langStr);
var sourceLink = regexp.matcher(page.getPath().toString()).replaceAll(langStr);
if (outputLink != null) {
var outputPath = Path.of(outputLink);
var sourcePath = Path.of(sourceLink);
if (Files.exists(sourcePath)) {
linkObj.addProperty(langStr, page.getOutputPath().getParent().relativize(outputPath).toString().replace('\\', '/'));
} else {
linkObj.add(langStr, JsonNull.INSTANCE);
Logger.of(MultiLangLinkCollector.class).info("no-language-doc-found", langStr, page.getPath());
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion FrostRender/src/main/resources/fr-language/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
"template-not-specify": "The file {} has not applied a template. Catalogue wont be generated.",
"failed-to-parse-image": "Unable to parse image {}, reason: {}",
"unsupported-image-format": "The image format used by {} is not supported temporarily.",
"no-language-doc-found": "{} version of doc {} cannot be found.",

"config-file": "config file",
"template-file": "template file",
"content-file": "content file"
"content-file": "content file",

"zh-cn": "Simplified Chinese",
"en-us": "English"
}
6 changes: 5 additions & 1 deletion FrostRender/src/main/resources/fr-language/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@
"template-not-specify": "文件 {} 尚未应用模板,无法注入目录。",
"failed-to-parse-image": "无法解析图像 {},原因:{}",
"unsupported-image-format": "暂不支持 {} 所用的图像格式。",
"no-language-doc-found": "文档 {1} 的 {} 版本没有找到。",

"config-file": "配置文件",
"template-file": "模板文件",
"content-file": "内容文件"
"content-file": "内容文件",

"zh-cn": "简体中文",
"en-us": "英语"
}

0 comments on commit 6c43678

Please sign in to comment.