From 2fa7c464f019f67c5c0494aaf5ac0f5ecc1ee7a7 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 16 Jan 2018 12:03:31 -0500 Subject: Updated dependencies and added avct/uasurfer (#8089) * Updated dependencies and added avct/uasurfer * Added uasurfer to NOTICE.txt --- vendor/golang.org/x/text/cmd/gotext/main.go | 53 ++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 17 deletions(-) (limited to 'vendor/golang.org/x/text/cmd/gotext/main.go') diff --git a/vendor/golang.org/x/text/cmd/gotext/main.go b/vendor/golang.org/x/text/cmd/gotext/main.go index b03eb5565..73f6d91cb 100644 --- a/vendor/golang.org/x/text/cmd/gotext/main.go +++ b/vendor/golang.org/x/text/cmd/gotext/main.go @@ -25,6 +25,8 @@ import ( "unicode" "unicode/utf8" + "golang.org/x/text/message/pipeline" + "golang.org/x/text/language" "golang.org/x/tools/go/buildutil" ) @@ -34,10 +36,23 @@ func init() { } var ( - dir = flag.String("dir", "textdata", "default subdirectory to store translation files") - langs = flag.String("lang", "en", "comma-separated list of languages to process") + srcLang = flag.String("srclang", "en-US", "the source-code language") + dir = flag.String("dir", "locales", "default subdirectory to store translation files") ) +func config() (*pipeline.Config, error) { + tag, err := language.Parse(*srcLang) + if err != nil { + return nil, wrap(err, "invalid srclang") + } + return &pipeline.Config{ + SourceLanguage: tag, + Supported: getLangs(), + TranslationsPattern: `messages\.(.*)\.json`, + GenFile: *out, + }, nil +} + // NOTE: the Command struct is copied from the go tool in core. // A Command is an implementation of a go command @@ -45,7 +60,7 @@ var ( type Command struct { // Run runs the command. // The args are the arguments after the command name. - Run func(cmd *Command, args []string) error + Run func(cmd *Command, c *pipeline.Config, args []string) error // UsageLine is the one-line usage message. // The first word in the line is taken to be the command name. @@ -86,9 +101,11 @@ func (c *Command) Runnable() bool { // Commands lists the available commands and help topics. // The order here is the order in which they are printed by 'go help'. var commands = []*Command{ + cmdUpdate, cmdExtract, + cmdRewrite, + cmdGenerate, // TODO: - // - generate code from translations. // - update: full-cycle update of extraction, sending, and integration // - report: report of freshness of translations } @@ -126,8 +143,12 @@ func main() { cmd.Flag.Usage = func() { cmd.Usage() } cmd.Flag.Parse(args[1:]) args = cmd.Flag.Args() - if err := cmd.Run(cmd, args); err != nil { - fatalf("gotext: %v", err) + config, err := config() + if err != nil { + fatalf("gotext: %+v", err) + } + if err := cmd.Run(cmd, config, args); err != nil { + fatalf("gotext: %+v", err) } exit() return @@ -277,12 +298,7 @@ func help(args []string) { if strings.HasSuffix(arg, "documentation") { w := &bytes.Buffer{} - fmt.Fprintln(w, "// Copyright 2016 The Go Authors. All rights reserved.") - fmt.Fprintln(w, "// Use of this source code is governed by a BSD-style") - fmt.Fprintln(w, "// license that can be found in the LICENSE file.") - fmt.Fprintln(w) - fmt.Fprintln(w, "// DO NOT EDIT THIS FILE. GENERATED BY go generate.") - fmt.Fprintln(w, "// Edit the documentation in other files and rerun go generate to generate this one.") + fmt.Fprintln(w, "// Code generated by go generate. DO NOT EDIT.") fmt.Fprintln(w) buf := new(bytes.Buffer) printUsage(buf) @@ -292,10 +308,10 @@ func help(args []string) { if arg == "gendocumentation" { b, err := format.Source(w.Bytes()) if err != nil { - errorf("Could not format generated docs: %v\n", err) + logf("Could not format generated docs: %v\n", err) } if err := ioutil.WriteFile("doc.go", b, 0666); err != nil { - errorf("Could not create file alldocs.go: %v\n", err) + logf("Could not create file alldocs.go: %v\n", err) } } else { fmt.Println(w.String()) @@ -316,7 +332,10 @@ func help(args []string) { } func getLangs() (tags []language.Tag) { - for _, t := range strings.Split(*langs, ",") { + for _, t := range strings.Split(*lang, ",") { + if t == "" { + continue + } tag, err := language.Parse(t) if err != nil { fatalf("gotext: could not parse language %q: %v", t, err) @@ -340,11 +359,11 @@ func exit() { } func fatalf(format string, args ...interface{}) { - errorf(format, args...) + logf(format, args...) exit() } -func errorf(format string, args ...interface{}) { +func logf(format string, args ...interface{}) { log.Printf(format, args...) setExitStatus(1) } -- cgit v1.2.3-1-g7c22