You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

41 lines
1.0 KiB

  1. // Copyright 2016 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package main
  5. import (
  6. "golang.org/x/text/message/pipeline"
  7. )
  8. // TODO:
  9. // - merge information into existing files
  10. // - handle different file formats (PO, XLIFF)
  11. // - handle features (gender, plural)
  12. // - message rewriting
  13. func init() {
  14. lang = cmdExtract.Flag.String("lang", "en-US", "comma-separated list of languages to process")
  15. }
  16. var cmdExtract = &Command{
  17. Run: runExtract,
  18. UsageLine: "extract <package>*",
  19. Short: "extracts strings to be translated from code",
  20. }
  21. func runExtract(cmd *Command, config *pipeline.Config, args []string) error {
  22. config.Packages = args
  23. state, err := pipeline.Extract(config)
  24. if err != nil {
  25. return wrap(err, "extract failed")
  26. }
  27. if err := state.Import(); err != nil {
  28. return wrap(err, "import failed")
  29. }
  30. if err := state.Merge(); err != nil {
  31. return wrap(err, "merge failed")
  32. }
  33. return wrap(state.Export(), "export failed")
  34. }