diff options
Diffstat (limited to 'vendor/golang.org/x/text/cmd/gotext/examples/extract_http')
7 files changed, 0 insertions, 251 deletions
diff --git a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/catalog_gen.go b/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/catalog_gen.go deleted file mode 100644 index 2c410dcdb..000000000 --- a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/catalog_gen.go +++ /dev/null @@ -1,57 +0,0 @@ -// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. - -package main - -import ( - "golang.org/x/text/language" - "golang.org/x/text/message" - "golang.org/x/text/message/catalog" -) - -type dictionary struct { - index []uint32 - data string -} - -func (d *dictionary) Lookup(key string) (data string, ok bool) { - p := messageKeyToIndex[key] - start, end := d.index[p], d.index[p+1] - if start == end { - return "", false - } - return d.data[start:end], true -} - -func init() { - dict := map[string]catalog.Dictionary{ - "en": &dictionary{index: enIndex, data: enData}, - "zh": &dictionary{index: zhIndex, data: zhData}, - } - fallback := language.MustParse("en") - cat, err := catalog.NewFromMap(dict, catalog.Fallback(fallback)) - if err != nil { - panic(err) - } - message.DefaultCatalog = cat -} - -var messageKeyToIndex = map[string]int{ - "Do you like your browser (%s)?\n": 1, - "Hello %s!\n": 0, -} - -var enIndex = []uint32{ // 3 elements - 0x00000000, 0x00000012, 0x00000039, -} // Size: 36 bytes - -const enData string = "" + // Size: 57 bytes - "\x04\x00\x01\x0a\x0d\x02Hello %[1]s!\x04\x00\x01\x0a\x22\x02Do you like " + - "your browser (%[1]s)?" - -var zhIndex = []uint32{ // 3 elements - 0x00000000, 0x00000000, 0x00000000, -} // Size: 36 bytes - -const zhData string = "" - -// Total table size 129 bytes (0KiB); checksum: 9C146C82 diff --git a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/de/out.gotext.json b/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/de/out.gotext.json deleted file mode 100755 index d8437c01f..000000000 --- a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/de/out.gotext.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "language": "de", - "messages": [ - { - "id": "Hello {From}!", - "key": "Hello %s!\n", - "message": "Hello {From}!", - "translation": "", - "placeholders": [ - { - "id": "From", - "string": "%[1]s", - "type": "string", - "underlyingType": "string", - "argNum": 1, - "expr": "r.Header.Get(\"From\")" - } - ], - "position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:22:11" - }, - { - "id": "Do you like your browser ({User_Agent})?", - "key": "Do you like your browser (%s)?\n", - "message": "Do you like your browser ({User_Agent})?", - "translation": "", - "placeholders": [ - { - "id": "User_Agent", - "string": "%[1]s", - "type": "string", - "underlyingType": "string", - "argNum": 1, - "expr": "r.Header.Get(\"User-Agent\")" - } - ], - "position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:24:11" - } - ] -}
\ No newline at end of file diff --git a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/en-US/out.gotext.json b/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/en-US/out.gotext.json deleted file mode 100755 index de59eca1d..000000000 --- a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/en-US/out.gotext.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "language": "en-US", - "messages": [ - { - "id": "Hello {From}!", - "key": "Hello %s!\n", - "message": "Hello {From}!", - "translation": "", - "placeholders": [ - { - "id": "From", - "string": "%[1]s", - "type": "string", - "underlyingType": "string", - "argNum": 1, - "expr": "r.Header.Get(\"From\")" - } - ], - "position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:22:11" - }, - { - "id": "Do you like your browser ({User_Agent})?", - "key": "Do you like your browser (%s)?\n", - "message": "Do you like your browser ({User_Agent})?", - "translation": "", - "placeholders": [ - { - "id": "User_Agent", - "string": "%[1]s", - "type": "string", - "underlyingType": "string", - "argNum": 1, - "expr": "r.Header.Get(\"User-Agent\")" - } - ], - "position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:24:11" - } - ] -}
\ No newline at end of file diff --git a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/en/out.gotext.json b/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/en/out.gotext.json deleted file mode 100644 index 1391e5848..000000000 --- a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/en/out.gotext.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "language": "en", - "messages": [ - { - "id": "Hello {From}!", - "message": "Hello {From}!", - "translation": "Hello {From}!", - "translatorComment": "Copied from source.", - "placeholders": [ - { - "id": "From", - "string": "%[1]s", - "type": "string", - "underlyingType": "string", - "argNum": 1, - "expr": "r.Header.Get(\"From\")" - } - ], - "fuzzy": true - }, - { - "id": "Do you like your browser ({User_Agent})?", - "message": "Do you like your browser ({User_Agent})?", - "translation": "Do you like your browser ({User_Agent})?", - "translatorComment": "Copied from source.", - "placeholders": [ - { - "id": "User_Agent", - "string": "%[1]s", - "type": "string", - "underlyingType": "string", - "argNum": 1, - "expr": "r.Header.Get(\"User-Agent\")" - } - ], - "fuzzy": true - } - ] -}
\ No newline at end of file diff --git a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/zh/out.gotext.json b/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/zh/out.gotext.json deleted file mode 100755 index 7b26974d5..000000000 --- a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/zh/out.gotext.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "language": "zh", - "messages": [ - { - "id": "Hello {From}!", - "message": "Hello {From}!", - "translation": "", - "placeholders": [ - { - "id": "From", - "string": "%[1]s", - "type": "string", - "underlyingType": "string", - "argNum": 1, - "expr": "r.Header.Get(\"From\")" - } - ] - }, - { - "id": "Do you like your browser ({User_Agent})?", - "message": "Do you like your browser ({User_Agent})?", - "translation": "", - "placeholders": [ - { - "id": "User_Agent", - "string": "%[1]s", - "type": "string", - "underlyingType": "string", - "argNum": 1, - "expr": "r.Header.Get(\"User-Agent\")" - } - ] - } - ] -}
\ No newline at end of file diff --git a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/main.go b/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/main.go deleted file mode 100644 index b5eb3b334..000000000 --- a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/main.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 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 - -//go:generate gotext -srclang=en update -out=catalog_gen.go -lang=en,zh - -import ( - "net/http" - - "golang.org/x/text/cmd/gotext/examples/extract_http/pkg" -) - -func main() { - http.Handle("/generize", http.HandlerFunc(pkg.Generize)) -} diff --git a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go b/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go deleted file mode 100644 index 7b4463488..000000000 --- a/vendor/golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 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 pkg - -import ( - "net/http" - - "golang.org/x/text/language" - "golang.org/x/text/message" -) - -var matcher = language.NewMatcher(message.DefaultCatalog.Languages()) - -func Generize(w http.ResponseWriter, r *http.Request) { - lang, _ := r.Cookie("lang") - accept := r.Header.Get("Accept-Language") - tag := message.MatchLanguage(lang.String(), accept) - p := message.NewPrinter(tag) - - p.Fprintf(w, "Hello %s!\n", r.Header.Get("From")) - - p.Fprintf(w, "Do you like your browser (%s)?\n", r.Header.Get("User-Agent")) -} |