/// <summary> /// 中译英 /// </summary> public void ToEnglish() { if (Entity.IsFreeze) { return; } foreach (var col in Entity.Properties) { if (string.IsNullOrEmpty(col.Caption) || (!string.IsNullOrWhiteSpace(col.Name) && col.Name[0] < 256)) { continue; } col.Name = BaiduFanYi.FanYiWord(col.Caption); } Entity.IsModify = true; }
/// <summary> /// 自动修复 /// </summary> public void EnumToEnglish() { var en = Context.SelectConfig as EnumConfig; if (en == null) { return; } foreach (var item in en.Items) { if (string.IsNullOrWhiteSpace(item.Name) || item.Name[0] < 256) { continue; } item.Name = BaiduFanYi.FanYiWord(item.Name); } en.IsModify = true; }
public static void CheckEnum(PropertyConfig column) { var line = column.Description?.Trim(CoderBase.NoneLanguageChar) ?? ""; StringBuilder sb = new StringBuilder(); StringBuilder caption = new StringBuilder(); bool preIsNumber = false; bool startEnum = false; EnumConfig ec = new EnumConfig { Name = column.Parent.Name.ToUWord() + column.Name.ToUWord(), Description = column.Description, Caption = column.Caption, Items = new ConfigCollection <EnumItem>() }; EnumItem ei = new EnumItem(); foreach (var c in line) { if (c >= '0' && c <= '9') { if (!preIsNumber) { if (!startEnum) { caption.Append(sb); } else if (sb.Length > 0) { new List <string>().Add(sb.ToString()); ei.Caption = sb.ToString(); } sb = new StringBuilder(); startEnum = true; } preIsNumber = true; } else { if (preIsNumber) { if (sb.Length > 0) { ei = new EnumItem { Value = sb.ToString() }; ec.Items.Add(ei); sb = new StringBuilder(); } } preIsNumber = false; } sb.Append(c); } if (!startEnum) { return; } if (sb.Length > 0) { if (preIsNumber) { ec.Items.Add(new EnumItem { Value = sb.ToString() }); } else { ei.Caption = sb.ToString(); } } if (ec.Items.Count > 0) { ec.LinkField = column.Key; column.EnumConfig = ec; column.CustomType = ec.Name; column.Description = line; foreach (var item in ec.Items) { if (string.IsNullOrEmpty(item.Caption)) { column.EnumConfig = null; column.CustomType = null; return; } var arr = item.Caption.Trim(CoderBase.NoneNameChar).Split(CoderBase.NoneNameChar, StringSplitOptions.RemoveEmptyEntries); if (arr.Length == 0) { column.EnumConfig = null; column.CustomType = null; return; } item.Caption = arr[0]; item.Name = BaiduFanYi.FanYiWord(item.Caption.MulitReplace2("", "表示")); } if (caption.Length > 0) { column.Caption = caption.ToString(); } } else { column.EnumConfig = null; column.CustomType = null; } }