多语言支持
策略名称与策略参数的描述均可采用中文|英文的格式书写,网页会自动识别并按语言显示。在其它使用位置,例如策略描述、使用说明等Markdown格式的文本中,可以使用[trans]中文|英文[/trans]或[trans]中文||英文[/trans]的格式,同样能够实现自动识别语言的效果。切换语言后,刷新网页即可生效。
在策略代码中,可写入字符串的函数同样支持语言切换,例如Log()函数、LogStatus()函数等。
javascript
function main() {
Log("[trans]日志|log[/trans]")
var table = {
type: "table",
title: "[trans]操作|option[/trans]",
cols: ["[trans]列1|col1[/trans]", "[trans]列2|col2[/trans]", "[trans]操作|option[/trans]"],
rows: [
["[trans]甲醇|MA[/trans]", "[trans]螺纹钢|rb[/trans]", {"type": "button", "cmd": "coverAll", "name": "平仓|cover", "description": "描述|description"}] // 注意:按钮中不用加[trans]标签
]
}
LogStatus("[trans]信息|message[/trans]", "\n`" + JSON.stringify(table) + "`")
throw "[trans]错误|error[/trans]"
}
python
import json
def main():
Log("[trans]日志|log[/trans]")
table = {
"type": "table",
"title": "[trans]操作|option[/trans]",
"cols": ["[trans]列1|col1[/trans]", "[trans]列2|col2[/trans]", "[trans]操作|option[/trans]"],
"rows": [
["[trans]甲醇|MA[/trans]", "[trans]螺纹钢|rb[/trans]", {"type": "button", "cmd": "coverAll", "name": "平仓|cover", "description": "描述|description"}]
]
}
LogStatus("[trans]信息|message[/trans]", "\n`" + json.dumps(table) + "`")
raise Exception("[trans]错误|error[/trans]")
rust
fn main() {
Log!("[trans]日志|log[/trans]");
let table = r#"{
"type": "table",
"title": "[trans]操作|option[/trans]",
"cols": ["[trans]列1|col1[/trans]", "[trans]列2|col2[/trans]", "[trans]操作|option[/trans]"],
"rows": [
["[trans]甲醇|MA[/trans]", "[trans]螺纹钢|rb[/trans]", {"type": "button", "cmd": "coverAll", "name": "平仓|cover", "description": "描述|description"}]
]
}"#;
LogStatus!("[trans]信息|message[/trans]", format!("\n`{}`", table));
Panic!("[trans]错误|error[/trans]");
}
c++
void main() {
Log("[trans]日志|log[/trans]");
json table = R"({
"type": "table",
"title": "[trans]操作|option[/trans]",
"cols": ["[trans]列1|col1[/trans]", "[trans]列2|col2[/trans]", "[trans]操作|option[/trans]"],
"rows": [
["[trans]甲醇|MA[/trans]", "[trans]螺纹钢|rb[/trans]", {"type": "button", "cmd": "coverAll", "name": "平仓|cover", "description": "描述|description"}]
]
})"_json;
LogStatus("[trans]信息|message[/trans]", "\n`" + table.dump() + "`");
Panic("[trans]错误|error[/trans]");
}