...
1
2
3
4
5 package po
6
7 import (
8 "regexp"
9 )
10
11 var (
12 reComment = regexp.MustCompile(`^#`)
13 reExtractedComments = regexp.MustCompile(`^#\.`)
14 reReferenceComments = regexp.MustCompile(`^#:`)
15 reFlagsComments = regexp.MustCompile(`^#,`)
16 rePrevMsgContextComments = regexp.MustCompile(`^#\|\s+msgctxt`)
17 rePrevMsgIdComments = regexp.MustCompile(`^#\|\s+msgid`)
18 reStringLineComments = regexp.MustCompile(`^#\|\s+".*"\s*$`)
19
20 reMsgContext = regexp.MustCompile(`^msgctxt\s+".*"\s*$`)
21 reMsgId = regexp.MustCompile(`^msgid\s+".*"\s*$`)
22 reMsgIdPlural = regexp.MustCompile(`^msgid_plural\s+".*"\s*$`)
23 reMsgStr = regexp.MustCompile(`^msgstr\s*".*"\s*$`)
24 reMsgStrPlural = regexp.MustCompile(`^msgstr\s*(\[\d+\])\s*".*"\s*$`)
25 reStringLine = regexp.MustCompile(`^\s*".*"\s*$`)
26 reBlankLine = regexp.MustCompile(`^\s*$`)
27 )
28
29 func (p *Message) isInvalidLine(s string) bool {
30 if reComment.MatchString(s) {
31 return false
32 }
33 if reBlankLine.MatchString(s) {
34 return false
35 }
36
37 if reMsgContext.MatchString(s) {
38 return false
39 }
40 if reMsgId.MatchString(s) {
41 return false
42 }
43 if reMsgIdPlural.MatchString(s) {
44 return false
45 }
46 if reMsgStr.MatchString(s) {
47 return false
48 }
49 if reMsgStrPlural.MatchString(s) {
50 return false
51 }
52
53 if reStringLine.MatchString(s) {
54 return false
55 }
56
57 return true
58 }
59
View as plain text