internal void AddAutoComment(string s) { if (AutoComments == null) { AutoComments = new List <string>(); } if (AutoComments.Contains(s)) { return; } if (s.StartsWith("/") || s.StartsWith("(String used ")) { AutoComments.Add(s); } else { // Keep these comments in order at the beginning. var idx = AutoComments.FindIndex(0, IsPathComment); if (idx < 0) { idx = AutoComments.Count; } AutoComments.Insert(idx, s); } }
/// <summary> /// Write the contents of this object to the given TextWriter. /// </summary> internal void Write(TextWriter swOut) { if (UserComments != null) { if (IsObsolete) { foreach (var comment in UserComments) { swOut.WriteLine("#" + comment); } return; } foreach (var comment in UserComments) { WriteComment(comment, ' ', swOut); } } if (References != null) { foreach (var reference in References) { WriteComment(reference, ':', swOut); } } if (AutoComments != null) { // Sort the set of path comments generated from the XML configuration files var idx = AutoComments.FindIndex(0, IsPathComment); if (idx >= 0) { var cPath = AutoComments.Count - idx; var lastComment = AutoComments[AutoComments.Count - 1]; if (_mCDup == 1 && lastComment.StartsWith("(String used ")) { --cPath; } AutoComments.Sort(idx, cPath, null); } foreach (var comment in AutoComments) { WriteComment(comment, '.', swOut); } } if (_mCDup > 1) { WriteComment($"(String used {_mCDup} times.)", '.', swOut); } if (Flags != null) { foreach (var flag in Flags) { WriteComment(flag, ',', swOut); } } WriteMsgBundle("msgid", MsgId, swOut); WriteMsgBundle("msgstr", MsgStr, swOut); swOut.WriteLine(""); }