aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gotext.go66
1 files changed, 38 insertions, 28 deletions
diff --git a/src/gotext.go b/src/gotext.go
index 73190c3..bfba745 100644
--- a/src/gotext.go
+++ b/src/gotext.go
@@ -229,30 +229,25 @@ func processSingleGoSource(fset *token.FileSet, fname string) error {
}
var formatTime = func() string {
- return time.Now().Format("2006-01-02 15:04-0700")
+ if false {
+ // FIXME
+ return time.Now().Format("2006-01-02 15:04-0700")
+ }
+ return "2015-06-30T14:48:00-03:00"
}
func writePotFile(out io.Writer) {
- header := fmt.Sprintf(`# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr "Project-Id-Version: %s\n"
- "Report-Msgid-Bugs-To: %s\n"
- "POT-Creation-Date: %s\n"
- "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
- "Language-Team: LANGUAGE <LL@li.org>\n"
- "Language: \n"
- "MIME-Version: 1.0\n"
- "Content-Type: text/plain; charset=UTF-8\n"
- "Content-Transfer-Encoding: 8bit\n"
-
-`, opts.PackageName, opts.MsgIDBugsAddress, formatTime())
+ header := g.Heredoc(`
+ #, fuzzy
+ msgid ""
+ msgstr ""
+ "Language: \n"
+ "MIME-Version: 1.0\n"
+ "Content-Type: text/plain; charset=UTF-8\n"
+ "Content-Transfer-Encoding: 8bit\n"
+
+ `)
fmt.Fprintf(out, "%s", header)
// yes, this is the way to do it in go
@@ -286,17 +281,23 @@ msgstr "Project-Id-Version: %s\n"
var formatOutput = func(in string) string {
// split string with \n into multiple lines
// to make the output nicer
- out := strings.Replace(in, "\\n", "\\n\"\n \"", -1)
+ out := strings.Replace(in, "\\n", "\\n\"\n\"", -1)
// cleanup too aggressive splitting (empty "" lines)
- return strings.TrimSuffix(out, "\"\n \"")
+ out = strings.TrimSuffix(out, "\"\n\"")
+
+ if strings.Count(out, "\n") == 0 {
+ return out
+ } else {
+ return "\"\n\"" + out
+ }
}
- fmt.Fprintf(out, "msgid \"%v\"\n", formatOutput(k))
+ fmt.Fprintf(out, "msgid \"%v\"\n", formatOutput(k))
if msgid.msgidPlural != "" {
- fmt.Fprintf(out, "msgid_plural \"%v\"\n", formatOutput(msgid.msgidPlural))
- fmt.Fprintf(out, "msgstr[0] \"\"\n")
- fmt.Fprintf(out, "msgstr[1] \"\"\n")
+ fmt.Fprintf(out, "msgid_plural \"%v\"\n", formatOutput(msgid.msgidPlural))
+ fmt.Fprintf(out, "msgstr[0] \"\"\n")
+ fmt.Fprintf(out, "msgstr[1] \"\"\n")
} else {
- fmt.Fprintf(out, "msgstr \"\"\n")
+ fmt.Fprintf(out, "msgstr \"\"\n")
}
fmt.Fprintf(out, "\n")
}
@@ -323,7 +324,16 @@ type optsT struct {
KeywordPlural string `long:"keyword-plural" default:"gt.NGettext" description:"look for WORD as the keyword for plural strings"`
}
-var opts optsT
+// FIXME: Remove me
+var opts = optsT{
+ NoLocation: false,
+ AddCommentsTag: "TRANSLATORS:",
+ Keyword: "i18n.G",
+ KeywordPlural: "i18n.NG",
+ SortOutput: true,
+ PackageName: "snappy",
+ MsgIDBugsAddress: "snappy-devel@lists.ubuntu.com",
+}
type argsT struct{
allArgs []string