...
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 cmdUpdate = &Command{
18 Init: initUpdate,
19 Run: runUpdate,
20 UsageLine: "update <package>* [-out <gofile>]",
21 Short: "merge translations and generate catalog",
22 }
23
24 func initUpdate(cmd *Command) {
25 lang = cmd.Flag.String("lang", "en-US", "comma-separated list of languages to process")
26 out = cmd.Flag.String("out", "", "output file to write to")
27 }
28
29 func runUpdate(cmd *Command, config *pipeline.Config, args []string) error {
30 config.Packages = args
31 state, err := pipeline.Extract(config)
32 if err != nil {
33 return wrap(err, "extract failed")
34 }
35 if err := state.Import(); err != nil {
36 return wrap(err, "import failed")
37 }
38 if err := state.Merge(); err != nil {
39 return wrap(err, "merge failed")
40 }
41 if err := state.Export(); err != nil {
42 return wrap(err, "export failed")
43 }
44 if *out != "" {
45 return wrap(state.Generate(), "generation failed")
46 }
47 return nil
48 }
49
View as plain text