Skip to content

Commit

Permalink
There should be no whitespace before comments or other specifiers (#12)
Browse files Browse the repository at this point in the history
* There should be no whitespace before comments or other specifiers

* Convert tab to space

* Specify eol
  • Loading branch information
taylor-s-dean authored Jan 11, 2022
1 parent 660fb03 commit d552ecf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions gettext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ var messagesJSON = []byte(`
"other"
]
},
"#This is a message with a # sign.": {
"translation": "#This is a translation with a # sign."
},
"One piggy went to the market.": {
"translation": "Одна свинья ушла на рынок."
}
Expand Down
14 changes: 7 additions & 7 deletions po2json/po2json.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ var (
stateMsgstrPlural: "msgstr_plural",
}

regexComment = regexp.MustCompile(`\s*#.*`)
regexComment = regexp.MustCompile(`^#.*$`)
regexEmpty = regexp.MustCompile(`^\s*$`)
regexMsgctxt = regexp.MustCompile(`msgctxt\s+(".*")`)
regexMsgid = regexp.MustCompile(`msgid\s+(".*")`)
regexMsgstr = regexp.MustCompile(`msgstr\s+(".*")`)
regexMsgidPlural = regexp.MustCompile(`msgid_plural\s+(".*")`)
regexMsgstrPlural = regexp.MustCompile(`msgstr\[\d+\]\s+(".*")`)
regexString = regexp.MustCompile(`(".*")`)
regexMsgctxt = regexp.MustCompile(`^msgctxt\s+(".*")$`)
regexMsgid = regexp.MustCompile(`^msgid\s+(".*")$`)
regexMsgstr = regexp.MustCompile(`^msgstr\s+(".*")$`)
regexMsgidPlural = regexp.MustCompile(`^msgid_plural\s+(".*")$`)
regexMsgstrPlural = regexp.MustCompile(`^msgstr\[\d+\]\s+(".*")$`)
regexString = regexp.MustCompile(`^(".*")$`)
regexHeaderKeyValue = regexp.MustCompile(`([a-zA-Z0-9-]+)\s*:\s*(.*?)(?:\n|\z)`)
)

Expand Down
3 changes: 3 additions & 0 deletions testdata/test.po
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ msgctxt "Context with plural"
msgid "One piggy went to the market."
msgstr "Одна свинья ушла на рынок."

msgid "#This is a message with a # sign."
msgstr "#This is a translation with a # sign."

#, fuzzy
msgctxt ""
"Context with plural"
Expand Down

0 comments on commit d552ecf

Please sign in to comment.