Skip to content

Commit

Permalink
json不再附带插入到htm里了,现在是js补丁版本
Browse files Browse the repository at this point in the history
  • Loading branch information
yunzlp committed Jun 6, 2024
1 parent effa59b commit 9854076
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
41 changes: 28 additions & 13 deletions GameMakerManualTranslatorBuild-Project/res/build.aardio
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ if setting.group{
group="def"
}


//生成导入依赖的html
importHtml=""
//依赖js
Expand All @@ -31,16 +30,26 @@ if setting.group{
console.log("import:",p)
}
},);
//依赖json和global json
importHtml+=//<script type="text/javascript" src="{json}"></script>
importHtml+=//<script type="text/javascript" src="{global}"></script>


//设置路径
path_manual = path+"GMS2-Robohelp-en/"
path_build = path+"build/"
path_language = path+"language/"+group+"/"



//读取模板与全局内容
var template=string.load(path+"/patch/template.htm")
var json_global=string.load(fsys.path.canonicalize(path_language+"/global.json"))

//将全局json储存
if !json_global json_global="{}"
json_global="json_global="+json_global
string.save(fsys.path.canonicalize(path+"/build/assets/import/language/global.js"),json_global)

//将内容注入文档
fsys.enum(path_manual,"*.htm",function(dirname,filename,fullpath,findData){
Expand All @@ -52,23 +61,30 @@ fsys.enum(path_manual,"*.htm",function(dirname,filename,fullpath,findData){
//文档原html
var html=string.load(fullpath)

var path_base=string.match(html,'src="(.*?)template/scripts')
var path_base=string.match(html,'src="(.*?)template/scripts')//基础路径

//获取json文本
var json=string.load(fsys.path.canonicalize(path_language+"/www/"+p+".json"))
if !json json="{}"
json="json="+json
//保存json文本
string.save(fsys.path.canonicalize(path+"/build/assets/import/language/"+p+".js"),json)

//替换原文档基础路径
var tmp_template=string.replace(template,"@{path}",path_base)

var tmp_importHtml=string.replace(importHtml,"@{path}",path_base+"assets\import")
var tmp_importHtml=string.replace(tmp_importHtml,"@{global}",path_base+"assets\import\language\global.js")
var tmp_importHtml=string.replace(tmp_importHtml,"@{json}",path_base+"assets\import\language\"+p+".js")

//替换基础路径
var tmp=string.replace(template,"@{path}",path_base)
//替换字典
var tmp=string.replace(tmp,"@{global}",json_global)
var tmp=string.replace(tmp,"@{json}",json)
//替换插入依赖js,css
var tmp=string.replace(
tmp,"@{importHtml}",
string.replace(importHtml,"@{path}",path_base+"assets\import")
var tmp_template=string.replace(
tmp_template,"@{importHtml}",
tmp_importHtml
)

//加入
html=string.replace(html,"@<head>","<head>"+'\r\n'+tmp)
html=string.replace(html,"@<head>","<head>"+'\r\n'+tmp_template)

console.log("patch:",p)

Expand All @@ -78,11 +94,10 @@ fsys.enum(path_manual,"*.htm",function(dirname,filename,fullpath,findData){
}
},);


//复制import
fsys.copy(
fsys.path.canonicalize(path+"/patch/import")
,fsys.path.canonicalize(path+"/build/assets/import")
,fsys.path.canonicalize(path+"/build/assets/")
)
console.log("copy:","!!!import!!!")

Expand Down
Binary file modified GameMakerManualTranslatorBuild.exe
Binary file not shown.
22 changes: 5 additions & 17 deletions patch/template.htm
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@
$(".header").append(html);
} else {
//否则就是页内
$(".topic-header").append(html);
$(".topic-header button")
.css("position", "relative")
.css("top", "44px");
//$(".topic-header").append(html);
//$(".topic-header button")
// .css("position", "relative")
// .css("top", "44px");
}
};

Expand All @@ -98,18 +98,6 @@
return after
};

let json_global
let json_file = {json}
let get_json_global = $.ajax({
url: "/global.json",
type: "GET",
dataType: "json",
async: false,
success: function (data) {
json_global = data
},
});

$(function () {
//添加按钮
addNoTranslationStateButton();
Expand All @@ -126,7 +114,7 @@
});

$(css2).each(function () {
setTranslator($(this), json_file);
setTranslator($(this), json);
});

$(css3).each(function () {
Expand Down

0 comments on commit 9854076

Please sign in to comment.