UI Text Localization
Text in the strategy interface can be written in both Chinese and English; the web page shows the one matching the current language (refresh the page after switching languages):
- Strategy name and descriptions of strategy parameters: write
Chinese|English. - Strategy description, usage instructions and other
Markdowntext: write[trans]Chinese|English[/trans]or[trans]Chinese||English[/trans]. - Functions in the strategy code that output strings, such as
Log()andLogStatus(): the same asMarkdowntext; texts of status bar buttons are writtenChinese|Englishdirectly, without the[trans]tag.
javascript
function main() {
Log("[trans]日志|log[/trans]")
// no [trans] tag inside buttons
var btn = {"type": "button", "cmd": "coverAll", "name": "平仓|cover",
"description": "描述|description"}
var table = {
type: "table",
title: "[trans]操作|option[/trans]",
cols: ["[trans]列1|col1[/trans]", "[trans]列2|col2[/trans]", "[trans]操作|option[/trans]"],
rows: [
["[trans]比特币|BTC[/trans]", "[trans]以太坊|ETH[/trans]", btn]
]
}
LogStatus("[trans]信息|message[/trans]", "\n`" + JSON.stringify(table) + "`")
throw "[trans]错误|error[/trans]"
}
python
import json
def main():
Log("[trans]日志|log[/trans]")
btn = {"type": "button", "cmd": "coverAll", "name": "平仓|cover",
"description": "描述|description"}
table = {
"type": "table",
"title": "[trans]操作|option[/trans]",
"cols": ["[trans]列1|col1[/trans]", "[trans]列2|col2[/trans]", "[trans]操作|option[/trans]"],
"rows": [
["[trans]比特币|BTC[/trans]", "[trans]以太坊|ETH[/trans]", btn]
]
}
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]比特币|BTC[/trans]", "[trans]以太坊|ETH[/trans]",
{"type": "button", "cmd": "coverAll", "name": "平仓|cover",
"description": "描述|description"}]
]
}"#;
LogStatus!("[trans]信息|message[/trans]", format!("\n`{}`", table));
Panic!("[trans]错误|error[/trans]");
}