예제 #1
0
        internal static CommentLine CreateNew(Entry entry, CommentLine.Kinds kind, int?index, bool isContinuation, IO.TextLine addRelativeTo, bool addRelativeToBefore, string text)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }
            if (addRelativeTo == null)
            {
                throw new ArgumentNullException("addRelativeTo");
            }
            int insertAt = entry.File.TextFile.Lines.IndexOf(addRelativeTo);

            if (insertAt < 0)
            {
                throw new ArgumentOutOfRangeException("addRelativeTo");
            }
            if (!addRelativeToBefore)
            {
                insertAt++;
            }
            IO.TextLine textLine = new IO.TextLine(BuildTextFileData(kind, index, isContinuation, text));
            entry.File.TextFile.Lines.Insert(insertAt, textLine);
            CommentLine result;

            if (index.HasValue)
            {
                result = new IndexedCommentLine(entry.File, textLine, isContinuation, kind, text, index.Value);
            }
            else
            {
                result = new CommentLine(entry.File, textLine, isContinuation, kind, text);
            }
            entry.LineAdded(result);
            return(result);
        }
예제 #2
0
 internal IndexedCommentLine(POFile file, IO.TextLine source, bool isContinuation, CommentLine.Kinds kind, string text, int index)
     : base(file, source, isContinuation, kind, text)
 {
     this._index = index;
 }
예제 #3
0
        private static string BuildTextFileData(CommentLine.Kinds kind, int?index, bool isContinuation, string text)
        {
            if (isContinuation)
            {
                switch (kind)
                {
                case CommentLine.Kinds.PreviousUntraslated_Context:
                case CommentLine.Kinds.PreviousUntraslated_ID:
                case CommentLine.Kinds.PreviousUntraslated_IDPlural:
                    return(string.Format("#| \"{0}\"", text));

                case CommentLine.Kinds.Removed_Context:
                case CommentLine.Kinds.Removed_ID:
                case CommentLine.Kinds.Removed_IDPlural:
                case CommentLine.Kinds.Removed_Translated:
                case CommentLine.Kinds.Removed_TranslatedIndexed:
                    return(string.Format("#~ \"{0}\"", text));

                default:
                    throw new NotImplementedException();
                }
            }
            else
            {
                switch (kind)
                {
                case CommentLine.Kinds.TranslatorComment:
                    return(string.Format("# {0}", text));

                case CommentLine.Kinds.ExtractedComment:
                    return(string.Format("#. {0}", text));

                case CommentLine.Kinds.Reference:
                    return(string.Format("#: {0}", text));

                case CommentLine.Kinds.Flags:
                    return(string.Format("#, {0}", text));

                case CommentLine.Kinds.PreviousUntraslated_Context:
                    return(string.Format("#| msgctxt \"{0}\"", text));

                case CommentLine.Kinds.PreviousUntraslated_ID:
                    return(string.Format("#| msgid \"{0}\"", text));

                case CommentLine.Kinds.PreviousUntraslated_IDPlural:
                    return(string.Format("#| msgid_plural \"{0}\"", text));

                case CommentLine.Kinds.Removed_Context:
                    return(string.Format("#~ msgctxt \"{0}\"", text));

                case CommentLine.Kinds.Removed_ID:
                    return(string.Format("#~ msgid \"{0}\"", text));

                case CommentLine.Kinds.Removed_IDPlural:
                    return(string.Format("#~ msgid_plural \"{0}\"", text));

                case CommentLine.Kinds.Removed_Translated:
                    return(string.Format("#~ msgstr \"{0}\"", text));

                case CommentLine.Kinds.Removed_TranslatedIndexed:
                    return(string.Format("#~ msgstr[{0}] \"{1}\"", index.Value, text));

                default:
                    throw new NotImplementedException();
                }
            }
        }
예제 #4
0
 protected CommentLine(POFile file, IO.TextLine source, bool isContinuation, CommentLine.Kinds kind, string text)
     : base(file, source, Line.Types.Comment, isContinuation, text)
 {
     this._kind = kind;
 }
예제 #5
0
 protected CommentLine(POFile file, IO.TextLine source, bool isContinuation, CommentLine.Kinds kind, string text)
     : base(file, source, Line.Types.Comment, isContinuation, text)
 {
     this._kind = kind;
 }