SV.T(text)
SV.T(...)
is a handy function for translating a
string based on the host's current language settings. The
translation is based on a dictionary provided by the script author.
If an out-of-dictionary string is encountered, it fallbacks to the
host's translation file, and if a translation is still not found,
the original string will be returned.
Embed a translation dictionary in the script
The script author may implement
getTranslations(langCode)
callback to provide a
script-specific translation dictionary. This function is executed
when Synthesizer V Studio loads the script and it takes a
string
argument for the language code. It returns an
array of pairs (array) of string
.
For example,
(JavaScript)
function getTranslations(langCode) {
if(langCode == "ja-jp") {
return [
["Please enter a number here:", "数字を入力してください:"],
["Please enter some text here:", "テキストを入力してください:"]
];
} else
if(langCode == "zh-cn") {
return [
["Please enter a number here:", "请输入一个数字:"],
["Please enter some text here:", "请输入一段文本:"]
];
}
return [];
}
function main() {
SV.showInputBox("My Script", SV.T("Please enter a number here:"), "");
SV.showInputBox("My Script", SV.T("Please enter some text here:"), "");
SV.finish();
}
(Lua)
function getTranslations(langCode)
if langCode == "ja-jp" then
return {
{"Please enter a number here:", "数字を入力してください:"},
{"Please enter some text here:", "テキストを入力してください:"}
}
elseif langCode == "zh-cn" then
return {
{"Please enter a number here:", "请输入一个数字:"},
{"Please enter some text here:", "请输入一段文本:"}
}
end
return {}
end
function main()
SV:showInputBox("My Script", SV:T("Please enter a number here:"), "")
SV:showInputBox("My Script", SV:T("Please enter some text here:"), "")
SV:finish()
end