1
// Copyright 2013 ChaiShushan <chaishushan{AT}gmail.com>. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
12
func TestPoComment(t *testing.T) {
14
for i := 0; i < len(testPoComments); i++ {
18
err := x.readPoComment(newLineReader(testPoComments[i].Data))
20
t.Fatalf("%d: %v", i, err)
22
x.StartLine = 0 // ingore comment line
23
if !reflect.DeepEqual(&x, &testPoComments[i].PoComment) {
24
t.Logf("expect(%d):\n", i)
25
t.Logf("\n%v\n", &testPoComments[i].PoComment)
26
t.Logf("got(%d):\n", i)
30
if testPoComments[i].CheckStringer {
31
s := testPoComments[i].PoComment.String()
32
if s != testPoComments[i].Data {
33
t.Logf("expect(%d):\n", i)
34
t.Logf("\n%s\n", testPoComments[i].Data)
35
t.Logf("got(%d):\n", i)
36
t.Logf("\n%s\n", testPoComments[i].PoComment.String())
43
type testPoComment struct {
49
var testPoComments = []testPoComment{
51
// --------------------------------------------------------------
52
// CheckStringer: true
53
// --------------------------------------------------------------
57
Data: `# translator comments
60
TranslatorComment: `translator comments`,
65
Data: `# translator comments
68
TranslatorComment: `translator comments`,
74
Data: `# translator-comments
77
#: src/msgcmp.c:338 src/po-lex.c:699 src/msg.c:123
78
#, fuzzy, c-format, range:0..10
80
#| "previous-context1\n"
81
#| "previous-context2"
83
#| "previous-untranslated-string1\n"
84
#| "previous-untranslated-string2"
87
TranslatorComment: "translator-comments\nbad comment",
88
ExtractedComment: "extracted-comments",
89
ReferenceFile: []string{"src/msgcmp.c", "src/po-lex.c", "src/msg.c"},
90
ReferenceLine: []int{338, 699, 123},
91
Flags: []string{"fuzzy", "c-format", "range:0..10"},
92
PrevMsgContext: "previous-context1\nprevious-context2",
93
PrevMsgId: "previous-untranslated-string1\nprevious-untranslated-string2",
97
// --------------------------------------------------------------
98
// CheckStringer: false
99
// --------------------------------------------------------------
102
CheckStringer: false,
104
# translator-comments
106
#. extracted-comments
107
#: src/msgcmp.c:338 src/po-lex.c:699
109
#, fuzzy,c-format,range:0..10
111
#| "previous-context1\n"
112
#| "previous-context2"
114
#| "previous-untranslated-string1\n"
115
#| "previous-untranslated-string2"
118
TranslatorComment: "translator-comments\nbad comment",
119
ExtractedComment: "extracted-comments",
120
ReferenceFile: []string{"src/msgcmp.c", "src/po-lex.c", "src/msg.c"},
121
ReferenceLine: []int{338, 699, 123},
122
Flags: []string{"fuzzy", "c-format", "range:0..10"},
123
PrevMsgContext: "previous-context1\nprevious-context2",
124
PrevMsgId: "previous-untranslated-string1\nprevious-untranslated-string2",
128
CheckStringer: false,
130
# SOME DESCRIPTIVE TITLE.
131
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
132
# This file is distributed under the same license as the PACKAGE package.
133
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
137
"Project-Id-Version: Poedit 1.5\n"
138
"Report-Msgid-Bugs-To: poedit@googlegroups.com\n"
139
"POT-Creation-Date: 2012-07-30 10:34+0200\n"
140
"PO-Revision-Date: 2013-12-25 09:32+0800\n"
141
"Last-Translator: chai2010 <chaishushan@gmail.com>\n"
143
"MIME-Version: 1.0\n"
144
"Content-Type: text/plain; charset=UTF-8\n"
145
"Content-Transfer-Encoding: 8bit\n"
146
"Plural-Forms: nplurals=1; plural=0;\n"
147
"X-Generator: Poedit 1.5.7\n"
150
TranslatorComment: `SOME DESCRIPTIVE TITLE.
151
Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
152
This file is distributed under the same license as the PACKAGE package.
153
FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
158
CheckStringer: false,
160
#. TRANSLATORS: This is version information in about dialog, it is followed
161
#. by version number when used (wxWidgets 2.8)
162
#: ../src/edframe.cpp:2431
163
#| msgctxt "previous-context asdasd"
168
ExtractedComment: `TRANSLATORS: This is version information in about dialog, it is followed
169
by version number when used (wxWidgets 2.8)`,
170
ReferenceFile: []string{"../src/edframe.cpp"},
171
ReferenceLine: []int{2431},
172
PrevMsgContext: "previous-context asdasd",
176
CheckStringer: false,
179
msgid "First string for testing."
180
msgstr "Lang1: 1st string"
183
ReferenceFile: []string{"tst-gettext2.c"},
184
ReferenceLine: []int{33},
188
CheckStringer: false,
190
#: app/app_procs.c:307
192
msgid "Can't find output format %s\n"
194
"敲矾弊牢 '%s'甫 佬阑荐 绝嚼聪促\n"
198
ReferenceFile: []string{"app/app_procs.c"},
199
ReferenceLine: []int{307},
200
Flags: []string{"fuzzy", "c-format"},
204
// --------------------------------------------------------------
206
// --------------------------------------------------------------