...
1
2
3
4
5
6
7
8
9 package main
10
11 import (
12 "flag"
13 "fmt"
14 "log"
15
16 "github.com/chai2010/gettext-go/po"
17 )
18
19 var (
20 flagPotFile = flag.String("pot-file", "output.pot", "set output pot file path")
21 flagHelp = flag.Bool("h", false, "show help info")
22 )
23
24 func init() {
25 log.SetFlags(log.Lshortfile)
26
27 flag.Usage = func() {
28 fmt.Println("usage: xgettext-go [flags] pkgpath")
29 fmt.Println(" xgettext-go -pot-file=output.pot pkgpath")
30 fmt.Println(" xgettext-go -h")
31 fmt.Println()
32
33 flag.PrintDefaults()
34 fmt.Println()
35
36 fmt.Println("See https://github.com/chai2010/gettext-go")
37 }
38 }
39
40 func main() {
41 flag.Parse()
42
43 if flag.NArg() == 0 || *flagHelp {
44 flag.Usage()
45 return
46 }
47
48 pkg := LoadPackage(flag.Arg(0))
49 potFile := pkg.GenPotFile()
50
51 if err := potFile.Save(*flagPotFile); err != nil {
52 log.Fatal(err)
53 }
54
55 if _, err := po.LoadFile(*flagPotFile); err != nil {
56 log.Println(err)
57 }
58 }
59
View as plain text