1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

Add FeedIcon API call and update dependencies

This commit is contained in:
Frédéric Guillot 2017-12-16 11:25:18 -08:00
parent 231ebf2daa
commit 27196589fb
262 changed files with 83830 additions and 30061 deletions

View file

@ -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,22 @@ 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,
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 +59,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.
@ -87,8 +101,9 @@ func (c *Command) Runnable() bool {
// The order here is the order in which they are printed by 'go help'.
var commands = []*Command{
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 +141,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 +296,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 +306,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 +330,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 +357,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)
}