2017-05-11 16:39:54 +02:00
|
|
|
// Copyright 2016 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-01-16 14:20:59 +01:00
|
|
|
"golang.org/x/text/message/pipeline"
|
2017-05-11 16:39:54 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
// - merge information into existing files
|
|
|
|
// - handle different file formats (PO, XLIFF)
|
|
|
|
// - handle features (gender, plural)
|
|
|
|
// - message rewriting
|
|
|
|
|
2018-01-16 14:20:59 +01:00
|
|
|
func init() {
|
|
|
|
lang = cmdExtract.Flag.String("lang", "en-US", "comma-separated list of languages to process")
|
|
|
|
}
|
|
|
|
|
2017-05-11 16:39:54 +02:00
|
|
|
var cmdExtract = &Command{
|
|
|
|
Run: runExtract,
|
|
|
|
UsageLine: "extract <package>*",
|
2018-01-16 14:20:59 +01:00
|
|
|
Short: "extracts strings to be translated from code",
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2018-01-16 14:20:59 +01:00
|
|
|
func runExtract(cmd *Command, config *pipeline.Config, args []string) error {
|
|
|
|
config.Packages = args
|
|
|
|
state, err := pipeline.Extract(config)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2018-01-16 14:20:59 +01:00
|
|
|
return wrap(err, "extract failed")
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
2018-01-16 14:20:59 +01:00
|
|
|
if err := state.Import(); err != nil {
|
|
|
|
return wrap(err, "import failed")
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
2018-01-16 14:20:59 +01:00
|
|
|
if err := state.Merge(); err != nil {
|
|
|
|
return wrap(err, "merge failed")
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
2018-01-16 14:20:59 +01:00
|
|
|
return wrap(state.Export(), "export failed")
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|