...
1
2
3
4
5 package main
6
7 import (
8 "golang.org/x/text/message/pipeline"
9 )
10
11
12
13
14
15
16
17 var cmdExtract = &Command{
18 Init: initExtract,
19 Run: runExtract,
20 UsageLine: "extract <package>*",
21 Short: "extracts strings to be translated from code",
22 }
23
24 func initExtract(cmd *Command) {
25 lang = cmd.Flag.String("lang", "en-US", "comma-separated list of languages to process")
26 }
27
28 func runExtract(cmd *Command, config *pipeline.Config, args []string) error {
29 config.Packages = args
30 state, err := pipeline.Extract(config)
31 if err != nil {
32 return wrap(err, "extract failed")
33 }
34 if err := state.Import(); err != nil {
35 return wrap(err, "import failed")
36 }
37 if err := state.Merge(); err != nil {
38 return wrap(err, "merge failed")
39 }
40 return wrap(state.Export(), "export failed")
41 }
42
View as plain text