StrokesPlus.net教程及脚本持续更新

切换语言

//Get current culture
var culture = sp.GetCurrentCulture();

//Create input box to prompt selecting a language based on available files
var inputBoxInfo = new InputBoxInfo();
inputBoxInfo.Title = "Change Culture";
inputBoxInfo.Message = "Select an available language below. These are the languages available in the StrokesPlus.net\\Resources folder.";
var files = clr.System.IO.Directory.GetFiles(clr.System.IO.Path.GetDirectoryName(clr.System.Reflection.Assembly.GetEntryAssembly().Location) + "\\Resources");
for (i=0;i<files.Length;i++)
{
    var fi = new FileInfo(files[i]);
    var file = fi.Name;
    if(file.indexOf("Icons") !== 0) { //Ignore the Icons.resources file
        file = file.replace(/resources/ig , "").replace(/\./ig,"");
        if(file == "") file = "en-US"; //Since the culture name isn't in the English file name, add it manually
        inputBoxInfo.Items.Add(CultureInfo.GetCultureInfo(file).DisplayName + " [" + file + "]");
    }
}
inputBoxInfo.Sort = true;
//Show the input box
var res = sp.InputBox(inputBoxInfo);

//If a selection was made, change the culture
if(res != null) {
    var n = /\[(.*)\]/i; //Define the regular expression for matching the culture string
    var match = n.exec(res); //Get the text between the brackets, e.g. [en-US]
    sp.ChangeCulture(match[1]);
}