Update vendored library golang.org/x/text
This commit is contained in:
parent
d8dd79eb0b
commit
5b6568875c
46 changed files with 610 additions and 2739 deletions
4
Gopkg.lock
generated
4
Gopkg.lock
generated
|
@ -206,10 +206,10 @@
|
||||||
revision = "378d26f46672a356c46195c28f61bdb4c0a781dd"
|
revision = "378d26f46672a356c46195c28f61bdb4c0a781dd"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
|
||||||
name = "golang.org/x/text"
|
name = "golang.org/x/text"
|
||||||
packages = ["collate","collate/build","internal/colltab","internal/gen","internal/tag","internal/triegen","internal/ucd","language","secure/bidirule","transform","unicode/bidi","unicode/cldr","unicode/norm","unicode/rangetable"]
|
packages = ["collate","collate/build","internal/colltab","internal/gen","internal/tag","internal/triegen","internal/ucd","language","secure/bidirule","transform","unicode/bidi","unicode/cldr","unicode/norm","unicode/rangetable"]
|
||||||
revision = "e19ae1496984b1c655b8044a65c0300a3c878dd3"
|
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
|
||||||
|
version = "v0.3.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|
3
vendor/golang.org/x/text/cmd/gotext/common.go
generated
vendored
3
vendor/golang.org/x/text/cmd/gotext/common.go
generated
vendored
|
@ -21,9 +21,6 @@ const (
|
||||||
// NOTE: The command line tool already prefixes with "gotext:".
|
// NOTE: The command line tool already prefixes with "gotext:".
|
||||||
var (
|
var (
|
||||||
wrap = func(err error, msg string) error {
|
wrap = func(err error, msg string) error {
|
||||||
if err == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return fmt.Errorf("%s: %v", msg, err)
|
return fmt.Errorf("%s: %v", msg, err)
|
||||||
}
|
}
|
||||||
errorf = fmt.Errorf
|
errorf = fmt.Errorf
|
||||||
|
|
60
vendor/golang.org/x/text/cmd/gotext/examples/extract/catalog.go
generated
vendored
60
vendor/golang.org/x/text/cmd/gotext/examples/extract/catalog.go
generated
vendored
|
@ -37,48 +37,40 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var messageKeyToIndex = map[string]int{
|
var messageKeyToIndex = map[string]int{
|
||||||
"%.2[1]f miles traveled (%[1]f)": 8,
|
"%.2[1]f miles traveled (%[1]f)": 6,
|
||||||
"%[1]s is visiting %[3]s!\n": 3,
|
"%[1]s is visiting %[3]s!\n": 3,
|
||||||
"%d files remaining!": 5,
|
"%d more files remaining!": 4,
|
||||||
"%d more files remaining!": 4,
|
"%s is out of order!": 5,
|
||||||
"%s is out of order!": 7,
|
"%s is visiting %s!\n": 2,
|
||||||
"%s is visiting %s!\n": 2,
|
"Hello %s!\n": 1,
|
||||||
"Hello %s!\n": 1,
|
"Hello world!\n": 0,
|
||||||
"Hello world!\n": 0,
|
|
||||||
"Use the following code for your discount: %d\n": 6,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var deIndex = []uint32{ // 10 elements
|
var deIndex = []uint32{ // 8 elements
|
||||||
0x00000000, 0x00000011, 0x00000023, 0x0000003d,
|
0x00000000, 0x0000000d, 0x0000001b, 0x00000031,
|
||||||
0x00000057, 0x00000076, 0x00000076, 0x00000076,
|
0x00000047, 0x00000066, 0x00000066, 0x00000066,
|
||||||
0x00000076, 0x00000076,
|
} // Size: 56 bytes
|
||||||
} // Size: 64 bytes
|
|
||||||
|
|
||||||
const deData string = "" + // Size: 118 bytes
|
const deData string = "" + // Size: 102 bytes
|
||||||
"\x04\x00\x01\x0a\x0c\x02Hallo Welt!\x04\x00\x01\x0a\x0d\x02Hallo %[1]s!" +
|
"\x02Hallo Welt!\x0a\x02Hallo %[1]s!\x0a\x02%[1]s besucht %[2]s!\x0a\x02%" +
|
||||||
"\x04\x00\x01\x0a\x15\x02%[1]s besucht %[2]s!\x04\x00\x01\x0a\x15\x02%[1]" +
|
"[1]s besucht %[3]s!\x0a\x02Noch %[1]d Bestände zu gehen!"
|
||||||
"s besucht %[3]s!\x02Noch %[1]d Bestände zu gehen!"
|
|
||||||
|
|
||||||
var en_USIndex = []uint32{ // 10 elements
|
var en_USIndex = []uint32{ // 8 elements
|
||||||
0x00000000, 0x00000012, 0x00000024, 0x00000042,
|
0x00000000, 0x0000000e, 0x0000001c, 0x00000036,
|
||||||
0x00000060, 0x000000a3, 0x000000ba, 0x000000ef,
|
0x00000050, 0x00000093, 0x000000aa, 0x000000c9,
|
||||||
0x00000106, 0x00000125,
|
} // Size: 56 bytes
|
||||||
} // Size: 64 bytes
|
|
||||||
|
|
||||||
const en_USData string = "" + // Size: 293 bytes
|
const en_USData string = "" + // Size: 201 bytes
|
||||||
"\x04\x00\x01\x0a\x0d\x02Hello world!\x04\x00\x01\x0a\x0d\x02Hello %[1]sn" +
|
"\x02Hello world!\x0a\x02Hello %[1]s!\x0a\x02%[1]s is visiting %[2]s!\x0a" +
|
||||||
"\x04\x00\x01\x0a\x19\x02%[1]s is visiting %[2]s!\x04\x00\x01\x0a\x19\x02" +
|
"\x02%[1]s is visiting %[3]s!\x0a\x04\x01\x81\x01\x00\x02\x14\x02One file" +
|
||||||
"%[1]s is visiting %[3]s!\x14\x01\x81\x01\x00\x02\x14\x02One file remaini" +
|
" remaining!\x00&\x02There are %[1]d more files remaining!\x02%[1]s is ou" +
|
||||||
"ng!\x00&\x02There are %[1]d more files remaining!\x02%[1]d files remaini" +
|
"t of order!\x02%.2[1]f miles traveled (%[1]f)"
|
||||||
"ng!\x04\x00\x01\x0a0\x02Use the following code for your discount: %[1]d" +
|
|
||||||
"\x02%[1]s is out of order!\x02%.2[1]f miles traveled (%[1]f)"
|
|
||||||
|
|
||||||
var zhIndex = []uint32{ // 10 elements
|
var zhIndex = []uint32{ // 8 elements
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
0x00000000, 0x00000000,
|
} // Size: 56 bytes
|
||||||
} // Size: 64 bytes
|
|
||||||
|
|
||||||
const zhData string = ""
|
const zhData string = ""
|
||||||
|
|
||||||
// Total table size 603 bytes (0KiB); checksum: 1D2754EE
|
// Total table size 471 bytes (0KiB); checksum: 7746955
|
||||||
|
|
34
vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/de/messages.gotext.json
generated
vendored
34
vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/de/messages.gotext.json
generated
vendored
|
@ -2,17 +2,17 @@
|
||||||
"language": "de",
|
"language": "de",
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"id": "Hello world!",
|
"id": "Hello world!\n",
|
||||||
"key": "Hello world!\n",
|
"key": "Hello world!\n",
|
||||||
"message": "Hello world!",
|
"message": "Hello world!\n",
|
||||||
"translation": "Hallo Welt!",
|
"translation": "Hallo Welt!\n",
|
||||||
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:27:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:27:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Hello {City}!",
|
"id": "Hello {City}!\n",
|
||||||
"key": "Hello %s!\n",
|
"key": "Hello %s!\n",
|
||||||
"message": "Hello {City}!",
|
"message": "Hello {City}!\n",
|
||||||
"translation": "Hallo {City}!",
|
"translation": "Hallo {City}!\n",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "City",
|
"id": "City",
|
||||||
|
@ -26,10 +26,10 @@
|
||||||
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:31:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:31:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Hello {Town}!",
|
"id": "Hello {Town}!\n",
|
||||||
"key": "Hello %s!\n",
|
"key": "Hello %s!\n",
|
||||||
"message": "Hello {Town}!",
|
"message": "Hello {Town}!\n",
|
||||||
"translation": "Hallo {Town}!",
|
"translation": "Hallo {Town}!\n",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "Town",
|
"id": "Town",
|
||||||
|
@ -44,10 +44,10 @@
|
||||||
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:35:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:35:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Person} is visiting {Place}!",
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
"key": "%s is visiting %s!\n",
|
"key": "%s is visiting %s!\n",
|
||||||
"message": "{Person} is visiting {Place}!",
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
"translation": "{Person} besucht {Place}!",
|
"translation": "{Person} besucht {Place}!\n",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "Person",
|
"id": "Person",
|
||||||
|
@ -71,10 +71,10 @@
|
||||||
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:40:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:40:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Person} is visiting {Place}!",
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
"key": "%[1]s is visiting %[3]s!\n",
|
"key": "%[1]s is visiting %[3]s!\n",
|
||||||
"message": "{Person} is visiting {Place}!",
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
"translation": "{Person} besucht {Place}!",
|
"translation": "{Person} besucht {Place}!\n",
|
||||||
"comment": "Person visiting a place.",
|
"comment": "Person visiting a place.",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -123,9 +123,9 @@
|
||||||
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:67:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:67:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
"id": "Use the following code for your discount: {ReferralCode}\n",
|
||||||
"key": "Use the following code for your discount: %d\n",
|
"key": "Use the following code for your discount: %d\n",
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
"message": "Use the following code for your discount: {ReferralCode}\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
|
113
vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/de/out.gotext.json
generated
vendored
113
vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/de/out.gotext.json
generated
vendored
|
@ -2,14 +2,17 @@
|
||||||
"language": "de",
|
"language": "de",
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"id": "Hello world!",
|
"id": "Hello world!\n",
|
||||||
"message": "Hello world!",
|
"key": "Hello world!\n",
|
||||||
"translation": "Hallo Welt!"
|
"message": "Hello world!\n",
|
||||||
|
"translation": "",
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:28:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Hello {City}!",
|
"id": "Hello {City}!\n",
|
||||||
"message": "Hello {City}!",
|
"key": "Hello %s!\n",
|
||||||
"translation": "Hallo {City}!",
|
"message": "Hello {City}!\n",
|
||||||
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "City",
|
"id": "City",
|
||||||
|
@ -19,12 +22,32 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "city"
|
"expr": "city"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:32:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Person} is visiting {Place}!",
|
"id": "Hello {Town}!\n",
|
||||||
"message": "{Person} is visiting {Place}!",
|
"key": "Hello %s!\n",
|
||||||
"translation": "{Person} besucht {Place}!",
|
"message": "Hello {Town}!\n",
|
||||||
|
"translation": "",
|
||||||
|
"placeholders": [
|
||||||
|
{
|
||||||
|
"id": "Town",
|
||||||
|
"string": "%[1]s",
|
||||||
|
"type": "string",
|
||||||
|
"underlyingType": "string",
|
||||||
|
"argNum": 1,
|
||||||
|
"expr": "town",
|
||||||
|
"comment": "Town"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:36:10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
|
"key": "%s is visiting %s!\n",
|
||||||
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "Person",
|
"id": "Person",
|
||||||
|
@ -44,27 +67,66 @@
|
||||||
"expr": "place",
|
"expr": "place",
|
||||||
"comment": "Place the person is visiting."
|
"comment": "Place the person is visiting."
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:41:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{2} files remaining!",
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
"message": "{2} files remaining!",
|
"key": "%[1]s is visiting %[3]s!\n",
|
||||||
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
|
"translation": "",
|
||||||
|
"comment": "Person visiting a place.",
|
||||||
|
"placeholders": [
|
||||||
|
{
|
||||||
|
"id": "Person",
|
||||||
|
"string": "%[1]s",
|
||||||
|
"type": "string",
|
||||||
|
"underlyingType": "string",
|
||||||
|
"argNum": 1,
|
||||||
|
"expr": "pp.Person"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "Place",
|
||||||
|
"string": "%[3]s",
|
||||||
|
"type": "string",
|
||||||
|
"underlyingType": "string",
|
||||||
|
"argNum": 3,
|
||||||
|
"expr": "pp.Place",
|
||||||
|
"comment": "Place the person is visiting."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "Extra",
|
||||||
|
"string": "%[2]v",
|
||||||
|
"type": "int",
|
||||||
|
"underlyingType": "int",
|
||||||
|
"argNum": 2,
|
||||||
|
"expr": "pp.extra"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:56:10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "{} files remaining!",
|
||||||
|
"key": "%d files remaining!",
|
||||||
|
"message": "{} files remaining!",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "2",
|
"id": "",
|
||||||
"string": "%[1]d",
|
"string": "%[1]d",
|
||||||
"type": "int",
|
"type": "int",
|
||||||
"underlyingType": "int",
|
"underlyingType": "int",
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "2"
|
"expr": "2"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:63:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{N} more files remaining!",
|
"id": "{N} more files remaining!",
|
||||||
|
"key": "%d more files remaining!",
|
||||||
"message": "{N} more files remaining!",
|
"message": "{N} more files remaining!",
|
||||||
"translation": "Noch {N} Bestände zu gehen!",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "N",
|
"id": "N",
|
||||||
|
@ -74,11 +136,13 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "n"
|
"expr": "n"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:68:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
"id": "Use the following code for your discount: {ReferralCode}\n",
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
"key": "Use the following code for your discount: %d\n",
|
||||||
|
"message": "Use the following code for your discount: {ReferralCode}\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -89,13 +153,15 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "c"
|
"expr": "c"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:74:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": [
|
"id": [
|
||||||
"msgOutOfOrder",
|
"msgOutOfOrder",
|
||||||
"{Device} is out of order!"
|
"{Device} is out of order!"
|
||||||
],
|
],
|
||||||
|
"key": "%s is out of order!",
|
||||||
"message": "{Device} is out of order!",
|
"message": "{Device} is out of order!",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"comment": "FOO\n",
|
"comment": "FOO\n",
|
||||||
|
@ -108,10 +174,12 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "device"
|
"expr": "device"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:82:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
"id": "{Miles} miles traveled ({Miles_1})",
|
||||||
|
"key": "%.2[1]f miles traveled (%[1]f)",
|
||||||
"message": "{Miles} miles traveled ({Miles_1})",
|
"message": "{Miles} miles traveled ({Miles_1})",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
|
@ -131,7 +199,8 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "miles"
|
"expr": "miles"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:86:10"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
32
vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/en-US/messages.gotext.json
generated
vendored
32
vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/en-US/messages.gotext.json
generated
vendored
|
@ -2,23 +2,23 @@
|
||||||
"language": "en-US",
|
"language": "en-US",
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"id": "Hello world!",
|
"id": "Hello world!\n",
|
||||||
"key": "Hello world!\n",
|
"key": "Hello world!\n",
|
||||||
"message": "Hello world!",
|
"message": "Hello world!\n",
|
||||||
"translation": "Hello world!",
|
"translation": "Hello world!\n",
|
||||||
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:27:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:27:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Hello {City}!",
|
"id": "Hello {City}!\n",
|
||||||
"key": "Hello %s!\n",
|
"key": "Hello %s!\n",
|
||||||
"message": "Hello {City}!",
|
"message": "Hello {City}!\n",
|
||||||
"translation": "Hello {City}n"
|
"translation": "Hello {City}!\n"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Hello {Town}!",
|
"id": "Hello {Town}!\n",
|
||||||
"key": "Hello %s!\n",
|
"key": "Hello %s!\n",
|
||||||
"message": "Hello {Town}!",
|
"message": "Hello {Town}!\n",
|
||||||
"translation": "Hello {Town}!",
|
"translation": "Hello {Town}!\n",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "Town",
|
"id": "Town",
|
||||||
|
@ -32,16 +32,16 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Person} is visiting {Place}!",
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
"key": "%s is visiting %s!\n",
|
"key": "%s is visiting %s!\n",
|
||||||
"message": "{Person} is visiting {Place}!",
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
"translation": "{Person} is visiting {Place}!\n"
|
"translation": "{Person} is visiting {Place}!\n"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Person} is visiting {Place}!",
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
"key": "%[1]s is visiting %[3]s!\n",
|
"key": "%[1]s is visiting %[3]s!\n",
|
||||||
"message": "{Person} is visiting {Place}!",
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
"translation": "{Person} is visiting {Place}!",
|
"translation": "{Person} is visiting {Place}!\n",
|
||||||
"comment": "Person visiting a place."
|
"comment": "Person visiting a place."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -60,9 +60,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
"id": "Use the following code for your discount: {ReferralCode}\n",
|
||||||
"key": "Use the following code for your discount: %d\n",
|
"key": "Use the following code for your discount: %d\n",
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
"message": "Use the following code for your discount: {ReferralCode}\n",
|
||||||
"translation": ""
|
"translation": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
134
vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/en-US/out.gotext.json
generated
vendored
134
vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/en-US/out.gotext.json
generated
vendored
|
@ -2,14 +2,17 @@
|
||||||
"language": "en-US",
|
"language": "en-US",
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"id": "Hello world!",
|
"id": "Hello world!\n",
|
||||||
"message": "Hello world!",
|
"key": "Hello world!\n",
|
||||||
"translation": "Hello world!"
|
"message": "Hello world!\n",
|
||||||
|
"translation": "",
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:28:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Hello {City}!",
|
"id": "Hello {City}!\n",
|
||||||
"message": "Hello {City}!",
|
"key": "Hello %s!\n",
|
||||||
"translation": "Hello {City}n",
|
"message": "Hello {City}!\n",
|
||||||
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "City",
|
"id": "City",
|
||||||
|
@ -19,12 +22,32 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "city"
|
"expr": "city"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:32:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Person} is visiting {Place}!",
|
"id": "Hello {Town}!\n",
|
||||||
"message": "{Person} is visiting {Place}!",
|
"key": "Hello %s!\n",
|
||||||
"translation": "{Person} is visiting {Place}!",
|
"message": "Hello {Town}!\n",
|
||||||
|
"translation": "",
|
||||||
|
"placeholders": [
|
||||||
|
{
|
||||||
|
"id": "Town",
|
||||||
|
"string": "%[1]s",
|
||||||
|
"type": "string",
|
||||||
|
"underlyingType": "string",
|
||||||
|
"argNum": 1,
|
||||||
|
"expr": "town",
|
||||||
|
"comment": "Town"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:36:10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
|
"key": "%s is visiting %s!\n",
|
||||||
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "Person",
|
"id": "Person",
|
||||||
|
@ -44,16 +67,52 @@
|
||||||
"expr": "place",
|
"expr": "place",
|
||||||
"comment": "Place the person is visiting."
|
"comment": "Place the person is visiting."
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:41:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{2} files remaining!",
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
"message": "{2} files remaining!",
|
"key": "%[1]s is visiting %[3]s!\n",
|
||||||
"translation": "{2} files remaining!",
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
"translatorComment": "Copied from source.",
|
"translation": "",
|
||||||
|
"comment": "Person visiting a place.",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "2",
|
"id": "Person",
|
||||||
|
"string": "%[1]s",
|
||||||
|
"type": "string",
|
||||||
|
"underlyingType": "string",
|
||||||
|
"argNum": 1,
|
||||||
|
"expr": "pp.Person"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "Place",
|
||||||
|
"string": "%[3]s",
|
||||||
|
"type": "string",
|
||||||
|
"underlyingType": "string",
|
||||||
|
"argNum": 3,
|
||||||
|
"expr": "pp.Place",
|
||||||
|
"comment": "Place the person is visiting."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "Extra",
|
||||||
|
"string": "%[2]v",
|
||||||
|
"type": "int",
|
||||||
|
"underlyingType": "int",
|
||||||
|
"argNum": 2,
|
||||||
|
"expr": "pp.extra"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:56:10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "{} files remaining!",
|
||||||
|
"key": "%d files remaining!",
|
||||||
|
"message": "{} files remaining!",
|
||||||
|
"translation": "",
|
||||||
|
"placeholders": [
|
||||||
|
{
|
||||||
|
"id": "",
|
||||||
"string": "%[1]d",
|
"string": "%[1]d",
|
||||||
"type": "int",
|
"type": "int",
|
||||||
"underlyingType": "int",
|
"underlyingType": "int",
|
||||||
|
@ -61,25 +120,13 @@
|
||||||
"expr": "2"
|
"expr": "2"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"fuzzy": true
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:63:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{N} more files remaining!",
|
"id": "{N} more files remaining!",
|
||||||
|
"key": "%d more files remaining!",
|
||||||
"message": "{N} more files remaining!",
|
"message": "{N} more files remaining!",
|
||||||
"translation": {
|
"translation": "",
|
||||||
"select": {
|
|
||||||
"feature": "plural",
|
|
||||||
"arg": "N",
|
|
||||||
"cases": {
|
|
||||||
"one": {
|
|
||||||
"msg": "One file remaining!"
|
|
||||||
},
|
|
||||||
"other": {
|
|
||||||
"msg": "There are {N} more files remaining!"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "N",
|
"id": "N",
|
||||||
|
@ -89,13 +136,14 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "n"
|
"expr": "n"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:68:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
"id": "Use the following code for your discount: {ReferralCode}\n",
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
"key": "Use the following code for your discount: %d\n",
|
||||||
"translation": "Use the following code for your discount: {ReferralCode}",
|
"message": "Use the following code for your discount: {ReferralCode}\n",
|
||||||
"translatorComment": "Copied from source.",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "ReferralCode",
|
"id": "ReferralCode",
|
||||||
|
@ -106,15 +154,16 @@
|
||||||
"expr": "c"
|
"expr": "c"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"fuzzy": true
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:74:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": [
|
"id": [
|
||||||
"msgOutOfOrder",
|
"msgOutOfOrder",
|
||||||
"{Device} is out of order!"
|
"{Device} is out of order!"
|
||||||
],
|
],
|
||||||
|
"key": "%s is out of order!",
|
||||||
"message": "{Device} is out of order!",
|
"message": "{Device} is out of order!",
|
||||||
"translation": "{Device} is out of order!",
|
"translation": "",
|
||||||
"comment": "FOO\n",
|
"comment": "FOO\n",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -125,12 +174,14 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "device"
|
"expr": "device"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:82:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
"id": "{Miles} miles traveled ({Miles_1})",
|
||||||
|
"key": "%.2[1]f miles traveled (%[1]f)",
|
||||||
"message": "{Miles} miles traveled ({Miles_1})",
|
"message": "{Miles} miles traveled ({Miles_1})",
|
||||||
"translation": "{Miles} miles traveled ({Miles_1})",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "Miles",
|
"id": "Miles",
|
||||||
|
@ -148,7 +199,8 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "miles"
|
"expr": "miles"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:86:10"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
68
vendor/golang.org/x/text/message/pipeline/testdata/test1/extracted.gotext.json → vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/extracted.gotext.json
generated
vendored
Normal file → Executable file
68
vendor/golang.org/x/text/message/pipeline/testdata/test1/extracted.gotext.json → vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/extracted.gotext.json
generated
vendored
Normal file → Executable file
|
@ -2,16 +2,16 @@
|
||||||
"language": "en-US",
|
"language": "en-US",
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"id": "Hello world!",
|
"id": "Hello world!\n",
|
||||||
"key": "Hello world!\n",
|
"key": "Hello world!\n",
|
||||||
"message": "Hello world!",
|
"message": "Hello world!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"position": "testdata/test1/test1.go:19:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:28:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Hello {City}!",
|
"id": "Hello {City}!\n",
|
||||||
"key": "Hello %s!\n",
|
"key": "Hello %s!\n",
|
||||||
"message": "Hello {City}!",
|
"message": "Hello {City}!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -23,12 +23,30 @@
|
||||||
"expr": "city"
|
"expr": "city"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"position": "testdata/test1/test1.go:24:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:32:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Person} is visiting {Place}!",
|
"id": "Hello {Town}!\n",
|
||||||
|
"key": "Hello %s!\n",
|
||||||
|
"message": "Hello {Town}!\n",
|
||||||
|
"translation": "",
|
||||||
|
"placeholders": [
|
||||||
|
{
|
||||||
|
"id": "Town",
|
||||||
|
"string": "%[1]s",
|
||||||
|
"type": "string",
|
||||||
|
"underlyingType": "string",
|
||||||
|
"argNum": 1,
|
||||||
|
"expr": "town",
|
||||||
|
"comment": "Town"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:36:10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
"key": "%s is visiting %s!\n",
|
"key": "%s is visiting %s!\n",
|
||||||
"message": "{Person} is visiting {Place}!",
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -50,14 +68,14 @@
|
||||||
"comment": "Place the person is visiting."
|
"comment": "Place the person is visiting."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"position": "testdata/test1/test1.go:30:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:41:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Person} is visiting {Place}!",
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
"key": "%[1]s is visiting %[3]s!\n",
|
"key": "%[1]s is visiting %[3]s!\n",
|
||||||
"message": "{Person} is visiting {Place}!",
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"comment": "Field names are placeholders.",
|
"comment": "Person visiting a place.",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "Person",
|
"id": "Person",
|
||||||
|
@ -85,16 +103,16 @@
|
||||||
"expr": "pp.extra"
|
"expr": "pp.extra"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"position": "testdata/test1/test1.go:44:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:56:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{2} files remaining!",
|
"id": "{} files remaining!",
|
||||||
"key": "%d files remaining!",
|
"key": "%d files remaining!",
|
||||||
"message": "{2} files remaining!",
|
"message": "{} files remaining!",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "2",
|
"id": "",
|
||||||
"string": "%[1]d",
|
"string": "%[1]d",
|
||||||
"type": "int",
|
"type": "int",
|
||||||
"underlyingType": "int",
|
"underlyingType": "int",
|
||||||
|
@ -102,7 +120,7 @@
|
||||||
"expr": "2"
|
"expr": "2"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"position": "testdata/test1/test1.go:51:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:63:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{N} more files remaining!",
|
"id": "{N} more files remaining!",
|
||||||
|
@ -119,24 +137,24 @@
|
||||||
"expr": "n"
|
"expr": "n"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"position": "testdata/test1/test1.go:56:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:68:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
"id": "Use the following code for your discount: {ReferralCode}\n",
|
||||||
"key": "Use the following code for your discount: %d\n",
|
"key": "Use the following code for your discount: %d\n",
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
"message": "Use the following code for your discount: {ReferralCode}\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "ReferralCode",
|
"id": "ReferralCode",
|
||||||
"string": "%[1]d",
|
"string": "%[1]d",
|
||||||
"type": "./testdata/test1.referralCode",
|
"type": "golang.org/x/text/cmd/gotext/examples/extract.referralCode",
|
||||||
"underlyingType": "int",
|
"underlyingType": "int",
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "c"
|
"expr": "c"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"position": "testdata/test1/test1.go:64:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:74:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": [
|
"id": [
|
||||||
|
@ -146,7 +164,7 @@
|
||||||
"key": "%s is out of order!",
|
"key": "%s is out of order!",
|
||||||
"message": "{Device} is out of order!",
|
"message": "{Device} is out of order!",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"comment": "This comment wins.\n",
|
"comment": "FOO\n",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "Device",
|
"id": "Device",
|
||||||
|
@ -157,7 +175,7 @@
|
||||||
"expr": "device"
|
"expr": "device"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"position": "testdata/test1/test1.go:70:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:82:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
"id": "{Miles} miles traveled ({Miles_1})",
|
||||||
|
@ -182,7 +200,7 @@
|
||||||
"expr": "miles"
|
"expr": "miles"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"position": "testdata/test1/test1.go:74:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:86:10"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
20
vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/zh/messages.gotext.json
generated
vendored
20
vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/zh/messages.gotext.json
generated
vendored
|
@ -2,16 +2,16 @@
|
||||||
"language": "zh",
|
"language": "zh",
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"id": "Hello world!",
|
"id": "Hello world!\n",
|
||||||
"key": "Hello world!\n",
|
"key": "Hello world!\n",
|
||||||
"message": "Hello world!",
|
"message": "Hello world!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:27:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:27:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Hello {City}!",
|
"id": "Hello {City}!\n",
|
||||||
"key": "Hello %s!\n",
|
"key": "Hello %s!\n",
|
||||||
"message": "Hello {City}!",
|
"message": "Hello {City}!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -26,9 +26,9 @@
|
||||||
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:31:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:31:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Hello {Town}!",
|
"id": "Hello {Town}!\n",
|
||||||
"key": "Hello %s!\n",
|
"key": "Hello %s!\n",
|
||||||
"message": "Hello {Town}!",
|
"message": "Hello {Town}!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -44,9 +44,9 @@
|
||||||
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:35:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:35:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Person} is visiting {Place}!",
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
"key": "%s is visiting %s!\n",
|
"key": "%s is visiting %s!\n",
|
||||||
"message": "{Person} is visiting {Place}!",
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -71,9 +71,9 @@
|
||||||
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:40:10"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:40:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Person} is visiting {Place}!",
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
"key": "%[1]s is visiting %[3]s!\n",
|
"key": "%[1]s is visiting %[3]s!\n",
|
||||||
"message": "{Person} is visiting {Place}!",
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"comment": "Person visiting a place.",
|
"comment": "Person visiting a place.",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
|
|
107
vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/zh/out.gotext.json
generated
vendored
107
vendor/golang.org/x/text/cmd/gotext/examples/extract/locales/zh/out.gotext.json
generated
vendored
|
@ -2,13 +2,16 @@
|
||||||
"language": "zh",
|
"language": "zh",
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"id": "Hello world!",
|
"id": "Hello world!\n",
|
||||||
"message": "Hello world!",
|
"key": "Hello world!\n",
|
||||||
"translation": ""
|
"message": "Hello world!\n",
|
||||||
|
"translation": "",
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:28:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Hello {City}!",
|
"id": "Hello {City}!\n",
|
||||||
"message": "Hello {City}!",
|
"key": "Hello %s!\n",
|
||||||
|
"message": "Hello {City}!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -19,11 +22,31 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "city"
|
"expr": "city"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:32:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Person} is visiting {Place}!",
|
"id": "Hello {Town}!\n",
|
||||||
"message": "{Person} is visiting {Place}!",
|
"key": "Hello %s!\n",
|
||||||
|
"message": "Hello {Town}!\n",
|
||||||
|
"translation": "",
|
||||||
|
"placeholders": [
|
||||||
|
{
|
||||||
|
"id": "Town",
|
||||||
|
"string": "%[1]s",
|
||||||
|
"type": "string",
|
||||||
|
"underlyingType": "string",
|
||||||
|
"argNum": 1,
|
||||||
|
"expr": "town",
|
||||||
|
"comment": "Town"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:36:10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
|
"key": "%s is visiting %s!\n",
|
||||||
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -44,25 +67,64 @@
|
||||||
"expr": "place",
|
"expr": "place",
|
||||||
"comment": "Place the person is visiting."
|
"comment": "Place the person is visiting."
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:41:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{2} files remaining!",
|
"id": "{Person} is visiting {Place}!\n",
|
||||||
"message": "{2} files remaining!",
|
"key": "%[1]s is visiting %[3]s!\n",
|
||||||
|
"message": "{Person} is visiting {Place}!\n",
|
||||||
|
"translation": "",
|
||||||
|
"comment": "Person visiting a place.",
|
||||||
|
"placeholders": [
|
||||||
|
{
|
||||||
|
"id": "Person",
|
||||||
|
"string": "%[1]s",
|
||||||
|
"type": "string",
|
||||||
|
"underlyingType": "string",
|
||||||
|
"argNum": 1,
|
||||||
|
"expr": "pp.Person"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "Place",
|
||||||
|
"string": "%[3]s",
|
||||||
|
"type": "string",
|
||||||
|
"underlyingType": "string",
|
||||||
|
"argNum": 3,
|
||||||
|
"expr": "pp.Place",
|
||||||
|
"comment": "Place the person is visiting."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "Extra",
|
||||||
|
"string": "%[2]v",
|
||||||
|
"type": "int",
|
||||||
|
"underlyingType": "int",
|
||||||
|
"argNum": 2,
|
||||||
|
"expr": "pp.extra"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:56:10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "{} files remaining!",
|
||||||
|
"key": "%d files remaining!",
|
||||||
|
"message": "{} files remaining!",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "2",
|
"id": "",
|
||||||
"string": "%[1]d",
|
"string": "%[1]d",
|
||||||
"type": "int",
|
"type": "int",
|
||||||
"underlyingType": "int",
|
"underlyingType": "int",
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "2"
|
"expr": "2"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:63:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{N} more files remaining!",
|
"id": "{N} more files remaining!",
|
||||||
|
"key": "%d more files remaining!",
|
||||||
"message": "{N} more files remaining!",
|
"message": "{N} more files remaining!",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
|
@ -74,11 +136,13 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "n"
|
"expr": "n"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:68:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
"id": "Use the following code for your discount: {ReferralCode}\n",
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
"key": "Use the following code for your discount: %d\n",
|
||||||
|
"message": "Use the following code for your discount: {ReferralCode}\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -89,13 +153,15 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "c"
|
"expr": "c"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:74:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": [
|
"id": [
|
||||||
"msgOutOfOrder",
|
"msgOutOfOrder",
|
||||||
"{Device} is out of order!"
|
"{Device} is out of order!"
|
||||||
],
|
],
|
||||||
|
"key": "%s is out of order!",
|
||||||
"message": "{Device} is out of order!",
|
"message": "{Device} is out of order!",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"comment": "FOO\n",
|
"comment": "FOO\n",
|
||||||
|
@ -108,10 +174,12 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "device"
|
"expr": "device"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:82:10"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
"id": "{Miles} miles traveled ({Miles_1})",
|
||||||
|
"key": "%.2[1]f miles traveled (%[1]f)",
|
||||||
"message": "{Miles} miles traveled ({Miles_1})",
|
"message": "{Miles} miles traveled ({Miles_1})",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
|
@ -131,7 +199,8 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "miles"
|
"expr": "miles"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:86:10"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
3
vendor/golang.org/x/text/cmd/gotext/examples/extract/main.go
generated
vendored
3
vendor/golang.org/x/text/cmd/gotext/examples/extract/main.go
generated
vendored
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
//go:generate gotext update -out catalog.go
|
//go:generate gotext extract --lang=de,zh
|
||||||
|
//go:generate gotext generate -out catalog.go
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"golang.org/x/text/language"
|
"golang.org/x/text/language"
|
||||||
|
|
57
vendor/golang.org/x/text/cmd/gotext/examples/extract_http/catalog_gen.go
generated
vendored
57
vendor/golang.org/x/text/cmd/gotext/examples/extract_http/catalog_gen.go
generated
vendored
|
@ -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
|
|
8
vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/de/out.gotext.json
generated
vendored
8
vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/de/out.gotext.json
generated
vendored
|
@ -2,9 +2,9 @@
|
||||||
"language": "de",
|
"language": "de",
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"id": "Hello {From}!",
|
"id": "Hello {From}!\n",
|
||||||
"key": "Hello %s!\n",
|
"key": "Hello %s!\n",
|
||||||
"message": "Hello {From}!",
|
"message": "Hello {From}!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -19,9 +19,9 @@
|
||||||
"position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:22:11"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:22:11"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Do you like your browser ({User_Agent})?",
|
"id": "Do you like your browser ({User_Agent})?\n",
|
||||||
"key": "Do you like your browser (%s)?\n",
|
"key": "Do you like your browser (%s)?\n",
|
||||||
"message": "Do you like your browser ({User_Agent})?",
|
"message": "Do you like your browser ({User_Agent})?\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
"language": "en-US",
|
"language": "en-US",
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"id": "Hello {From}!",
|
"id": "Hello {From}!\n",
|
||||||
"key": "Hello %s!\n",
|
"key": "Hello %s!\n",
|
||||||
"message": "Hello {From}!",
|
"message": "Hello {From}!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -19,9 +19,9 @@
|
||||||
"position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:22:11"
|
"position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:22:11"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Do you like your browser ({User_Agent})?",
|
"id": "Do you like your browser ({User_Agent})?\n",
|
||||||
"key": "Do you like your browser (%s)?\n",
|
"key": "Do you like your browser (%s)?\n",
|
||||||
"message": "Do you like your browser ({User_Agent})?",
|
"message": "Do you like your browser ({User_Agent})?\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
|
22
vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/en/out.gotext.json → vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/extracted.gotext.json
generated
vendored
Normal file → Executable file
22
vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/en/out.gotext.json → vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/extracted.gotext.json
generated
vendored
Normal file → Executable file
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"language": "en",
|
"language": "en-US",
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"id": "Hello {From}!",
|
"id": "Hello {From}!\n",
|
||||||
"message": "Hello {From}!",
|
"key": "Hello %s!\n",
|
||||||
"translation": "Hello {From}!",
|
"message": "Hello {From}!\n",
|
||||||
"translatorComment": "Copied from source.",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "From",
|
"id": "From",
|
||||||
|
@ -16,13 +16,13 @@
|
||||||
"expr": "r.Header.Get(\"From\")"
|
"expr": "r.Header.Get(\"From\")"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"fuzzy": true
|
"position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:22:11"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Do you like your browser ({User_Agent})?",
|
"id": "Do you like your browser ({User_Agent})?\n",
|
||||||
"message": "Do you like your browser ({User_Agent})?",
|
"key": "Do you like your browser (%s)?\n",
|
||||||
"translation": "Do you like your browser ({User_Agent})?",
|
"message": "Do you like your browser ({User_Agent})?\n",
|
||||||
"translatorComment": "Copied from source.",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
"id": "User_Agent",
|
"id": "User_Agent",
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
"expr": "r.Header.Get(\"User-Agent\")"
|
"expr": "r.Header.Get(\"User-Agent\")"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"fuzzy": true
|
"position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:24:11"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
16
vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/zh/out.gotext.json
generated
vendored
16
vendor/golang.org/x/text/cmd/gotext/examples/extract_http/locales/zh/out.gotext.json
generated
vendored
|
@ -2,8 +2,9 @@
|
||||||
"language": "zh",
|
"language": "zh",
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"id": "Hello {From}!",
|
"id": "Hello {From}!\n",
|
||||||
"message": "Hello {From}!",
|
"key": "Hello %s!\n",
|
||||||
|
"message": "Hello {From}!\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -14,11 +15,13 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "r.Header.Get(\"From\")"
|
"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})?",
|
"id": "Do you like your browser ({User_Agent})?\n",
|
||||||
"message": "Do you like your browser ({User_Agent})?",
|
"key": "Do you like your browser (%s)?\n",
|
||||||
|
"message": "Do you like your browser ({User_Agent})?\n",
|
||||||
"translation": "",
|
"translation": "",
|
||||||
"placeholders": [
|
"placeholders": [
|
||||||
{
|
{
|
||||||
|
@ -29,7 +32,8 @@
|
||||||
"argNum": 1,
|
"argNum": 1,
|
||||||
"expr": "r.Header.Get(\"User-Agent\")"
|
"expr": "r.Header.Get(\"User-Agent\")"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:24:11"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
2
vendor/golang.org/x/text/cmd/gotext/examples/extract_http/main.go
generated
vendored
2
vendor/golang.org/x/text/cmd/gotext/examples/extract_http/main.go
generated
vendored
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
//go:generate gotext -srclang=en update -out=catalog_gen.go -lang=en,zh
|
//go:generate gotext extract --lang=de,zh
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
59
vendor/golang.org/x/text/cmd/gotext/extract.go
generated
vendored
59
vendor/golang.org/x/text/cmd/gotext/extract.go
generated
vendored
|
@ -5,6 +5,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"golang.org/x/text/internal"
|
||||||
|
"golang.org/x/text/language"
|
||||||
"golang.org/x/text/message/pipeline"
|
"golang.org/x/text/message/pipeline"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,7 +21,13 @@ import (
|
||||||
// - handle features (gender, plural)
|
// - handle features (gender, plural)
|
||||||
// - message rewriting
|
// - message rewriting
|
||||||
|
|
||||||
|
var (
|
||||||
|
srcLang *string
|
||||||
|
lang *string
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
srcLang = cmdExtract.Flag.String("srclang", "en-US", "the source-code language")
|
||||||
lang = cmdExtract.Flag.String("lang", "en-US", "comma-separated list of languages to process")
|
lang = cmdExtract.Flag.String("lang", "en-US", "comma-separated list of languages to process")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,17 +37,45 @@ var cmdExtract = &Command{
|
||||||
Short: "extracts strings to be translated from code",
|
Short: "extracts strings to be translated from code",
|
||||||
}
|
}
|
||||||
|
|
||||||
func runExtract(cmd *Command, config *pipeline.Config, args []string) error {
|
func runExtract(cmd *Command, args []string) error {
|
||||||
config.Packages = args
|
tag, err := language.Parse(*srcLang)
|
||||||
state, err := pipeline.Extract(config)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return wrap(err, "extract failed")
|
return wrap(err, "")
|
||||||
}
|
}
|
||||||
if err := state.Import(); err != nil {
|
config := &pipeline.Config{
|
||||||
return wrap(err, "import failed")
|
SourceLanguage: tag,
|
||||||
|
Packages: args,
|
||||||
}
|
}
|
||||||
if err := state.Merge(); err != nil {
|
out, err := pipeline.Extract(config)
|
||||||
return wrap(err, "merge failed")
|
|
||||||
|
data, err := json.MarshalIndent(out, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
return wrap(err, "")
|
||||||
}
|
}
|
||||||
return wrap(state.Export(), "export failed")
|
os.MkdirAll(*dir, 0755)
|
||||||
|
// TODO: this file can probably go if we replace the extract + generate
|
||||||
|
// cycle with a init once and update cycle.
|
||||||
|
file := filepath.Join(*dir, extractFile)
|
||||||
|
if err := ioutil.WriteFile(file, data, 0644); err != nil {
|
||||||
|
return wrap(err, "could not create file")
|
||||||
|
}
|
||||||
|
|
||||||
|
langs := append(getLangs(), tag)
|
||||||
|
langs = internal.UniqueTags(langs)
|
||||||
|
for _, tag := range langs {
|
||||||
|
// TODO: inject translations from existing files to avoid retranslation.
|
||||||
|
out.Language = tag
|
||||||
|
data, err := json.MarshalIndent(out, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
return wrap(err, "JSON marshal failed")
|
||||||
|
}
|
||||||
|
file := filepath.Join(*dir, tag.String(), outFile)
|
||||||
|
if err := os.MkdirAll(filepath.Dir(file), 0750); err != nil {
|
||||||
|
return wrap(err, "dir create failed")
|
||||||
|
}
|
||||||
|
if err := ioutil.WriteFile(file, data, 0740); err != nil {
|
||||||
|
return wrap(err, "write failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
87
vendor/golang.org/x/text/cmd/gotext/generate.go
generated
vendored
87
vendor/golang.org/x/text/cmd/gotext/generate.go
generated
vendored
|
@ -5,27 +5,100 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/text/message/pipeline"
|
"golang.org/x/text/message/pipeline"
|
||||||
|
"golang.org/x/tools/go/loader"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
out = cmdGenerate.Flag.String("out", "", "output file to write to")
|
out = cmdGenerate.Flag.String("out", "", "output file to write to")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
out *string
|
||||||
|
)
|
||||||
|
|
||||||
var cmdGenerate = &Command{
|
var cmdGenerate = &Command{
|
||||||
Run: runGenerate,
|
Run: runGenerate,
|
||||||
UsageLine: "generate <package>",
|
UsageLine: "generate <package>",
|
||||||
Short: "generates code to insert translated messages",
|
Short: "generates code to insert translated messages",
|
||||||
}
|
}
|
||||||
|
|
||||||
func runGenerate(cmd *Command, config *pipeline.Config, args []string) error {
|
var transRe = regexp.MustCompile(`messages\.(.*)\.json`)
|
||||||
config.Packages = args
|
|
||||||
s, err := pipeline.Extract(config)
|
func runGenerate(cmd *Command, args []string) error {
|
||||||
|
|
||||||
|
prog, err := loadPackages(&loader.Config{}, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return wrap(err, "extraction failed")
|
return wrap(err, "could not load package")
|
||||||
}
|
}
|
||||||
if err := s.Import(); err != nil {
|
|
||||||
return wrap(err, "import failed")
|
pkgs := prog.InitialPackages()
|
||||||
|
if len(pkgs) != 1 {
|
||||||
|
return fmt.Errorf("more than one package selected: %v", pkgs)
|
||||||
}
|
}
|
||||||
return wrap(s.Generate(), "generation failed")
|
pkg := pkgs[0].Pkg.Name()
|
||||||
|
|
||||||
|
// TODO: add in external input. Right now we assume that all files are
|
||||||
|
// manually created and stored in the textdata directory.
|
||||||
|
|
||||||
|
// Build up index of translations and original messages.
|
||||||
|
extracted := pipeline.Locale{}
|
||||||
|
translations := []*pipeline.Locale{}
|
||||||
|
|
||||||
|
err = filepath.Walk(*dir, func(path string, f os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return wrap(err, "loading data")
|
||||||
|
}
|
||||||
|
if f.IsDir() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if f.Name() == extractFile {
|
||||||
|
b, err := ioutil.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return wrap(err, "read file failed")
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(b, &extracted); err != nil {
|
||||||
|
return wrap(err, "unmarshal source failed")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if f.Name() == outFile {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if !strings.HasSuffix(path, gotextSuffix) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
b, err := ioutil.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return wrap(err, "read file failed")
|
||||||
|
}
|
||||||
|
var locale pipeline.Locale
|
||||||
|
if err := json.Unmarshal(b, &locale); err != nil {
|
||||||
|
return wrap(err, "parsing translation file failed")
|
||||||
|
}
|
||||||
|
translations = append(translations, &locale)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
w := os.Stdout
|
||||||
|
if *out != "" {
|
||||||
|
w, err = os.Create(*out)
|
||||||
|
if err != nil {
|
||||||
|
return wrap(err, "create file failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = pipeline.Generate(w, pkg, &extracted, translations...)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
29
vendor/golang.org/x/text/cmd/gotext/main.go
generated
vendored
29
vendor/golang.org/x/text/cmd/gotext/main.go
generated
vendored
|
@ -25,8 +25,6 @@ import (
|
||||||
"unicode"
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"golang.org/x/text/message/pipeline"
|
|
||||||
|
|
||||||
"golang.org/x/text/language"
|
"golang.org/x/text/language"
|
||||||
"golang.org/x/tools/go/buildutil"
|
"golang.org/x/tools/go/buildutil"
|
||||||
)
|
)
|
||||||
|
@ -35,23 +33,7 @@ func init() {
|
||||||
flag.Var((*buildutil.TagsFlag)(&build.Default.BuildTags), "tags", buildutil.TagsFlagDoc)
|
flag.Var((*buildutil.TagsFlag)(&build.Default.BuildTags), "tags", buildutil.TagsFlagDoc)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var dir = flag.String("dir", "locales", "default subdirectory to store translation files")
|
||||||
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.
|
// NOTE: the Command struct is copied from the go tool in core.
|
||||||
|
|
||||||
|
@ -60,7 +42,7 @@ func config() (*pipeline.Config, error) {
|
||||||
type Command struct {
|
type Command struct {
|
||||||
// Run runs the command.
|
// Run runs the command.
|
||||||
// The args are the arguments after the command name.
|
// The args are the arguments after the command name.
|
||||||
Run func(cmd *Command, c *pipeline.Config, args []string) error
|
Run func(cmd *Command, args []string) error
|
||||||
|
|
||||||
// UsageLine is the one-line usage message.
|
// UsageLine is the one-line usage message.
|
||||||
// The first word in the line is taken to be the command name.
|
// The first word in the line is taken to be the command name.
|
||||||
|
@ -101,7 +83,6 @@ func (c *Command) Runnable() bool {
|
||||||
// Commands lists the available commands and help topics.
|
// Commands lists the available commands and help topics.
|
||||||
// The order here is the order in which they are printed by 'go help'.
|
// The order here is the order in which they are printed by 'go help'.
|
||||||
var commands = []*Command{
|
var commands = []*Command{
|
||||||
cmdUpdate,
|
|
||||||
cmdExtract,
|
cmdExtract,
|
||||||
cmdRewrite,
|
cmdRewrite,
|
||||||
cmdGenerate,
|
cmdGenerate,
|
||||||
|
@ -143,11 +124,7 @@ func main() {
|
||||||
cmd.Flag.Usage = func() { cmd.Usage() }
|
cmd.Flag.Usage = func() { cmd.Usage() }
|
||||||
cmd.Flag.Parse(args[1:])
|
cmd.Flag.Parse(args[1:])
|
||||||
args = cmd.Flag.Args()
|
args = cmd.Flag.Args()
|
||||||
config, err := config()
|
if err := cmd.Run(cmd, args); err != nil {
|
||||||
if err != nil {
|
|
||||||
fatalf("gotext: %+v", err)
|
|
||||||
}
|
|
||||||
if err := cmd.Run(cmd, config, args); err != nil {
|
|
||||||
fatalf("gotext: %+v", err)
|
fatalf("gotext: %+v", err)
|
||||||
}
|
}
|
||||||
exit()
|
exit()
|
||||||
|
|
2
vendor/golang.org/x/text/cmd/gotext/rewrite.go
generated
vendored
2
vendor/golang.org/x/text/cmd/gotext/rewrite.go
generated
vendored
|
@ -38,7 +38,7 @@ using Printf to allow translators to reorder arguments.
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
func runRewrite(cmd *Command, _ *pipeline.Config, args []string) error {
|
func runRewrite(cmd *Command, args []string) error {
|
||||||
w := os.Stdout
|
w := os.Stdout
|
||||||
if *overwrite {
|
if *overwrite {
|
||||||
w = nil
|
w = nil
|
||||||
|
|
52
vendor/golang.org/x/text/cmd/gotext/update.go
generated
vendored
52
vendor/golang.org/x/text/cmd/gotext/update.go
generated
vendored
|
@ -1,52 +0,0 @@
|
||||||
// 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 (
|
|
||||||
"golang.org/x/text/message/pipeline"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// - merge information into existing files
|
|
||||||
// - handle different file formats (PO, XLIFF)
|
|
||||||
// - handle features (gender, plural)
|
|
||||||
// - message rewriting
|
|
||||||
|
|
||||||
var (
|
|
||||||
lang *string
|
|
||||||
out *string
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
lang = cmdUpdate.Flag.String("lang", "en-US", "comma-separated list of languages to process")
|
|
||||||
out = cmdUpdate.Flag.String("out", "", "output file to write to")
|
|
||||||
}
|
|
||||||
|
|
||||||
var cmdUpdate = &Command{
|
|
||||||
Run: runUpdate,
|
|
||||||
UsageLine: "update <package>* [-out <gofile>]",
|
|
||||||
Short: "merge translations and generate catalog",
|
|
||||||
}
|
|
||||||
|
|
||||||
func runUpdate(cmd *Command, config *pipeline.Config, args []string) error {
|
|
||||||
config.Packages = args
|
|
||||||
state, err := pipeline.Extract(config)
|
|
||||||
if err != nil {
|
|
||||||
return wrap(err, "extract failed")
|
|
||||||
}
|
|
||||||
if err := state.Import(); err != nil {
|
|
||||||
return wrap(err, "import failed")
|
|
||||||
}
|
|
||||||
if err := state.Merge(); err != nil {
|
|
||||||
return wrap(err, "merge failed")
|
|
||||||
}
|
|
||||||
if err := state.Export(); err != nil {
|
|
||||||
return wrap(err, "export failed")
|
|
||||||
}
|
|
||||||
if *out != "" {
|
|
||||||
return wrap(state.Generate(), "generation failed")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
4
vendor/golang.org/x/text/currency/example_test.go
generated
vendored
4
vendor/golang.org/x/text/currency/example_test.go
generated
vendored
|
@ -16,12 +16,12 @@ func ExampleQuery() {
|
||||||
for it := currency.Query(currency.Date(t1799)); it.Next(); {
|
for it := currency.Query(currency.Date(t1799)); it.Next(); {
|
||||||
from := ""
|
from := ""
|
||||||
if t, ok := it.From(); ok {
|
if t, ok := it.From(); ok {
|
||||||
from = t.Format("2006-01-02")
|
from = t.Format("2006-01-01")
|
||||||
}
|
}
|
||||||
fmt.Printf("%v is used in %v since: %v\n", it.Unit(), it.Region(), from)
|
fmt.Printf("%v is used in %v since: %v\n", it.Unit(), it.Region(), from)
|
||||||
}
|
}
|
||||||
// Output:
|
// Output:
|
||||||
// GBP is used in GB since: 1694-07-27
|
// GBP is used in GB since: 1694-07-07
|
||||||
// GIP is used in GI since: 1713-01-01
|
// GIP is used in GI since: 1713-01-01
|
||||||
// USD is used in US since: 1792-01-01
|
// USD is used in US since: 1792-01-01
|
||||||
}
|
}
|
||||||
|
|
43
vendor/golang.org/x/text/internal/catmsg/catmsg.go
generated
vendored
43
vendor/golang.org/x/text/internal/catmsg/catmsg.go
generated
vendored
|
@ -104,24 +104,20 @@ const (
|
||||||
msgFirst
|
msgFirst
|
||||||
msgRaw
|
msgRaw
|
||||||
msgString
|
msgString
|
||||||
msgAffix
|
numFixed
|
||||||
// Leave some arbitrary room for future expansion: 20 should suffice.
|
|
||||||
numInternal = 20
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const prefix = "golang.org/x/text/internal/catmsg."
|
const prefix = "golang.org/x/text/internal/catmsg."
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// TODO: find a more stable way to link handles to message types.
|
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
names = map[string]Handle{
|
names = map[string]Handle{
|
||||||
prefix + "Vars": msgVars,
|
prefix + "Vars": msgVars,
|
||||||
prefix + "First": msgFirst,
|
prefix + "First": msgFirst,
|
||||||
prefix + "Raw": msgRaw,
|
prefix + "Raw": msgRaw,
|
||||||
prefix + "String": msgString,
|
prefix + "String": msgString,
|
||||||
prefix + "Affix": msgAffix,
|
|
||||||
}
|
}
|
||||||
handlers = make([]Handler, numInternal)
|
handlers = make([]Handler, numFixed)
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -165,20 +161,6 @@ func init() {
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
handlers[msgAffix] = func(d *Decoder) bool {
|
|
||||||
// TODO: use an alternative method for common cases.
|
|
||||||
prefix := d.DecodeString()
|
|
||||||
suffix := d.DecodeString()
|
|
||||||
if prefix != "" {
|
|
||||||
d.Render(prefix)
|
|
||||||
}
|
|
||||||
ret := d.ExecuteMessage()
|
|
||||||
if suffix != "" {
|
|
||||||
d.Render(suffix)
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -392,24 +374,3 @@ func (s String) Compile(e *Encoder) (err error) {
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affix is a message that adds a prefix and suffix to another message.
|
|
||||||
// This is mostly used add back whitespace to a translation that was stripped
|
|
||||||
// before sending it out.
|
|
||||||
type Affix struct {
|
|
||||||
Message Message
|
|
||||||
Prefix string
|
|
||||||
Suffix string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compile implements Message.
|
|
||||||
func (a Affix) Compile(e *Encoder) (err error) {
|
|
||||||
// TODO: consider adding a special message type that just adds a single
|
|
||||||
// return. This is probably common enough to handle the majority of cases.
|
|
||||||
// Get some stats first, though.
|
|
||||||
e.EncodeMessageType(msgAffix)
|
|
||||||
e.EncodeString(a.Prefix)
|
|
||||||
e.EncodeString(a.Suffix)
|
|
||||||
e.EncodeMessage(a.Message)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
13
vendor/golang.org/x/text/internal/catmsg/catmsg_test.go
generated
vendored
13
vendor/golang.org/x/text/internal/catmsg/catmsg_test.go
generated
vendored
|
@ -70,10 +70,6 @@ func TestCodec(t *testing.T) {
|
||||||
desc: "simple string",
|
desc: "simple string",
|
||||||
m: String("foo"),
|
m: String("foo"),
|
||||||
tests: single("foo", ""),
|
tests: single("foo", ""),
|
||||||
}, {
|
|
||||||
desc: "affix",
|
|
||||||
m: &Affix{String("foo"), "\t", "\n"},
|
|
||||||
tests: single("\t|foo|\n", ""),
|
|
||||||
}, {
|
}, {
|
||||||
desc: "missing var",
|
desc: "missing var",
|
||||||
m: String("foo${bar}"),
|
m: String("foo${bar}"),
|
||||||
|
@ -104,13 +100,6 @@ func TestCodec(t *testing.T) {
|
||||||
String("foo${bar}"),
|
String("foo${bar}"),
|
||||||
},
|
},
|
||||||
tests: single("foo|baz", ""),
|
tests: single("foo|baz", ""),
|
||||||
}, {
|
|
||||||
desc: "affix with substitution",
|
|
||||||
m: &Affix{seq{
|
|
||||||
&Var{"bar", String("baz")},
|
|
||||||
String("foo${bar}"),
|
|
||||||
}, "\t", "\n"},
|
|
||||||
tests: single("\t|foo|baz|\n", ""),
|
|
||||||
}, {
|
}, {
|
||||||
desc: "shadowed variable",
|
desc: "shadowed variable",
|
||||||
m: seq{
|
m: seq{
|
||||||
|
@ -151,7 +140,7 @@ func TestCodec(t *testing.T) {
|
||||||
&Var{"bar", incomplete{}},
|
&Var{"bar", incomplete{}},
|
||||||
String("${bar}"),
|
String("${bar}"),
|
||||||
},
|
},
|
||||||
enc: "\x00\t\b\x01\x01\x14\x04\x02bar\x03\x00\x00\x00",
|
enc: "\x00\t\b\x01\x01\x04\x04\x02bar\x03\x00\x00\x00",
|
||||||
// TODO: recognize that it is cheaper to substitute bar.
|
// TODO: recognize that it is cheaper to substitute bar.
|
||||||
tests: single("bar", ""),
|
tests: single("bar", ""),
|
||||||
}, {
|
}, {
|
||||||
|
|
25
vendor/golang.org/x/text/message/pipeline/extract.go
generated
vendored
25
vendor/golang.org/x/text/message/pipeline/extract.go
generated
vendored
|
@ -28,12 +28,8 @@ import (
|
||||||
// - handle features (gender, plural)
|
// - handle features (gender, plural)
|
||||||
// - message rewriting
|
// - message rewriting
|
||||||
|
|
||||||
// - %m substitutions
|
|
||||||
// - `msg:"etc"` tags
|
|
||||||
// - msg/Msg top-level vars and strings.
|
|
||||||
|
|
||||||
// Extract extracts all strings form the package defined in Config.
|
// Extract extracts all strings form the package defined in Config.
|
||||||
func Extract(c *Config) (*State, error) {
|
func Extract(c *Config) (*Locale, error) {
|
||||||
conf := loader.Config{}
|
conf := loader.Config{}
|
||||||
prog, err := loadPackages(&conf, c.Packages)
|
prog, err := loadPackages(&conf, c.Packages)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -145,11 +141,9 @@ func Extract(c *Config) (*State, error) {
|
||||||
|
|
||||||
ph := placeholders{index: map[string]string{}}
|
ph := placeholders{index: map[string]string{}}
|
||||||
|
|
||||||
trimmed, _, _ := trimWS(fmtMsg)
|
|
||||||
|
|
||||||
p := fmtparser.Parser{}
|
p := fmtparser.Parser{}
|
||||||
p.Reset(simArgs)
|
p.Reset(simArgs)
|
||||||
for p.SetFormat(trimmed); p.Scan(); {
|
for p.SetFormat(fmtMsg); p.Scan(); {
|
||||||
switch p.Status {
|
switch p.Status {
|
||||||
case fmtparser.StatusText:
|
case fmtparser.StatusText:
|
||||||
msg += p.Text()
|
msg += p.Text()
|
||||||
|
@ -195,14 +189,11 @@ func Extract(c *Config) (*State, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &State{
|
out := &Locale{
|
||||||
Config: *c,
|
Language: c.SourceLanguage,
|
||||||
program: prog,
|
Messages: messages,
|
||||||
Extracted: Messages{
|
}
|
||||||
Language: c.SourceLanguage,
|
return out, nil
|
||||||
Messages: messages,
|
|
||||||
},
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func posString(conf loader.Config, info *loader.PackageInfo, pos token.Pos) string {
|
func posString(conf loader.Config, info *loader.PackageInfo, pos token.Pos) string {
|
||||||
|
@ -251,7 +242,7 @@ func strip(s string) string {
|
||||||
if unicode.IsSpace(r) || r == '-' {
|
if unicode.IsSpace(r) || r == '-' {
|
||||||
return '_'
|
return '_'
|
||||||
}
|
}
|
||||||
if !unicode.In(r, unicode.Letter, unicode.Mark, unicode.Number) {
|
if !unicode.In(r, unicode.Letter, unicode.Mark) {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
|
|
97
vendor/golang.org/x/text/message/pipeline/generate.go
generated
vendored
97
vendor/golang.org/x/text/message/pipeline/generate.go
generated
vendored
|
@ -6,9 +6,7 @@ package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/build"
|
|
||||||
"io"
|
"io"
|
||||||
"path/filepath"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -20,75 +18,23 @@ import (
|
||||||
"golang.org/x/text/internal/catmsg"
|
"golang.org/x/text/internal/catmsg"
|
||||||
"golang.org/x/text/internal/gen"
|
"golang.org/x/text/internal/gen"
|
||||||
"golang.org/x/text/language"
|
"golang.org/x/text/language"
|
||||||
"golang.org/x/tools/go/loader"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var transRe = regexp.MustCompile(`messages\.(.*)\.json`)
|
var transRe = regexp.MustCompile(`messages\.(.*)\.json`)
|
||||||
|
|
||||||
// Generate writes a Go file that defines a Catalog with translated messages.
|
// Generate writes a Go file with the given package name to w, which defines a
|
||||||
// Translations are retrieved from s.Messages, not s.Translations, so it
|
// Catalog with translated messages.
|
||||||
// is assumed Merge has been called.
|
func Generate(w io.Writer, pkg string, extracted *Locale, trans ...*Locale) (n int, err error) {
|
||||||
func (s *State) Generate() error {
|
// TODO: add in external input. Right now we assume that all files are
|
||||||
path := s.Config.GenPackage
|
// manually created and stored in the textdata directory.
|
||||||
if path == "" {
|
|
||||||
path = "."
|
|
||||||
}
|
|
||||||
isDir := path[0] == '.'
|
|
||||||
prog, err := loadPackages(&loader.Config{}, []string{path})
|
|
||||||
if err != nil {
|
|
||||||
return wrap(err, "could not load package")
|
|
||||||
}
|
|
||||||
pkgs := prog.InitialPackages()
|
|
||||||
if len(pkgs) != 1 {
|
|
||||||
return errorf("more than one package selected: %v", pkgs)
|
|
||||||
}
|
|
||||||
pkg := pkgs[0].Pkg.Name()
|
|
||||||
|
|
||||||
cw, err := s.generate()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if !isDir {
|
|
||||||
gopath := build.Default.GOPATH
|
|
||||||
path = filepath.Join(gopath, filepath.FromSlash(pkgs[0].Pkg.Path()))
|
|
||||||
}
|
|
||||||
path = filepath.Join(path, s.Config.GenFile)
|
|
||||||
cw.WriteGoFile(path, pkg) // TODO: WriteGoFile should return error.
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// WriteGen writes a Go file with the given package name to w that defines a
|
|
||||||
// Catalog with translated messages. Translations are retrieved from s.Messages,
|
|
||||||
// not s.Translations, so it is assumed Merge has been called.
|
|
||||||
func (s *State) WriteGen(w io.Writer, pkg string) error {
|
|
||||||
cw, err := s.generate()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
_, err = cw.WriteGo(w, pkg, "")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate is deprecated; use (*State).Generate().
|
|
||||||
func Generate(w io.Writer, pkg string, extracted *Messages, trans ...Messages) (n int, err error) {
|
|
||||||
s := State{
|
|
||||||
Extracted: *extracted,
|
|
||||||
Translations: trans,
|
|
||||||
}
|
|
||||||
cw, err := s.generate()
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
return cw.WriteGo(w, pkg, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *State) generate() (*gen.CodeWriter, error) {
|
|
||||||
// Build up index of translations and original messages.
|
// Build up index of translations and original messages.
|
||||||
translations := map[language.Tag]map[string]Message{}
|
translations := map[language.Tag]map[string]Message{}
|
||||||
languages := []language.Tag{}
|
languages := []language.Tag{}
|
||||||
|
langVars := []string{}
|
||||||
usedKeys := map[string]int{}
|
usedKeys := map[string]int{}
|
||||||
|
|
||||||
for _, loc := range s.Messages {
|
for _, loc := range trans {
|
||||||
tag := loc.Language
|
tag := loc.Language
|
||||||
if _, ok := translations[tag]; !ok {
|
if _, ok := translations[tag]; !ok {
|
||||||
translations[tag] = map[string]Message{}
|
translations[tag] = map[string]Message{}
|
||||||
|
@ -98,7 +44,7 @@ func (s *State) generate() (*gen.CodeWriter, error) {
|
||||||
if !m.Translation.IsEmpty() {
|
if !m.Translation.IsEmpty() {
|
||||||
for _, id := range m.ID {
|
for _, id := range m.ID {
|
||||||
if _, ok := translations[tag][id]; ok {
|
if _, ok := translations[tag][id]; ok {
|
||||||
warnf("Duplicate translation in locale %q for message %q", tag, id)
|
logf("Duplicate translation in locale %q for message %q", tag, id)
|
||||||
}
|
}
|
||||||
translations[tag][id] = m
|
translations[tag][id] = m
|
||||||
}
|
}
|
||||||
|
@ -109,11 +55,10 @@ func (s *State) generate() (*gen.CodeWriter, error) {
|
||||||
// Verify completeness and register keys.
|
// Verify completeness and register keys.
|
||||||
internal.SortTags(languages)
|
internal.SortTags(languages)
|
||||||
|
|
||||||
langVars := []string{}
|
|
||||||
for _, tag := range languages {
|
for _, tag := range languages {
|
||||||
langVars = append(langVars, strings.Replace(tag.String(), "-", "_", -1))
|
langVars = append(langVars, strings.Replace(tag.String(), "-", "_", -1))
|
||||||
dict := translations[tag]
|
dict := translations[tag]
|
||||||
for _, msg := range s.Extracted.Messages {
|
for _, msg := range extracted.Messages {
|
||||||
for _, id := range msg.ID {
|
for _, id := range msg.ID {
|
||||||
if trans, ok := dict[id]; ok && !trans.Translation.IsEmpty() {
|
if trans, ok := dict[id]; ok && !trans.Translation.IsEmpty() {
|
||||||
if _, ok := usedKeys[msg.Key]; !ok {
|
if _, ok := usedKeys[msg.Key]; !ok {
|
||||||
|
@ -122,7 +67,7 @@ func (s *State) generate() (*gen.CodeWriter, error) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// TODO: log missing entry.
|
// TODO: log missing entry.
|
||||||
warnf("%s: Missing entry for %q.", tag, id)
|
logf("%s: Missing entry for %q.", tag, id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,12 +78,12 @@ func (s *State) generate() (*gen.CodeWriter, error) {
|
||||||
Fallback language.Tag
|
Fallback language.Tag
|
||||||
Languages []string
|
Languages []string
|
||||||
}{
|
}{
|
||||||
Fallback: s.Extracted.Language,
|
Fallback: extracted.Language,
|
||||||
Languages: langVars,
|
Languages: langVars,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := lookup.Execute(cw, x); err != nil {
|
if err := lookup.Execute(cw, x); err != nil {
|
||||||
return nil, wrap(err, "error")
|
return 0, wrap(err, "error")
|
||||||
}
|
}
|
||||||
|
|
||||||
keyToIndex := []string{}
|
keyToIndex := []string{}
|
||||||
|
@ -155,29 +100,21 @@ func (s *State) generate() (*gen.CodeWriter, error) {
|
||||||
for i, tag := range languages {
|
for i, tag := range languages {
|
||||||
dict := translations[tag]
|
dict := translations[tag]
|
||||||
a := make([]string, len(usedKeys))
|
a := make([]string, len(usedKeys))
|
||||||
for _, msg := range s.Extracted.Messages {
|
for _, msg := range extracted.Messages {
|
||||||
for _, id := range msg.ID {
|
for _, id := range msg.ID {
|
||||||
if trans, ok := dict[id]; ok && !trans.Translation.IsEmpty() {
|
if trans, ok := dict[id]; ok && !trans.Translation.IsEmpty() {
|
||||||
m, err := assemble(&msg, &trans.Translation)
|
m, err := assemble(&msg, &trans.Translation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, wrap(err, "error")
|
return 0, wrap(err, "error")
|
||||||
}
|
|
||||||
_, leadWS, trailWS := trimWS(msg.Key)
|
|
||||||
if leadWS != "" || trailWS != "" {
|
|
||||||
m = catmsg.Affix{
|
|
||||||
Message: m,
|
|
||||||
Prefix: leadWS,
|
|
||||||
Suffix: trailWS,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// TODO: support macros.
|
// TODO: support macros.
|
||||||
data, err := catmsg.Compile(tag, nil, m)
|
data, err := catmsg.Compile(tag, nil, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, wrap(err, "error")
|
return 0, wrap(err, "error")
|
||||||
}
|
}
|
||||||
key := usedKeys[msg.Key]
|
key := usedKeys[msg.Key]
|
||||||
if d := a[key]; d != "" && d != data {
|
if d := a[key]; d != "" && d != data {
|
||||||
warnf("Duplicate non-consistent translation for key %q, picking the one for message %q", msg.Key, id)
|
logf("Duplicate non-consistent translation for key %q, picking the one for message %q", msg.Key, id)
|
||||||
}
|
}
|
||||||
a[key] = string(data)
|
a[key] = string(data)
|
||||||
break
|
break
|
||||||
|
@ -194,7 +131,7 @@ func (s *State) generate() (*gen.CodeWriter, error) {
|
||||||
cw.WriteVar(langVars[i]+"Index", index)
|
cw.WriteVar(langVars[i]+"Index", index)
|
||||||
cw.WriteConst(langVars[i]+"Data", strings.Join(a, ""))
|
cw.WriteConst(langVars[i]+"Data", strings.Join(a, ""))
|
||||||
}
|
}
|
||||||
return cw, nil
|
return cw.WriteGo(w, pkg, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func assemble(m *Message, t *Text) (msg catmsg.Message, err error) {
|
func assemble(m *Message, t *Text) (msg catmsg.Message, err error) {
|
||||||
|
|
13
vendor/golang.org/x/text/message/pipeline/go19_test.go
generated
vendored
13
vendor/golang.org/x/text/message/pipeline/go19_test.go
generated
vendored
|
@ -1,13 +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.
|
|
||||||
|
|
||||||
// +build go1.9
|
|
||||||
|
|
||||||
package pipeline
|
|
||||||
|
|
||||||
import "testing"
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
setHelper = (*testing.T).Helper
|
|
||||||
}
|
|
46
vendor/golang.org/x/text/message/pipeline/message.go
generated
vendored
46
vendor/golang.org/x/text/message/pipeline/message.go
generated
vendored
|
@ -6,7 +6,6 @@ package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/text/language"
|
"golang.org/x/text/language"
|
||||||
|
@ -24,8 +23,28 @@ import (
|
||||||
// the format string "%d file(s) remaining".
|
// the format string "%d file(s) remaining".
|
||||||
// See the examples directory for examples of extracted messages.
|
// See the examples directory for examples of extracted messages.
|
||||||
|
|
||||||
// Messages is used to store translations for a single language.
|
// Config contains configuration for the translation pipeline.
|
||||||
type Messages struct {
|
type Config struct {
|
||||||
|
SourceLanguage language.Tag
|
||||||
|
|
||||||
|
// Supported indicates the languages for which data should be generated.
|
||||||
|
// If unspecified, it will attempt to derive the set of supported languages
|
||||||
|
// from the context.
|
||||||
|
Supported []language.Tag
|
||||||
|
|
||||||
|
Packages []string
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// - Printf-style configuration
|
||||||
|
// - Template-style configuration
|
||||||
|
// - Extraction options
|
||||||
|
// - Rewrite options
|
||||||
|
// - Generation options
|
||||||
|
}
|
||||||
|
|
||||||
|
// A Locale is used to store all information for a single locale. This type is
|
||||||
|
// used both for extraction and injection.
|
||||||
|
type Locale struct {
|
||||||
Language language.Tag `json:"language"`
|
Language language.Tag `json:"language"`
|
||||||
Messages []Message `json:"messages"`
|
Messages []Message `json:"messages"`
|
||||||
Macros map[string]Text `json:"macros,omitempty"`
|
Macros map[string]Text `json:"macros,omitempty"`
|
||||||
|
@ -36,7 +55,7 @@ type Message struct {
|
||||||
// ID contains a list of identifiers for the message.
|
// ID contains a list of identifiers for the message.
|
||||||
ID IDList `json:"id"`
|
ID IDList `json:"id"`
|
||||||
// Key is the string that is used to look up the message at runtime.
|
// Key is the string that is used to look up the message at runtime.
|
||||||
Key string `json:"key,omitempty"`
|
Key string `json:"key"`
|
||||||
Meaning string `json:"meaning,omitempty"`
|
Meaning string `json:"meaning,omitempty"`
|
||||||
Message Text `json:"message"`
|
Message Text `json:"message"`
|
||||||
Translation Text `json:"translation"`
|
Translation Text `json:"translation"`
|
||||||
|
@ -46,11 +65,6 @@ type Message struct {
|
||||||
|
|
||||||
Placeholders []Placeholder `json:"placeholders,omitempty"`
|
Placeholders []Placeholder `json:"placeholders,omitempty"`
|
||||||
|
|
||||||
// Fuzzy indicates that the provide translation needs review by a
|
|
||||||
// translator, for instance because it was derived from automated
|
|
||||||
// translation.
|
|
||||||
Fuzzy bool `json:"fuzzy,omitempty"`
|
|
||||||
|
|
||||||
// TODO: default placeholder syntax is {foo}. Allow alternative escaping
|
// TODO: default placeholder syntax is {foo}. Allow alternative escaping
|
||||||
// like `foo`.
|
// like `foo`.
|
||||||
|
|
||||||
|
@ -100,20 +114,6 @@ func (m *Message) Substitute(msg string) (sub string, err error) {
|
||||||
return sub, err
|
return sub, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var errIncompatibleMessage = errors.New("messages incompatible")
|
|
||||||
|
|
||||||
func checkEquivalence(a, b *Message) error {
|
|
||||||
for _, v := range a.ID {
|
|
||||||
for _, w := range b.ID {
|
|
||||||
if v == w {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: canonicalize placeholders and check for type equivalence.
|
|
||||||
return errIncompatibleMessage
|
|
||||||
}
|
|
||||||
|
|
||||||
// A Placeholder is a part of the message that should not be changed by a
|
// A Placeholder is a part of the message that should not be changed by a
|
||||||
// translator. It can be used to hide or prettify format strings (e.g. %d or
|
// translator. It can be used to hide or prettify format strings (e.g. %d or
|
||||||
// {{.Count}}), hide HTML, or mark common names that should not be translated.
|
// {{.Count}}), hide HTML, or mark common names that should not be translated.
|
||||||
|
|
371
vendor/golang.org/x/text/message/pipeline/pipeline.go
generated
vendored
371
vendor/golang.org/x/text/message/pipeline/pipeline.go
generated
vendored
|
@ -8,398 +8,33 @@
|
||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/build"
|
"go/build"
|
||||||
"go/parser"
|
"go/parser"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"regexp"
|
|
||||||
"strings"
|
|
||||||
"text/template"
|
|
||||||
"unicode"
|
|
||||||
|
|
||||||
"golang.org/x/text/internal"
|
|
||||||
"golang.org/x/text/language"
|
|
||||||
"golang.org/x/text/runes"
|
|
||||||
"golang.org/x/tools/go/loader"
|
"golang.org/x/tools/go/loader"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
extractFile = "extracted.gotext.json"
|
extractFile = "extracted.gotext.json"
|
||||||
outFile = "out.gotext.json"
|
outFile = "out.gotext.json"
|
||||||
gotextSuffix = "gotext.json"
|
gotextSuffix = ".gotext.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config contains configuration for the translation pipeline.
|
|
||||||
type Config struct {
|
|
||||||
// Supported indicates the languages for which data should be generated.
|
|
||||||
// The default is to support all locales for which there are matching
|
|
||||||
// translation files.
|
|
||||||
Supported []language.Tag
|
|
||||||
|
|
||||||
// --- Extraction
|
|
||||||
|
|
||||||
SourceLanguage language.Tag
|
|
||||||
|
|
||||||
Packages []string
|
|
||||||
|
|
||||||
// --- File structure
|
|
||||||
|
|
||||||
// Dir is the root dir for all operations.
|
|
||||||
Dir string
|
|
||||||
|
|
||||||
// TranslationsPattern is a regular expression to match incoming translation
|
|
||||||
// files. These files may appear in any directory rooted at Dir.
|
|
||||||
// language for the translation files is determined as follows:
|
|
||||||
// 1. From the Language field in the file.
|
|
||||||
// 2. If not present, from a valid language tag in the filename, separated
|
|
||||||
// by dots (e.g. "en-US.json" or "incoming.pt_PT.xmb").
|
|
||||||
// 3. If not present, from a the closest subdirectory in which the file
|
|
||||||
// is contained that parses as a valid language tag.
|
|
||||||
TranslationsPattern string
|
|
||||||
|
|
||||||
// OutPattern defines the location for translation files for a certain
|
|
||||||
// language. The default is "{{.Dir}}/{{.Language}}/out.{{.Ext}}"
|
|
||||||
OutPattern string
|
|
||||||
|
|
||||||
// Format defines the file format for generated translation files.
|
|
||||||
// The default is XMB. Alternatives are GetText, XLIFF, L20n, GoText.
|
|
||||||
Format string
|
|
||||||
|
|
||||||
Ext string
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// Actions are additional actions to be performed after the initial extract
|
|
||||||
// and merge.
|
|
||||||
// Actions []struct {
|
|
||||||
// Name string
|
|
||||||
// Options map[string]string
|
|
||||||
// }
|
|
||||||
|
|
||||||
// --- Generation
|
|
||||||
|
|
||||||
// GenFile may be in a different package. It is not defined, it will
|
|
||||||
// be written to stdout.
|
|
||||||
GenFile string
|
|
||||||
|
|
||||||
// GenPackage is the package or relative path into which to generate the
|
|
||||||
// file. If not specified it is relative to the current directory.
|
|
||||||
GenPackage string
|
|
||||||
|
|
||||||
// DeclareVar defines a variable to which to assing the generated Catalog.
|
|
||||||
DeclareVar string
|
|
||||||
|
|
||||||
// SetDefault determines whether to assign the generated Catalog to
|
|
||||||
// message.DefaultCatalog. The default for this is true if DeclareVar is
|
|
||||||
// not defined, false otherwise.
|
|
||||||
SetDefault bool
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// - Printf-style configuration
|
|
||||||
// - Template-style configuration
|
|
||||||
// - Extraction options
|
|
||||||
// - Rewrite options
|
|
||||||
// - Generation options
|
|
||||||
}
|
|
||||||
|
|
||||||
// Operations:
|
|
||||||
// - extract: get the strings
|
|
||||||
// - disambiguate: find messages with the same key, but possible different meaning.
|
|
||||||
// - create out: create a list of messages that need translations
|
|
||||||
// - load trans: load the list of current translations
|
|
||||||
// - merge: assign list of translations as done
|
|
||||||
// - (action)expand: analyze features and create example sentences for each version.
|
|
||||||
// - (action)googletrans: pre-populate messages with automatic translations.
|
|
||||||
// - (action)export: send out messages somewhere non-standard
|
|
||||||
// - (action)import: load messages from somewhere non-standard
|
|
||||||
// - vet program: don't pass "foo" + var + "bar" strings. Not using funcs for translated strings.
|
|
||||||
// - vet trans: coverage: all translations/ all features.
|
|
||||||
// - generate: generate Go code
|
|
||||||
|
|
||||||
// State holds all accumulated information on translations during processing.
|
|
||||||
type State struct {
|
|
||||||
Config Config
|
|
||||||
|
|
||||||
Package string
|
|
||||||
program *loader.Program
|
|
||||||
|
|
||||||
Extracted Messages `json:"messages"`
|
|
||||||
|
|
||||||
// Messages includes all messages for which there need to be translations.
|
|
||||||
// Duplicates may be eliminated. Generation will be done from these messages
|
|
||||||
// (usually after merging).
|
|
||||||
Messages []Messages
|
|
||||||
|
|
||||||
// Translations are incoming translations for the application messages.
|
|
||||||
Translations []Messages
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *State) dir() string {
|
|
||||||
if d := s.Config.Dir; d != "" {
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
return "./locales"
|
|
||||||
}
|
|
||||||
|
|
||||||
func outPattern(s *State) (string, error) {
|
|
||||||
c := s.Config
|
|
||||||
pat := c.OutPattern
|
|
||||||
if pat == "" {
|
|
||||||
pat = "{{.Dir}}/{{.Language}}/out.{{.Ext}}"
|
|
||||||
}
|
|
||||||
|
|
||||||
ext := c.Ext
|
|
||||||
if ext == "" {
|
|
||||||
ext = c.Format
|
|
||||||
}
|
|
||||||
if ext == "" {
|
|
||||||
ext = gotextSuffix
|
|
||||||
}
|
|
||||||
t, err := template.New("").Parse(pat)
|
|
||||||
if err != nil {
|
|
||||||
return "", wrap(err, "error parsing template")
|
|
||||||
}
|
|
||||||
buf := bytes.Buffer{}
|
|
||||||
err = t.Execute(&buf, map[string]string{
|
|
||||||
"Dir": s.dir(),
|
|
||||||
"Language": "%s",
|
|
||||||
"Ext": ext,
|
|
||||||
})
|
|
||||||
return filepath.FromSlash(buf.String()), wrap(err, "incorrect OutPattern")
|
|
||||||
}
|
|
||||||
|
|
||||||
var transRE = regexp.MustCompile(`.*\.` + gotextSuffix)
|
|
||||||
|
|
||||||
// Import loads existing translation files.
|
|
||||||
func (s *State) Import() error {
|
|
||||||
outPattern, err := outPattern(s)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
re := transRE
|
|
||||||
if pat := s.Config.TranslationsPattern; pat != "" {
|
|
||||||
if re, err = regexp.Compile(pat); err != nil {
|
|
||||||
return wrapf(err, "error parsing regexp %q", s.Config.TranslationsPattern)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
x := importer{s, outPattern, re}
|
|
||||||
return x.walkImport(s.dir(), s.Config.SourceLanguage)
|
|
||||||
}
|
|
||||||
|
|
||||||
type importer struct {
|
|
||||||
state *State
|
|
||||||
outPattern string
|
|
||||||
transFile *regexp.Regexp
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *importer) walkImport(path string, tag language.Tag) error {
|
|
||||||
files, err := ioutil.ReadDir(path)
|
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
for _, f := range files {
|
|
||||||
name := f.Name()
|
|
||||||
tag := tag
|
|
||||||
if f.IsDir() {
|
|
||||||
if t, err := language.Parse(name); err == nil {
|
|
||||||
tag = t
|
|
||||||
}
|
|
||||||
// We ignore errors
|
|
||||||
if err := i.walkImport(filepath.Join(path, name), tag); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for _, l := range strings.Split(name, ".") {
|
|
||||||
if t, err := language.Parse(l); err == nil {
|
|
||||||
tag = t
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file := filepath.Join(path, name)
|
|
||||||
// TODO: Should we skip files that match output files?
|
|
||||||
if fmt.Sprintf(i.outPattern, tag) == file {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// TODO: handle different file formats.
|
|
||||||
if !i.transFile.MatchString(name) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
b, err := ioutil.ReadFile(file)
|
|
||||||
if err != nil {
|
|
||||||
return wrap(err, "read file failed")
|
|
||||||
}
|
|
||||||
var translations Messages
|
|
||||||
if err := json.Unmarshal(b, &translations); err != nil {
|
|
||||||
return wrap(err, "parsing translation file failed")
|
|
||||||
}
|
|
||||||
i.state.Translations = append(i.state.Translations, translations)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Merge merges the extracted messages with the existing translations.
|
|
||||||
func (s *State) Merge() error {
|
|
||||||
if s.Messages != nil {
|
|
||||||
panic("already merged")
|
|
||||||
}
|
|
||||||
// Create an index for each unique message.
|
|
||||||
// Duplicates are okay as long as the substitution arguments are okay as
|
|
||||||
// well.
|
|
||||||
// Top-level messages are okay to appear in multiple substitution points.
|
|
||||||
|
|
||||||
// Collect key equivalence.
|
|
||||||
msgs := []*Message{}
|
|
||||||
keyToIDs := map[string]*Message{}
|
|
||||||
for _, m := range s.Extracted.Messages {
|
|
||||||
m := m
|
|
||||||
if prev, ok := keyToIDs[m.Key]; ok {
|
|
||||||
if err := checkEquivalence(&m, prev); err != nil {
|
|
||||||
warnf("Key %q matches conflicting messages: %v and %v", m.Key, prev.ID, m.ID)
|
|
||||||
// TODO: track enough information so that the rewriter can
|
|
||||||
// suggest/disambiguate messages.
|
|
||||||
}
|
|
||||||
// TODO: add position to message.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
i := len(msgs)
|
|
||||||
msgs = append(msgs, &m)
|
|
||||||
keyToIDs[m.Key] = msgs[i]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Messages with different keys may still refer to the same translated
|
|
||||||
// message (e.g. different whitespace). Filter these.
|
|
||||||
idMap := map[string]bool{}
|
|
||||||
filtered := []*Message{}
|
|
||||||
for _, m := range msgs {
|
|
||||||
found := false
|
|
||||||
for _, id := range m.ID {
|
|
||||||
found = found || idMap[id]
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
filtered = append(filtered, m)
|
|
||||||
}
|
|
||||||
for _, id := range m.ID {
|
|
||||||
idMap[id] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build index of translations.
|
|
||||||
translations := map[language.Tag]map[string]Message{}
|
|
||||||
languages := append([]language.Tag{}, s.Config.Supported...)
|
|
||||||
|
|
||||||
for _, t := range s.Translations {
|
|
||||||
tag := t.Language
|
|
||||||
if _, ok := translations[tag]; !ok {
|
|
||||||
translations[tag] = map[string]Message{}
|
|
||||||
languages = append(languages, tag)
|
|
||||||
}
|
|
||||||
for _, m := range t.Messages {
|
|
||||||
if !m.Translation.IsEmpty() {
|
|
||||||
for _, id := range m.ID {
|
|
||||||
if _, ok := translations[tag][id]; ok {
|
|
||||||
warnf("Duplicate translation in locale %q for message %q", tag, id)
|
|
||||||
}
|
|
||||||
translations[tag][id] = m
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
languages = internal.UniqueTags(languages)
|
|
||||||
|
|
||||||
for _, tag := range languages {
|
|
||||||
ms := Messages{Language: tag}
|
|
||||||
for _, orig := range filtered {
|
|
||||||
m := *orig
|
|
||||||
m.Key = ""
|
|
||||||
m.Position = ""
|
|
||||||
|
|
||||||
for _, id := range m.ID {
|
|
||||||
if t, ok := translations[tag][id]; ok {
|
|
||||||
m.Translation = t.Translation
|
|
||||||
if t.TranslatorComment != "" {
|
|
||||||
m.TranslatorComment = t.TranslatorComment
|
|
||||||
m.Fuzzy = t.Fuzzy
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if tag == s.Config.SourceLanguage && m.Translation.IsEmpty() {
|
|
||||||
m.Translation = m.Message
|
|
||||||
if m.TranslatorComment == "" {
|
|
||||||
m.TranslatorComment = "Copied from source."
|
|
||||||
m.Fuzzy = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: if translation is empty: pre-expand based on available
|
|
||||||
// linguistic features. This may also be done as a plugin.
|
|
||||||
ms.Messages = append(ms.Messages, m)
|
|
||||||
}
|
|
||||||
s.Messages = append(s.Messages, ms)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Export writes out the messages to translation out files.
|
|
||||||
func (s *State) Export() error {
|
|
||||||
path, err := outPattern(s)
|
|
||||||
if err != nil {
|
|
||||||
return wrap(err, "export failed")
|
|
||||||
}
|
|
||||||
for _, out := range s.Messages {
|
|
||||||
// TODO: inject translations from existing files to avoid retranslation.
|
|
||||||
data, err := json.MarshalIndent(out, "", " ")
|
|
||||||
if err != nil {
|
|
||||||
return wrap(err, "JSON marshal failed")
|
|
||||||
}
|
|
||||||
file := fmt.Sprintf(path, out.Language)
|
|
||||||
if err := os.MkdirAll(filepath.Dir(file), 0755); err != nil {
|
|
||||||
return wrap(err, "dir create failed")
|
|
||||||
}
|
|
||||||
if err := ioutil.WriteFile(file, data, 0644); err != nil {
|
|
||||||
return wrap(err, "write failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
ws = runes.In(unicode.White_Space).Contains
|
|
||||||
notWS = runes.NotIn(unicode.White_Space).Contains
|
|
||||||
)
|
|
||||||
|
|
||||||
func trimWS(s string) (trimmed, leadWS, trailWS string) {
|
|
||||||
trimmed = strings.TrimRightFunc(s, ws)
|
|
||||||
trailWS = s[len(trimmed):]
|
|
||||||
if i := strings.IndexFunc(trimmed, notWS); i > 0 {
|
|
||||||
leadWS = trimmed[:i]
|
|
||||||
trimmed = trimmed[i:]
|
|
||||||
}
|
|
||||||
return trimmed, leadWS, trailWS
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: The command line tool already prefixes with "gotext:".
|
// NOTE: The command line tool already prefixes with "gotext:".
|
||||||
var (
|
var (
|
||||||
wrap = func(err error, msg string) error {
|
wrap = func(err error, msg string) error {
|
||||||
if err == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return fmt.Errorf("%s: %v", msg, err)
|
return fmt.Errorf("%s: %v", msg, err)
|
||||||
}
|
}
|
||||||
wrapf = func(err error, msg string, args ...interface{}) error {
|
wrapf = func(err error, msg string, args ...interface{}) error {
|
||||||
if err == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return wrap(err, fmt.Sprintf(msg, args...))
|
return wrap(err, fmt.Sprintf(msg, args...))
|
||||||
}
|
}
|
||||||
errorf = fmt.Errorf
|
errorf = fmt.Errorf
|
||||||
)
|
)
|
||||||
|
|
||||||
func warnf(format string, args ...interface{}) {
|
// TODO: don't log.
|
||||||
// TODO: don't log.
|
func logf(format string, args ...interface{}) {
|
||||||
log.Printf(format, args...)
|
log.Printf(format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
126
vendor/golang.org/x/text/message/pipeline/pipeline_test.go
generated
vendored
126
vendor/golang.org/x/text/message/pipeline/pipeline_test.go
generated
vendored
|
@ -1,126 +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 pipeline
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"golang.org/x/text/language"
|
|
||||||
)
|
|
||||||
|
|
||||||
var genFiles = flag.Bool("gen", false, "generate output files instead of comparing")
|
|
||||||
|
|
||||||
// setHelper is testing.T.Helper on Go 1.9+, overridden by go19_test.go.
|
|
||||||
var setHelper = func(t *testing.T) {}
|
|
||||||
|
|
||||||
func TestFullCycle(t *testing.T) {
|
|
||||||
const path = "./testdata"
|
|
||||||
dirs, err := ioutil.ReadDir(path)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
for _, f := range dirs {
|
|
||||||
t.Run(f.Name(), func(t *testing.T) {
|
|
||||||
chk := func(t *testing.T, err error) {
|
|
||||||
setHelper(t)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dir := filepath.Join(path, f.Name())
|
|
||||||
pkgPath := fmt.Sprintf("%s/%s", path, f.Name())
|
|
||||||
config := Config{
|
|
||||||
SourceLanguage: language.AmericanEnglish,
|
|
||||||
Packages: []string{pkgPath},
|
|
||||||
Dir: filepath.Join(dir, "locales"),
|
|
||||||
GenFile: "catalog_gen.go",
|
|
||||||
GenPackage: pkgPath,
|
|
||||||
}
|
|
||||||
// TODO: load config if available.
|
|
||||||
s, err := Extract(&config)
|
|
||||||
chk(t, err)
|
|
||||||
chk(t, s.Import())
|
|
||||||
chk(t, s.Merge())
|
|
||||||
// TODO:
|
|
||||||
// for range s.Config.Actions {
|
|
||||||
// // TODO: do the actions.
|
|
||||||
// }
|
|
||||||
chk(t, s.Export())
|
|
||||||
chk(t, s.Generate())
|
|
||||||
|
|
||||||
writeJSON(t, filepath.Join(dir, "extracted.gotext.json"), s.Extracted)
|
|
||||||
checkOutput(t, dir)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkOutput(t *testing.T, p string) {
|
|
||||||
filepath.Walk(p, func(p string, f os.FileInfo, err error) error {
|
|
||||||
if f.IsDir() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if filepath.Ext(p) != ".want" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
gotFile := p[:len(p)-len(".want")]
|
|
||||||
got, err := ioutil.ReadFile(gotFile)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("failed to read %q", p)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if *genFiles {
|
|
||||||
if err := ioutil.WriteFile(p, got, 0644); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
want, err := ioutil.ReadFile(p)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("failed to read %q", p)
|
|
||||||
} else {
|
|
||||||
scanGot := bufio.NewScanner(bytes.NewReader(got))
|
|
||||||
scanWant := bufio.NewScanner(bytes.NewReader(want))
|
|
||||||
line := 0
|
|
||||||
clean := func(s string) string {
|
|
||||||
if i := strings.LastIndex(s, "//"); i != -1 {
|
|
||||||
s = s[:i]
|
|
||||||
}
|
|
||||||
return path.Clean(filepath.ToSlash(s))
|
|
||||||
}
|
|
||||||
for scanGot.Scan() && scanWant.Scan() {
|
|
||||||
got := clean(scanGot.Text())
|
|
||||||
want := clean(scanWant.Text())
|
|
||||||
if got != want {
|
|
||||||
t.Errorf("file %q differs from .want file at line %d:\n\t%s\n\t%s", gotFile, line, got, want)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
line++
|
|
||||||
}
|
|
||||||
if scanGot.Scan() || scanWant.Scan() {
|
|
||||||
t.Errorf("file %q differs from .want file at line %d.", gotFile, line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func writeJSON(t *testing.T, path string, x interface{}) {
|
|
||||||
data, err := json.MarshalIndent(x, "", " ")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := ioutil.WriteFile(path, data, 0644); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
4
vendor/golang.org/x/text/message/pipeline/rewrite.go
generated
vendored
4
vendor/golang.org/x/text/message/pipeline/rewrite.go
generated
vendored
|
@ -24,11 +24,11 @@ const printerType = "golang.org/x/text/message.Printer"
|
||||||
// machinery and rewrites strings to adopt best practices when possible.
|
// machinery and rewrites strings to adopt best practices when possible.
|
||||||
// If w is not nil the generated files are written to it, each files with a
|
// If w is not nil the generated files are written to it, each files with a
|
||||||
// "--- <filename>" header. Otherwise the files are overwritten.
|
// "--- <filename>" header. Otherwise the files are overwritten.
|
||||||
func Rewrite(w io.Writer, args ...string) error {
|
func Rewrite(w io.Writer, goPackage string) error {
|
||||||
conf := &loader.Config{
|
conf := &loader.Config{
|
||||||
AllowErrors: true, // Allow unused instances of message.Printer.
|
AllowErrors: true, // Allow unused instances of message.Printer.
|
||||||
}
|
}
|
||||||
prog, err := loadPackages(conf, args)
|
prog, err := loadPackages(conf, []string{goPackage})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return wrap(err, "")
|
return wrap(err, "")
|
||||||
}
|
}
|
||||||
|
|
85
vendor/golang.org/x/text/message/pipeline/testdata/test1/catalog_gen.go
generated
vendored
85
vendor/golang.org/x/text/message/pipeline/testdata/test1/catalog_gen.go
generated
vendored
|
@ -1,85 +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{
|
|
||||||
"de": &dictionary{index: deIndex, data: deData},
|
|
||||||
"en_US": &dictionary{index: en_USIndex, data: en_USData},
|
|
||||||
"zh": &dictionary{index: zhIndex, data: zhData},
|
|
||||||
}
|
|
||||||
fallback := language.MustParse("en-US")
|
|
||||||
cat, err := catalog.NewFromMap(dict, catalog.Fallback(fallback))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
message.DefaultCatalog = cat
|
|
||||||
}
|
|
||||||
|
|
||||||
var messageKeyToIndex = map[string]int{
|
|
||||||
"%.2[1]f miles traveled (%[1]f)": 8,
|
|
||||||
"%[1]s is visiting %[3]s!\n": 3,
|
|
||||||
"%d files remaining!": 4,
|
|
||||||
"%d more files remaining!": 5,
|
|
||||||
"%s is out of order!": 7,
|
|
||||||
"%s is visiting %s!\n": 2,
|
|
||||||
"Hello %s!\n": 1,
|
|
||||||
"Hello world!\n": 0,
|
|
||||||
"Use the following code for your discount: %d\n": 6,
|
|
||||||
}
|
|
||||||
|
|
||||||
var deIndex = []uint32{ // 10 elements
|
|
||||||
0x00000000, 0x00000011, 0x00000023, 0x0000003d,
|
|
||||||
0x00000057, 0x00000075, 0x00000094, 0x00000094,
|
|
||||||
0x00000094, 0x00000094,
|
|
||||||
} // Size: 64 bytes
|
|
||||||
|
|
||||||
const deData string = "" + // Size: 148 bytes
|
|
||||||
"\x04\x00\x01\x0a\x0c\x02Hallo Welt!\x04\x00\x01\x0a\x0d\x02Hallo %[1]s!" +
|
|
||||||
"\x04\x00\x01\x0a\x15\x02%[1]s besucht %[2]s!\x04\x00\x01\x0a\x15\x02%[1]" +
|
|
||||||
"s besucht %[3]s!\x02Noch zwei Bestände zu gehen!\x02Noch %[1]d Bestände " +
|
|
||||||
"zu gehen!"
|
|
||||||
|
|
||||||
var en_USIndex = []uint32{ // 10 elements
|
|
||||||
0x00000000, 0x00000012, 0x00000024, 0x00000042,
|
|
||||||
0x00000060, 0x00000077, 0x000000ba, 0x000000ef,
|
|
||||||
0x00000106, 0x00000125,
|
|
||||||
} // Size: 64 bytes
|
|
||||||
|
|
||||||
const en_USData string = "" + // Size: 293 bytes
|
|
||||||
"\x04\x00\x01\x0a\x0d\x02Hello world!\x04\x00\x01\x0a\x0d\x02Hello %[1]s!" +
|
|
||||||
"\x04\x00\x01\x0a\x19\x02%[1]s is visiting %[2]s!\x04\x00\x01\x0a\x19\x02" +
|
|
||||||
"%[1]s is visiting %[3]s!\x02%[1]d files remaining!\x14\x01\x81\x01\x00" +
|
|
||||||
"\x02\x14\x02One file remaining!\x00&\x02There are %[1]d more files remai" +
|
|
||||||
"ning!\x04\x00\x01\x0a0\x02Use the following code for your discount: %[1]" +
|
|
||||||
"d\x02%[1]s is out of order!\x02%.2[1]f miles traveled (%[1]f)"
|
|
||||||
|
|
||||||
var zhIndex = []uint32{ // 10 elements
|
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
||||||
0x00000000, 0x00000000,
|
|
||||||
} // Size: 64 bytes
|
|
||||||
|
|
||||||
const zhData string = ""
|
|
||||||
|
|
||||||
// Total table size 633 bytes (0KiB); checksum: 74B32E70
|
|
85
vendor/golang.org/x/text/message/pipeline/testdata/test1/catalog_gen.go.want
generated
vendored
85
vendor/golang.org/x/text/message/pipeline/testdata/test1/catalog_gen.go.want
generated
vendored
|
@ -1,85 +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{
|
|
||||||
"de": &dictionary{index: deIndex, data: deData},
|
|
||||||
"en_US": &dictionary{index: en_USIndex, data: en_USData},
|
|
||||||
"zh": &dictionary{index: zhIndex, data: zhData},
|
|
||||||
}
|
|
||||||
fallback := language.MustParse("en-US")
|
|
||||||
cat, err := catalog.NewFromMap(dict, catalog.Fallback(fallback))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
message.DefaultCatalog = cat
|
|
||||||
}
|
|
||||||
|
|
||||||
var messageKeyToIndex = map[string]int{
|
|
||||||
"%.2[1]f miles traveled (%[1]f)": 8,
|
|
||||||
"%[1]s is visiting %[3]s!\n": 3,
|
|
||||||
"%d files remaining!": 4,
|
|
||||||
"%d more files remaining!": 5,
|
|
||||||
"%s is out of order!": 7,
|
|
||||||
"%s is visiting %s!\n": 2,
|
|
||||||
"Hello %s!\n": 1,
|
|
||||||
"Hello world!\n": 0,
|
|
||||||
"Use the following code for your discount: %d\n": 6,
|
|
||||||
}
|
|
||||||
|
|
||||||
var deIndex = []uint32{ // 10 elements
|
|
||||||
0x00000000, 0x00000011, 0x00000023, 0x0000003d,
|
|
||||||
0x00000057, 0x00000075, 0x00000094, 0x00000094,
|
|
||||||
0x00000094, 0x00000094,
|
|
||||||
} // Size: 64 bytes
|
|
||||||
|
|
||||||
const deData string = "" + // Size: 148 bytes
|
|
||||||
"\x04\x00\x01\x0a\x0c\x02Hallo Welt!\x04\x00\x01\x0a\x0d\x02Hallo %[1]s!" +
|
|
||||||
"\x04\x00\x01\x0a\x15\x02%[1]s besucht %[2]s!\x04\x00\x01\x0a\x15\x02%[1]" +
|
|
||||||
"s besucht %[3]s!\x02Noch zwei Bestände zu gehen!\x02Noch %[1]d Bestände " +
|
|
||||||
"zu gehen!"
|
|
||||||
|
|
||||||
var en_USIndex = []uint32{ // 10 elements
|
|
||||||
0x00000000, 0x00000012, 0x00000024, 0x00000042,
|
|
||||||
0x00000060, 0x00000077, 0x000000ba, 0x000000ef,
|
|
||||||
0x00000106, 0x00000125,
|
|
||||||
} // Size: 64 bytes
|
|
||||||
|
|
||||||
const en_USData string = "" + // Size: 293 bytes
|
|
||||||
"\x04\x00\x01\x0a\x0d\x02Hello world!\x04\x00\x01\x0a\x0d\x02Hello %[1]s!" +
|
|
||||||
"\x04\x00\x01\x0a\x19\x02%[1]s is visiting %[2]s!\x04\x00\x01\x0a\x19\x02" +
|
|
||||||
"%[1]s is visiting %[3]s!\x02%[1]d files remaining!\x14\x01\x81\x01\x00" +
|
|
||||||
"\x02\x14\x02One file remaining!\x00&\x02There are %[1]d more files remai" +
|
|
||||||
"ning!\x04\x00\x01\x0a0\x02Use the following code for your discount: %[1]" +
|
|
||||||
"d\x02%[1]s is out of order!\x02%.2[1]f miles traveled (%[1]f)"
|
|
||||||
|
|
||||||
var zhIndex = []uint32{ // 10 elements
|
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
||||||
0x00000000, 0x00000000,
|
|
||||||
} // Size: 64 bytes
|
|
||||||
|
|
||||||
const zhData string = ""
|
|
||||||
|
|
||||||
// Total table size 633 bytes (0KiB); checksum: 74B32E70
|
|
49
vendor/golang.org/x/text/message/pipeline/testdata/test1/catalog_test.go
generated
vendored
49
vendor/golang.org/x/text/message/pipeline/testdata/test1/catalog_test.go
generated
vendored
|
@ -1,49 +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
|
|
||||||
|
|
||||||
import (
|
|
||||||
"path"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"golang.org/x/text/message"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestCatalog(t *testing.T) {
|
|
||||||
args := func(a ...interface{}) []interface{} { return a }
|
|
||||||
testCases := []struct {
|
|
||||||
lang string
|
|
||||||
key string
|
|
||||||
args []interface{}
|
|
||||||
want string
|
|
||||||
}{{
|
|
||||||
lang: "en",
|
|
||||||
key: "Hello world!\n",
|
|
||||||
want: "Hello world!\n",
|
|
||||||
}, {
|
|
||||||
lang: "de",
|
|
||||||
key: "Hello world!\n",
|
|
||||||
want: "Hallo Welt!\n",
|
|
||||||
}, {
|
|
||||||
lang: "en",
|
|
||||||
key: "%d more files remaining!",
|
|
||||||
args: args(1),
|
|
||||||
want: "One file remaining!",
|
|
||||||
}, {
|
|
||||||
lang: "en-u-nu-fullwide",
|
|
||||||
key: "%d more files remaining!",
|
|
||||||
args: args(5),
|
|
||||||
want: "There are 5 more files remaining!",
|
|
||||||
}}
|
|
||||||
for _, tc := range testCases {
|
|
||||||
t.Run(path.Join(tc.lang, tc.key), func(t *testing.T) {
|
|
||||||
p := message.NewPrinter(message.MatchLanguage(tc.lang))
|
|
||||||
got := p.Sprintf(tc.key, tc.args...)
|
|
||||||
if got != tc.want {
|
|
||||||
t.Errorf("got %q; want %q", got, tc.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
188
vendor/golang.org/x/text/message/pipeline/testdata/test1/extracted.gotext.json.want
generated
vendored
188
vendor/golang.org/x/text/message/pipeline/testdata/test1/extracted.gotext.json.want
generated
vendored
|
@ -1,188 +0,0 @@
|
||||||
{
|
|
||||||
"language": "en-US",
|
|
||||||
"messages": [
|
|
||||||
{
|
|
||||||
"id": "Hello world!",
|
|
||||||
"key": "Hello world!\n",
|
|
||||||
"message": "Hello world!",
|
|
||||||
"translation": "",
|
|
||||||
"position": "testdata/test1/test1.go:19:10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Hello {City}!",
|
|
||||||
"key": "Hello %s!\n",
|
|
||||||
"message": "Hello {City}!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "City",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "city"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"position": "testdata/test1/test1.go:24:10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"key": "%s is visiting %s!\n",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Person",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "person",
|
|
||||||
"comment": "The person of matter."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Place",
|
|
||||||
"string": "%[2]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 2,
|
|
||||||
"expr": "place",
|
|
||||||
"comment": "Place the person is visiting."
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"position": "testdata/test1/test1.go:30:10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"key": "%[1]s is visiting %[3]s!\n",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "",
|
|
||||||
"comment": "Field names are placeholders.",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Person",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "pp.Person"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Place",
|
|
||||||
"string": "%[3]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 3,
|
|
||||||
"expr": "pp.Place",
|
|
||||||
"comment": "Place the person is visiting."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Extra",
|
|
||||||
"string": "%[2]v",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 2,
|
|
||||||
"expr": "pp.extra"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"position": "testdata/test1/test1.go:44:10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{2} files remaining!",
|
|
||||||
"key": "%d files remaining!",
|
|
||||||
"message": "{2} files remaining!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "2",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "2"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"position": "testdata/test1/test1.go:51:10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{N} more files remaining!",
|
|
||||||
"key": "%d more files remaining!",
|
|
||||||
"message": "{N} more files remaining!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "N",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "n"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"position": "testdata/test1/test1.go:56:10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"key": "Use the following code for your discount: %d\n",
|
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "ReferralCode",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "./testdata/test1.referralCode",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "c"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"position": "testdata/test1/test1.go:64:10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": [
|
|
||||||
"msgOutOfOrder",
|
|
||||||
"{Device} is out of order!"
|
|
||||||
],
|
|
||||||
"key": "%s is out of order!",
|
|
||||||
"message": "{Device} is out of order!",
|
|
||||||
"translation": "",
|
|
||||||
"comment": "This comment wins.\n",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Device",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "device"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"position": "testdata/test1/test1.go:70:10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"key": "%.2[1]f miles traveled (%[1]f)",
|
|
||||||
"message": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Miles",
|
|
||||||
"string": "%.2[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Miles_1",
|
|
||||||
"string": "%[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"position": "testdata/test1/test1.go:74:10"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
123
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/de/messages.gotext.json
generated
vendored
123
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/de/messages.gotext.json
generated
vendored
|
@ -1,123 +0,0 @@
|
||||||
{
|
|
||||||
"language": "de",
|
|
||||||
"messages": [
|
|
||||||
{
|
|
||||||
"id": "Hello world!",
|
|
||||||
"key": "Hello world!\n",
|
|
||||||
"message": "Hello world!",
|
|
||||||
"translation": "Hallo Welt!"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Hello {City}!",
|
|
||||||
"key": "Hello %s!\n",
|
|
||||||
"message": "Hello {City}!",
|
|
||||||
"translation": "Hallo {City}!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "City",
|
|
||||||
"string": "%[1]s"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"key": "%s is visiting %s!\n",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "{Person} besucht {Place}!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Person",
|
|
||||||
"string": "%[1]s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Place",
|
|
||||||
"string": "%[2]s"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"key": "%[1]s is visiting %[3]s!\n",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "{Person} besucht {Place}!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Person",
|
|
||||||
"string": "%[1]s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Place",
|
|
||||||
"string": "%[3]s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Extra",
|
|
||||||
"string": "%[2]v"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{2} files remaining!",
|
|
||||||
"key": "%d files remaining!",
|
|
||||||
"message": "{N} files remaining!",
|
|
||||||
"translation": "Noch zwei Bestände zu gehen!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "2",
|
|
||||||
"string": "%[1]d"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{N} more files remaining!",
|
|
||||||
"key": "%d more files remaining!",
|
|
||||||
"message": "{N} more files remaining!",
|
|
||||||
"translation": "Noch {N} Bestände zu gehen!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "N",
|
|
||||||
"string": "%[1]d"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"key": "Use the following code for your discount: %d\n",
|
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "ReferralCode",
|
|
||||||
"string": "%[1]d"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": [ "msgOutOfOrder", "{Device} is out of order!" ],
|
|
||||||
"key": "%s is out of order!",
|
|
||||||
"message": "{Device} is out of order!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Device",
|
|
||||||
"string": "%[1]s"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"key": "%.2[1]f miles traveled (%[1]f)",
|
|
||||||
"message": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Miles",
|
|
||||||
"string": "%.2[1]f"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Miles_1",
|
|
||||||
"string": "%[1]f"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
137
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/de/out.gotext.json
generated
vendored
137
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/de/out.gotext.json
generated
vendored
|
@ -1,137 +0,0 @@
|
||||||
{
|
|
||||||
"language": "de",
|
|
||||||
"messages": [
|
|
||||||
{
|
|
||||||
"id": "Hello world!",
|
|
||||||
"message": "Hello world!",
|
|
||||||
"translation": "Hallo Welt!"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Hello {City}!",
|
|
||||||
"message": "Hello {City}!",
|
|
||||||
"translation": "Hallo {City}!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "City",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "city"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "{Person} besucht {Place}!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Person",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "person",
|
|
||||||
"comment": "The person of matter."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Place",
|
|
||||||
"string": "%[2]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 2,
|
|
||||||
"expr": "place",
|
|
||||||
"comment": "Place the person is visiting."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{2} files remaining!",
|
|
||||||
"message": "{2} files remaining!",
|
|
||||||
"translation": "Noch zwei Bestände zu gehen!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "2",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "2"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{N} more files remaining!",
|
|
||||||
"message": "{N} more files remaining!",
|
|
||||||
"translation": "Noch {N} Bestände zu gehen!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "N",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "n"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "ReferralCode",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "./testdata/test1.referralCode",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "c"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": [
|
|
||||||
"msgOutOfOrder",
|
|
||||||
"{Device} is out of order!"
|
|
||||||
],
|
|
||||||
"message": "{Device} is out of order!",
|
|
||||||
"translation": "",
|
|
||||||
"comment": "This comment wins.\n",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Device",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "device"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"message": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Miles",
|
|
||||||
"string": "%.2[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Miles_1",
|
|
||||||
"string": "%[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
137
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/de/out.gotext.json.want
generated
vendored
137
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/de/out.gotext.json.want
generated
vendored
|
@ -1,137 +0,0 @@
|
||||||
{
|
|
||||||
"language": "de",
|
|
||||||
"messages": [
|
|
||||||
{
|
|
||||||
"id": "Hello world!",
|
|
||||||
"message": "Hello world!",
|
|
||||||
"translation": "Hallo Welt!"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Hello {City}!",
|
|
||||||
"message": "Hello {City}!",
|
|
||||||
"translation": "Hallo {City}!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "City",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "city"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "{Person} besucht {Place}!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Person",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "person",
|
|
||||||
"comment": "The person of matter."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Place",
|
|
||||||
"string": "%[2]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 2,
|
|
||||||
"expr": "place",
|
|
||||||
"comment": "Place the person is visiting."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{2} files remaining!",
|
|
||||||
"message": "{2} files remaining!",
|
|
||||||
"translation": "Noch zwei Bestände zu gehen!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "2",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "2"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{N} more files remaining!",
|
|
||||||
"message": "{N} more files remaining!",
|
|
||||||
"translation": "Noch {N} Bestände zu gehen!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "N",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "n"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "ReferralCode",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "./testdata/test1.referralCode",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "c"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": [
|
|
||||||
"msgOutOfOrder",
|
|
||||||
"{Device} is out of order!"
|
|
||||||
],
|
|
||||||
"message": "{Device} is out of order!",
|
|
||||||
"translation": "",
|
|
||||||
"comment": "This comment wins.\n",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Device",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "device"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"message": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Miles",
|
|
||||||
"string": "%.2[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Miles_1",
|
|
||||||
"string": "%[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,91 +0,0 @@
|
||||||
{
|
|
||||||
"language": "en-US",
|
|
||||||
"messages": [
|
|
||||||
{
|
|
||||||
"id": "Hello world!",
|
|
||||||
"key": "Hello world!\n",
|
|
||||||
"message": "Hello world!",
|
|
||||||
"translation": "Hello world!"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Hello {City}!",
|
|
||||||
"key": "Hello %s!\n",
|
|
||||||
"message": "Hello {City}!",
|
|
||||||
"translation": "Hello {City}!"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Hello {Town}!",
|
|
||||||
"key": "Hello %s!\n",
|
|
||||||
"message": "Hello {Town}!",
|
|
||||||
"translation": "Hello {Town}!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Town",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "town",
|
|
||||||
"comment": "Town"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"key": "%s is visiting %s!\n",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "{Person} is visiting {Place}!"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"key": "%[1]s is visiting %[3]s!\n",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "{Person} is visiting {Place}!"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{2} files remaining!",
|
|
||||||
"key": "%d files remaining!",
|
|
||||||
"message": "{N} files remaining!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "2",
|
|
||||||
"string": "%[1]d"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{N} more files remaining!",
|
|
||||||
"key": "%d more files remaining!",
|
|
||||||
"message": "{N} more files remaining!",
|
|
||||||
"translation": {
|
|
||||||
"select": {
|
|
||||||
"feature": "plural",
|
|
||||||
"arg": "N",
|
|
||||||
"cases": {
|
|
||||||
"one": "One file remaining!",
|
|
||||||
"other": "There are {N} more files remaining!"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"key": "Use the following code for your discount: %d\n",
|
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"translation": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": [ "msgOutOfOrder", "{Device} is out of order!" ],
|
|
||||||
"key": "%s is out of order!",
|
|
||||||
"message": "{Device} is out of order!",
|
|
||||||
"translation": "{Device} is out of order!"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"key": "%.2[1]f miles traveled (%[1]f)",
|
|
||||||
"message": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"translation": "{Miles} miles traveled ({Miles_1})"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
154
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/en-US/out.gotext.json
generated
vendored
154
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/en-US/out.gotext.json
generated
vendored
|
@ -1,154 +0,0 @@
|
||||||
{
|
|
||||||
"language": "en-US",
|
|
||||||
"messages": [
|
|
||||||
{
|
|
||||||
"id": "Hello world!",
|
|
||||||
"message": "Hello world!",
|
|
||||||
"translation": "Hello world!"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Hello {City}!",
|
|
||||||
"message": "Hello {City}!",
|
|
||||||
"translation": "Hello {City}!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "City",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "city"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "{Person} is visiting {Place}!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Person",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "person",
|
|
||||||
"comment": "The person of matter."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Place",
|
|
||||||
"string": "%[2]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 2,
|
|
||||||
"expr": "place",
|
|
||||||
"comment": "Place the person is visiting."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{2} files remaining!",
|
|
||||||
"message": "{2} files remaining!",
|
|
||||||
"translation": "{2} files remaining!",
|
|
||||||
"translatorComment": "Copied from source.",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "2",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "2"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"fuzzy": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{N} more files remaining!",
|
|
||||||
"message": "{N} more files remaining!",
|
|
||||||
"translation": {
|
|
||||||
"select": {
|
|
||||||
"feature": "plural",
|
|
||||||
"arg": "N",
|
|
||||||
"cases": {
|
|
||||||
"one": {
|
|
||||||
"msg": "One file remaining!"
|
|
||||||
},
|
|
||||||
"other": {
|
|
||||||
"msg": "There are {N} more files remaining!"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "N",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "n"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"translation": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"translatorComment": "Copied from source.",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "ReferralCode",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "./testdata/test1.referralCode",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "c"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"fuzzy": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": [
|
|
||||||
"msgOutOfOrder",
|
|
||||||
"{Device} is out of order!"
|
|
||||||
],
|
|
||||||
"message": "{Device} is out of order!",
|
|
||||||
"translation": "{Device} is out of order!",
|
|
||||||
"comment": "This comment wins.\n",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Device",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "device"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"message": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"translation": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Miles",
|
|
||||||
"string": "%.2[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Miles_1",
|
|
||||||
"string": "%[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
154
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/en-US/out.gotext.json.want
generated
vendored
154
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/en-US/out.gotext.json.want
generated
vendored
|
@ -1,154 +0,0 @@
|
||||||
{
|
|
||||||
"language": "en-US",
|
|
||||||
"messages": [
|
|
||||||
{
|
|
||||||
"id": "Hello world!",
|
|
||||||
"message": "Hello world!",
|
|
||||||
"translation": "Hello world!"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Hello {City}!",
|
|
||||||
"message": "Hello {City}!",
|
|
||||||
"translation": "Hello {City}!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "City",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "city"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "{Person} is visiting {Place}!",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Person",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "person",
|
|
||||||
"comment": "The person of matter."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Place",
|
|
||||||
"string": "%[2]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 2,
|
|
||||||
"expr": "place",
|
|
||||||
"comment": "Place the person is visiting."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{2} files remaining!",
|
|
||||||
"message": "{2} files remaining!",
|
|
||||||
"translation": "{2} files remaining!",
|
|
||||||
"translatorComment": "Copied from source.",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "2",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "2"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"fuzzy": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{N} more files remaining!",
|
|
||||||
"message": "{N} more files remaining!",
|
|
||||||
"translation": {
|
|
||||||
"select": {
|
|
||||||
"feature": "plural",
|
|
||||||
"arg": "N",
|
|
||||||
"cases": {
|
|
||||||
"one": {
|
|
||||||
"msg": "One file remaining!"
|
|
||||||
},
|
|
||||||
"other": {
|
|
||||||
"msg": "There are {N} more files remaining!"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "N",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "n"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"translation": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"translatorComment": "Copied from source.",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "ReferralCode",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "./testdata/test1.referralCode",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "c"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"fuzzy": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": [
|
|
||||||
"msgOutOfOrder",
|
|
||||||
"{Device} is out of order!"
|
|
||||||
],
|
|
||||||
"message": "{Device} is out of order!",
|
|
||||||
"translation": "{Device} is out of order!",
|
|
||||||
"comment": "This comment wins.\n",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Device",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "device"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"message": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"translation": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Miles",
|
|
||||||
"string": "%.2[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Miles_1",
|
|
||||||
"string": "%[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
135
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/zh/messages.gotext.json
generated
vendored
135
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/zh/messages.gotext.json
generated
vendored
|
@ -1,135 +0,0 @@
|
||||||
{
|
|
||||||
"language": "zh",
|
|
||||||
"messages": [
|
|
||||||
{
|
|
||||||
"id": "Hello world!",
|
|
||||||
"key": "Hello world!\n",
|
|
||||||
"message": "Hello world!",
|
|
||||||
"translation": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Hello {City}!",
|
|
||||||
"key": "Hello %s!\n",
|
|
||||||
"message": "Hello {City}!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "City",
|
|
||||||
"string": "%[1]s"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Hello {Town}!",
|
|
||||||
"key": "Hello %s!\n",
|
|
||||||
"message": "Hello {Town}!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Town",
|
|
||||||
"string": "%[1]s"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"key": "%s is visiting %s!\n",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Person",
|
|
||||||
"string": "%[1]s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Place",
|
|
||||||
"string": "%[2]s"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"key": "%[1]s is visiting %[3]s!\n",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Person",
|
|
||||||
"string": "%[1]s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Place",
|
|
||||||
"string": "%[3]s"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Extra",
|
|
||||||
"string": "%[2]v"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{2} files remaining!",
|
|
||||||
"key": "%d files remaining!",
|
|
||||||
"message": "{2} files remaining!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "",
|
|
||||||
"string": "%[1]d"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{N} more files remaining!",
|
|
||||||
"key": "%d more files remaining!",
|
|
||||||
"message": "{N} more files remaining!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "N",
|
|
||||||
"string": "%[1]d"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"key": "Use the following code for your discount: %d\n",
|
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "ReferralCode",
|
|
||||||
"string": "%[1]d"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": [ "{Device} is out of order!", "msgOutOfOrder" ],
|
|
||||||
"key": "%s is out of order!",
|
|
||||||
"message": "{Device} is out of order!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Device",
|
|
||||||
"string": "%[1]s"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"key": "%.2[1]f miles traveled (%[1]f)",
|
|
||||||
"message": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Miles",
|
|
||||||
"string": "%.2[1]f"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Miles_1",
|
|
||||||
"string": "%[1]f"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
137
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/zh/out.gotext.json
generated
vendored
137
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/zh/out.gotext.json
generated
vendored
|
@ -1,137 +0,0 @@
|
||||||
{
|
|
||||||
"language": "zh",
|
|
||||||
"messages": [
|
|
||||||
{
|
|
||||||
"id": "Hello world!",
|
|
||||||
"message": "Hello world!",
|
|
||||||
"translation": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Hello {City}!",
|
|
||||||
"message": "Hello {City}!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "City",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "city"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Person",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "person",
|
|
||||||
"comment": "The person of matter."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Place",
|
|
||||||
"string": "%[2]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 2,
|
|
||||||
"expr": "place",
|
|
||||||
"comment": "Place the person is visiting."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{2} files remaining!",
|
|
||||||
"message": "{2} files remaining!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "2",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "2"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{N} more files remaining!",
|
|
||||||
"message": "{N} more files remaining!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "N",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "n"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "ReferralCode",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "./testdata/test1.referralCode",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "c"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": [
|
|
||||||
"msgOutOfOrder",
|
|
||||||
"{Device} is out of order!"
|
|
||||||
],
|
|
||||||
"message": "{Device} is out of order!",
|
|
||||||
"translation": "",
|
|
||||||
"comment": "This comment wins.\n",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Device",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "device"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"message": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Miles",
|
|
||||||
"string": "%.2[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Miles_1",
|
|
||||||
"string": "%[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
137
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/zh/out.gotext.json.want
generated
vendored
137
vendor/golang.org/x/text/message/pipeline/testdata/test1/locales/zh/out.gotext.json.want
generated
vendored
|
@ -1,137 +0,0 @@
|
||||||
{
|
|
||||||
"language": "zh",
|
|
||||||
"messages": [
|
|
||||||
{
|
|
||||||
"id": "Hello world!",
|
|
||||||
"message": "Hello world!",
|
|
||||||
"translation": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Hello {City}!",
|
|
||||||
"message": "Hello {City}!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "City",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "city"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Person} is visiting {Place}!",
|
|
||||||
"message": "{Person} is visiting {Place}!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Person",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "person",
|
|
||||||
"comment": "The person of matter."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Place",
|
|
||||||
"string": "%[2]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 2,
|
|
||||||
"expr": "place",
|
|
||||||
"comment": "Place the person is visiting."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{2} files remaining!",
|
|
||||||
"message": "{2} files remaining!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "2",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "2"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{N} more files remaining!",
|
|
||||||
"message": "{N} more files remaining!",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "N",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "int",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "n"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"message": "Use the following code for your discount: {ReferralCode}",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "ReferralCode",
|
|
||||||
"string": "%[1]d",
|
|
||||||
"type": "./testdata/test1.referralCode",
|
|
||||||
"underlyingType": "int",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "c"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": [
|
|
||||||
"msgOutOfOrder",
|
|
||||||
"{Device} is out of order!"
|
|
||||||
],
|
|
||||||
"message": "{Device} is out of order!",
|
|
||||||
"translation": "",
|
|
||||||
"comment": "This comment wins.\n",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Device",
|
|
||||||
"string": "%[1]s",
|
|
||||||
"type": "string",
|
|
||||||
"underlyingType": "string",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "device"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"message": "{Miles} miles traveled ({Miles_1})",
|
|
||||||
"translation": "",
|
|
||||||
"placeholders": [
|
|
||||||
{
|
|
||||||
"id": "Miles",
|
|
||||||
"string": "%.2[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Miles_1",
|
|
||||||
"string": "%[1]f",
|
|
||||||
"type": "float64",
|
|
||||||
"underlyingType": "float64",
|
|
||||||
"argNum": 1,
|
|
||||||
"expr": "miles"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
75
vendor/golang.org/x/text/message/pipeline/testdata/test1/test1.go
generated
vendored
75
vendor/golang.org/x/text/message/pipeline/testdata/test1/test1.go
generated
vendored
|
@ -1,75 +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
|
|
||||||
|
|
||||||
import "golang.org/x/text/message"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
p := message.NewPrinter(message.MatchLanguage("en"))
|
|
||||||
|
|
||||||
// NOT EXTRACTED: strings passed to Println are not extracted.
|
|
||||||
p.Println("Hello world!")
|
|
||||||
|
|
||||||
// NOT EXTRACTED: strings passed to Print are not extracted.
|
|
||||||
p.Print("Hello world!\n")
|
|
||||||
|
|
||||||
// Extract and trim whitespace (TODO).
|
|
||||||
p.Printf("Hello world!\n")
|
|
||||||
|
|
||||||
// NOT EXTRACTED: city is not used as a pattern or passed to %m.
|
|
||||||
city := "Amsterdam"
|
|
||||||
// This comment is extracted.
|
|
||||||
p.Printf("Hello %s!\n", city)
|
|
||||||
|
|
||||||
person := "Sheila"
|
|
||||||
place := "Zürich"
|
|
||||||
|
|
||||||
// Substitutions replaced by variable names.
|
|
||||||
p.Printf("%s is visiting %s!\n",
|
|
||||||
person, // The person of matter.
|
|
||||||
place, // Place the person is visiting.
|
|
||||||
)
|
|
||||||
|
|
||||||
pp := struct {
|
|
||||||
Person string // The person of matter. // TODO: get this comment.
|
|
||||||
Place string
|
|
||||||
extra int
|
|
||||||
}{
|
|
||||||
person, place, 4,
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract will drop this comment in favor of the one below.
|
|
||||||
p.Printf("%[1]s is visiting %[3]s!\n", // Field names are placeholders.
|
|
||||||
pp.Person,
|
|
||||||
pp.extra,
|
|
||||||
pp.Place, // Place the person is visiting.
|
|
||||||
)
|
|
||||||
|
|
||||||
// Numeric literal becomes placeholder.
|
|
||||||
p.Printf("%d files remaining!", 2)
|
|
||||||
|
|
||||||
const n = 2
|
|
||||||
|
|
||||||
// Constant identifier becomes placeholder.
|
|
||||||
p.Printf("%d more files remaining!", n)
|
|
||||||
|
|
||||||
// Infer better names from type names.
|
|
||||||
type referralCode int
|
|
||||||
|
|
||||||
const c = referralCode(5)
|
|
||||||
|
|
||||||
// Use type name as placeholder.
|
|
||||||
p.Printf("Use the following code for your discount: %d\n", c)
|
|
||||||
|
|
||||||
// Use constant name as message ID.
|
|
||||||
const msgOutOfOrder = "%s is out of order!" // This comment wins.
|
|
||||||
const device = "Soda machine"
|
|
||||||
// This message has two IDs.
|
|
||||||
p.Printf(msgOutOfOrder, device)
|
|
||||||
|
|
||||||
// Multiple substitutions for same argument.
|
|
||||||
miles := 1.2345
|
|
||||||
p.Printf("%.2[1]f miles traveled (%[1]f)", miles)
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue