public SEntry(string file, string[] fields, TranslateValuePaser parser, string dir) { luaFile = file; ignoredFields = fields; valueParser = parser; luaDir = dir; }
public static bool ParseLuaFile(string fileName, string[] ignoreFields, out List <Template.STranslateValue> translateValues, TranslateValuePaser parser) { translateValues = new List <Template.STranslateValue>(); string[] lines = null; try { lines = File.ReadAllLines(fileName); } catch (Exception) { return(false); } //string fname = System.IO.Path.GetFileName(fileName); //string shortFileName = System.IO.Path.GetFileNameWithoutExtension(fileName); int nLine = 0; bool bComment = false; foreach (string line in lines) { ++nLine; if (line.IndexOf("--[[") >= 0) { bComment = true; } if (line.IndexOf("]]") >= 0) { bComment = false; } if (bComment) { continue; } string strLine = line; int idx = line.IndexOf("--"); if (idx > 0) { strLine = line.Substring(0, idx); } //解析要翻译的 List <STranslateValue> transList = new List <STranslateValue>(); parser(fileName, ignoreFields, strLine, transList); foreach (var trans in transList) { if (!string.IsNullOrEmpty(trans._val)) { if (!translateValues.Contains(trans)) { translateValues.Add(trans); } } } } return(true); }