public int GetLangIndex(eLanguageEnum eLanguage) { string str = eLanguage.ToString(); for (int i = 0; i < contryList.Count; i++) { if (contryList[i] == str) { return(i); } } return(-1); }
/// <summary> /// 当前语言是否有值,用于判断新增language Key /// </summary> /// <param name="eLanguage"></param> /// <returns></returns> public List <string> GetNewLanguageKey(eLanguageEnum eLanguage) { List <string> newKeyList = new List <string>(); int langIndex = GetLangIndex(eLanguage); int cnIndex = GetLangIndex(eLanguageEnum.Cn); int count = configLineDatas.Count; for (int i = 0; i < count; i++) { var myLineData = configLineDatas[i]; string langValue = myLineData.Values[langIndex]; if (string.IsNullOrEmpty(langValue)) { newKeyList.Add(myLineData.Values[cnIndex]); } } return(newKeyList); }
public void AddHead(string desc, eLanguageEnum[] eLangs = null) { if (eLangs == null) { eLangs = new eLanguageEnum[] { configLang }; } //表头 headLineData.Add(desc); //类型 string line = "string\t"; for (int i = 0; i < eLangs.Length; i++) { line += "string\t"; } line = line.TrimEnd('\t'); headLineData.Add(line); //描述 line = "中文\t"; for (int i = 0; i < eLangs.Length; i++) { line += chMapping[eLangs[i]] + "\t"; } line = line.TrimEnd('\t'); headLineData.Add(line); //字段 line = "Cn\t"; for (int i = 0; i < eLangs.Length; i++) { line += eLangs[i].ToString() + "\t"; } line = line.TrimEnd('\t'); headLineData.Add(line); }
private static List <string> GetCountryKeys(List <ConfigSplit> clinetCfgs, eLanguageEnum eLnag) { List <string> keys = new List <string>(); foreach (var clinetData in clinetCfgs) { var lines = clinetData.ConfigLineDatas; int langIndex = clinetData.GetLangIndex(eLnag); int cnIndex = clinetData.GetLangIndex(eLanguageEnum.Cn); foreach (var line in lines) { try { keys.Add(line.Values[cnIndex]); } catch (Exception ex) { throw new Exception($"语言超过数组界限:{clinetData.FileName},Key = {line.Key}+{ex.ToString()}"); } } } return(keys); }
/// <summary> /// 设置语言表 /// </summary> /// <param name="el"></param> public void SetLanguage(eLanguageEnum el) { configLang = el; }