vendor updates

This commit is contained in:
Serguei Bezverkhi
2018-03-06 17:33:18 -05:00
parent 4b3ebc171b
commit e9033989a0
5854 changed files with 248382 additions and 119809 deletions

View File

@ -21,9 +21,6 @@ const (
// NOTE: The command line tool already prefixes with "gotext:".
var (
wrap = func(err error, msg string) error {
if err == nil {
return nil
}
return fmt.Errorf("%s: %v", msg, err)
}
errorf = fmt.Errorf

View File

@ -37,48 +37,40 @@ func init() {
}
var messageKeyToIndex = map[string]int{
"%.2[1]f miles traveled (%[1]f)": 8,
"%[1]s is visiting %[3]s!\n": 3,
"%d files remaining!": 5,
"%d more files remaining!": 4,
"%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,
"%.2[1]f miles traveled (%[1]f)": 6,
"%[1]s is visiting %[3]s!\n": 3,
"%d more files remaining!": 4,
"%s is out of order!": 5,
"%s is visiting %s!\n": 2,
"Hello %s!\n": 1,
"Hello world!\n": 0,
}
var deIndex = []uint32{ // 10 elements
0x00000000, 0x00000011, 0x00000023, 0x0000003d,
0x00000057, 0x00000076, 0x00000076, 0x00000076,
0x00000076, 0x00000076,
} // Size: 64 bytes
var deIndex = []uint32{ // 8 elements
0x00000000, 0x0000000d, 0x0000001b, 0x00000031,
0x00000047, 0x00000066, 0x00000066, 0x00000066,
} // Size: 56 bytes
const deData string = "" + // Size: 118 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 %[1]d Bestände zu gehen!"
const deData string = "" + // Size: 102 bytes
"\x02Hallo Welt!\x0a\x02Hallo %[1]s!\x0a\x02%[1]s besucht %[2]s!\x0a\x02%" +
"[1]s besucht %[3]s!\x0a\x02Noch %[1]d Bestände zu gehen!"
var en_USIndex = []uint32{ // 10 elements
0x00000000, 0x00000012, 0x00000024, 0x00000042,
0x00000060, 0x000000a3, 0x000000ba, 0x000000ef,
0x00000106, 0x00000125,
} // Size: 64 bytes
var en_USIndex = []uint32{ // 8 elements
0x00000000, 0x0000000e, 0x0000001c, 0x00000036,
0x00000050, 0x00000093, 0x000000aa, 0x000000c9,
} // Size: 56 bytes
const en_USData string = "" + // Size: 293 bytes
"\x04\x00\x01\x0a\x0d\x02Hello world!\x04\x00\x01\x0a\x0d\x02Hello %[1]sn" +
"\x04\x00\x01\x0a\x19\x02%[1]s is visiting %[2]s!\x04\x00\x01\x0a\x19\x02" +
"%[1]s is visiting %[3]s!\x14\x01\x81\x01\x00\x02\x14\x02One file remaini" +
"ng!\x00&\x02There are %[1]d more files remaining!\x02%[1]d files remaini" +
"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)"
const en_USData string = "" + // Size: 201 bytes
"\x02Hello world!\x0a\x02Hello %[1]s!\x0a\x02%[1]s is visiting %[2]s!\x0a" +
"\x02%[1]s is visiting %[3]s!\x0a\x04\x01\x81\x01\x00\x02\x14\x02One file" +
" remaining!\x00&\x02There are %[1]d more files remaining!\x02%[1]s is ou" +
"t 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,
} // Size: 64 bytes
} // Size: 56 bytes
const zhData string = ""
// Total table size 603 bytes (0KiB); checksum: 1D2754EE
// Total table size 471 bytes (0KiB); checksum: 7746955

View File

@ -2,17 +2,17 @@
"language": "de",
"messages": [
{
"id": "Hello world!",
"id": "Hello world!\n",
"key": "Hello world!\n",
"message": "Hello world!",
"translation": "Hallo Welt!",
"message": "Hello world!\n",
"translation": "Hallo Welt!\n",
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:27:10"
},
{
"id": "Hello {City}!",
"id": "Hello {City}!\n",
"key": "Hello %s!\n",
"message": "Hello {City}!",
"translation": "Hallo {City}!",
"message": "Hello {City}!\n",
"translation": "Hallo {City}!\n",
"placeholders": [
{
"id": "City",
@ -26,10 +26,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",
"message": "Hello {Town}!",
"translation": "Hallo {Town}!",
"message": "Hello {Town}!\n",
"translation": "Hallo {Town}!\n",
"placeholders": [
{
"id": "Town",
@ -44,10 +44,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",
"message": "{Person} is visiting {Place}!",
"translation": "{Person} besucht {Place}!",
"message": "{Person} is visiting {Place}!\n",
"translation": "{Person} besucht {Place}!\n",
"placeholders": [
{
"id": "Person",
@ -71,10 +71,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",
"message": "{Person} is visiting {Place}!",
"translation": "{Person} besucht {Place}!",
"message": "{Person} is visiting {Place}!\n",
"translation": "{Person} besucht {Place}!\n",
"comment": "Person visiting a place.",
"placeholders": [
{
@ -123,9 +123,9 @@
"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",
"message": "Use the following code for your discount: {ReferralCode}",
"message": "Use the following code for your discount: {ReferralCode}\n",
"translation": "",
"placeholders": [
{

View File

@ -2,14 +2,17 @@
"language": "de",
"messages": [
{
"id": "Hello world!",
"message": "Hello world!",
"translation": "Hallo Welt!"
"id": "Hello world!\n",
"key": "Hello world!\n",
"message": "Hello world!\n",
"translation": "",
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:28:10"
},
{
"id": "Hello {City}!",
"message": "Hello {City}!",
"translation": "Hallo {City}!",
"id": "Hello {City}!\n",
"key": "Hello %s!\n",
"message": "Hello {City}!\n",
"translation": "",
"placeholders": [
{
"id": "City",
@ -19,12 +22,32 @@
"argNum": 1,
"expr": "city"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:32:10"
},
{
"id": "{Person} is visiting {Place}!",
"message": "{Person} is visiting {Place}!",
"translation": "{Person} besucht {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",
"message": "{Person} is visiting {Place}!\n",
"translation": "",
"placeholders": [
{
"id": "Person",
@ -44,27 +67,66 @@
"expr": "place",
"comment": "Place the person is visiting."
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:41:10"
},
{
"id": "{2} files remaining!",
"message": "{2} files remaining!",
"id": "{Person} is visiting {Place}!\n",
"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": "",
"placeholders": [
{
"id": "2",
"id": "",
"string": "%[1]d",
"type": "int",
"underlyingType": "int",
"argNum": 1,
"expr": "2"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:63:10"
},
{
"id": "{N} more files remaining!",
"key": "%d more files remaining!",
"message": "{N} more files remaining!",
"translation": "Noch {N} Bestände zu gehen!",
"translation": "",
"placeholders": [
{
"id": "N",
@ -74,11 +136,13 @@
"argNum": 1,
"expr": "n"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:68:10"
},
{
"id": "Use the following code for your discount: {ReferralCode}",
"message": "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",
"message": "Use the following code for your discount: {ReferralCode}\n",
"translation": "",
"placeholders": [
{
@ -89,13 +153,15 @@
"argNum": 1,
"expr": "c"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:74:10"
},
{
"id": [
"msgOutOfOrder",
"{Device} is out of order!"
],
"key": "%s is out of order!",
"message": "{Device} is out of order!",
"translation": "",
"comment": "FOO\n",
@ -108,10 +174,12 @@
"argNum": 1,
"expr": "device"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:82:10"
},
{
"id": "{Miles} miles traveled ({Miles_1})",
"key": "%.2[1]f miles traveled (%[1]f)",
"message": "{Miles} miles traveled ({Miles_1})",
"translation": "",
"placeholders": [
@ -131,7 +199,8 @@
"argNum": 1,
"expr": "miles"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:86:10"
}
]
}

View File

@ -2,23 +2,23 @@
"language": "en-US",
"messages": [
{
"id": "Hello world!",
"id": "Hello world!\n",
"key": "Hello world!\n",
"message": "Hello world!",
"translation": "Hello world!",
"message": "Hello world!\n",
"translation": "Hello world!\n",
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:27:10"
},
{
"id": "Hello {City}!",
"id": "Hello {City}!\n",
"key": "Hello %s!\n",
"message": "Hello {City}!",
"translation": "Hello {City}n"
"message": "Hello {City}!\n",
"translation": "Hello {City}!\n"
},
{
"id": "Hello {Town}!",
"id": "Hello {Town}!\n",
"key": "Hello %s!\n",
"message": "Hello {Town}!",
"translation": "Hello {Town}!",
"message": "Hello {Town}!\n",
"translation": "Hello {Town}!\n",
"placeholders": [
{
"id": "Town",
@ -32,16 +32,16 @@
]
},
{
"id": "{Person} is visiting {Place}!",
"id": "{Person} is visiting {Place}!\n",
"key": "%s is visiting %s!\n",
"message": "{Person} is visiting {Place}!",
"message": "{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",
"message": "{Person} is visiting {Place}!",
"translation": "{Person} is visiting {Place}!",
"message": "{Person} is visiting {Place}!\n",
"translation": "{Person} is visiting {Place}!\n",
"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",
"message": "Use the following code for your discount: {ReferralCode}",
"message": "Use the following code for your discount: {ReferralCode}\n",
"translation": ""
},
{

View File

@ -2,14 +2,17 @@
"language": "en-US",
"messages": [
{
"id": "Hello world!",
"message": "Hello world!",
"translation": "Hello world!"
"id": "Hello world!\n",
"key": "Hello world!\n",
"message": "Hello world!\n",
"translation": "",
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:28:10"
},
{
"id": "Hello {City}!",
"message": "Hello {City}!",
"translation": "Hello {City}n",
"id": "Hello {City}!\n",
"key": "Hello %s!\n",
"message": "Hello {City}!\n",
"translation": "",
"placeholders": [
{
"id": "City",
@ -19,12 +22,32 @@
"argNum": 1,
"expr": "city"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:32:10"
},
{
"id": "{Person} is visiting {Place}!",
"message": "{Person} is visiting {Place}!",
"translation": "{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",
"message": "{Person} is visiting {Place}!\n",
"translation": "",
"placeholders": [
{
"id": "Person",
@ -44,16 +67,52 @@
"expr": "place",
"comment": "Place the person is visiting."
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:41:10"
},
{
"id": "{2} files remaining!",
"message": "{2} files remaining!",
"translation": "{2} files remaining!",
"translatorComment": "Copied from source.",
"id": "{Person} is visiting {Place}!\n",
"key": "%[1]s is visiting %[3]s!\n",
"message": "{Person} is visiting {Place}!\n",
"translation": "",
"comment": "Person visiting a place.",
"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",
"type": "int",
"underlyingType": "int",
@ -61,25 +120,13 @@
"expr": "2"
}
],
"fuzzy": true
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:63:10"
},
{
"id": "{N} more files remaining!",
"key": "%d 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!"
}
}
}
},
"translation": "",
"placeholders": [
{
"id": "N",
@ -89,13 +136,14 @@
"argNum": 1,
"expr": "n"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:68:10"
},
{
"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.",
"id": "Use the following code for your discount: {ReferralCode}\n",
"key": "Use the following code for your discount: %d\n",
"message": "Use the following code for your discount: {ReferralCode}\n",
"translation": "",
"placeholders": [
{
"id": "ReferralCode",
@ -106,15 +154,16 @@
"expr": "c"
}
],
"fuzzy": true
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:74:10"
},
{
"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!",
"translation": "",
"comment": "FOO\n",
"placeholders": [
{
@ -125,12 +174,14 @@
"argNum": 1,
"expr": "device"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:82:10"
},
{
"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})",
"translation": "",
"placeholders": [
{
"id": "Miles",
@ -148,7 +199,8 @@
"argNum": 1,
"expr": "miles"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:86:10"
}
]
}

View File

@ -0,0 +1,206 @@
{
"language": "en-US",
"messages": [
{
"id": "Hello world!\n",
"key": "Hello world!\n",
"message": "Hello world!\n",
"translation": "",
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:28:10"
},
{
"id": "Hello {City}!\n",
"key": "Hello %s!\n",
"message": "Hello {City}!\n",
"translation": "",
"placeholders": [
{
"id": "City",
"string": "%[1]s",
"type": "string",
"underlyingType": "string",
"argNum": 1,
"expr": "city"
}
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:32:10"
},
{
"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",
"message": "{Person} is visiting {Place}!\n",
"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": "golang.org/x/text/cmd/gotext/examples/extract/main.go:41:10"
},
{
"id": "{Person} is visiting {Place}!\n",
"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": "",
"placeholders": [
{
"id": "",
"string": "%[1]d",
"type": "int",
"underlyingType": "int",
"argNum": 1,
"expr": "2"
}
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:63: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": "golang.org/x/text/cmd/gotext/examples/extract/main.go:68:10"
},
{
"id": "Use the following code for your discount: {ReferralCode}\n",
"key": "Use the following code for your discount: %d\n",
"message": "Use the following code for your discount: {ReferralCode}\n",
"translation": "",
"placeholders": [
{
"id": "ReferralCode",
"string": "%[1]d",
"type": "golang.org/x/text/cmd/gotext/examples/extract.referralCode",
"underlyingType": "int",
"argNum": 1,
"expr": "c"
}
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:74:10"
},
{
"id": [
"msgOutOfOrder",
"{Device} is out of order!"
],
"key": "%s is out of order!",
"message": "{Device} is out of order!",
"translation": "",
"comment": "FOO\n",
"placeholders": [
{
"id": "Device",
"string": "%[1]s",
"type": "string",
"underlyingType": "string",
"argNum": 1,
"expr": "device"
}
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:82: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": "golang.org/x/text/cmd/gotext/examples/extract/main.go:86:10"
}
]
}

View File

@ -2,16 +2,16 @@
"language": "zh",
"messages": [
{
"id": "Hello world!",
"id": "Hello world!\n",
"key": "Hello world!\n",
"message": "Hello world!",
"message": "Hello world!\n",
"translation": "",
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:27:10"
},
{
"id": "Hello {City}!",
"id": "Hello {City}!\n",
"key": "Hello %s!\n",
"message": "Hello {City}!",
"message": "Hello {City}!\n",
"translation": "",
"placeholders": [
{
@ -26,9 +26,9 @@
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:31:10"
},
{
"id": "Hello {Town}!",
"id": "Hello {Town}!\n",
"key": "Hello %s!\n",
"message": "Hello {Town}!",
"message": "Hello {Town}!\n",
"translation": "",
"placeholders": [
{
@ -44,9 +44,9 @@
"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",
"message": "{Person} is visiting {Place}!",
"message": "{Person} is visiting {Place}!\n",
"translation": "",
"placeholders": [
{
@ -71,9 +71,9 @@
"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",
"message": "{Person} is visiting {Place}!",
"message": "{Person} is visiting {Place}!\n",
"translation": "",
"comment": "Person visiting a place.",
"placeholders": [

View File

@ -2,13 +2,16 @@
"language": "zh",
"messages": [
{
"id": "Hello world!",
"message": "Hello world!",
"translation": ""
"id": "Hello world!\n",
"key": "Hello world!\n",
"message": "Hello world!\n",
"translation": "",
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:28:10"
},
{
"id": "Hello {City}!",
"message": "Hello {City}!",
"id": "Hello {City}!\n",
"key": "Hello %s!\n",
"message": "Hello {City}!\n",
"translation": "",
"placeholders": [
{
@ -19,11 +22,31 @@
"argNum": 1,
"expr": "city"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:32:10"
},
{
"id": "{Person} is visiting {Place}!",
"message": "{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",
"message": "{Person} is visiting {Place}!\n",
"translation": "",
"placeholders": [
{
@ -44,25 +67,64 @@
"expr": "place",
"comment": "Place the person is visiting."
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:41:10"
},
{
"id": "{2} files remaining!",
"message": "{2} files remaining!",
"id": "{Person} is visiting {Place}!\n",
"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": "",
"placeholders": [
{
"id": "2",
"id": "",
"string": "%[1]d",
"type": "int",
"underlyingType": "int",
"argNum": 1,
"expr": "2"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:63:10"
},
{
"id": "{N} more files remaining!",
"key": "%d more files remaining!",
"message": "{N} more files remaining!",
"translation": "",
"placeholders": [
@ -74,11 +136,13 @@
"argNum": 1,
"expr": "n"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:68:10"
},
{
"id": "Use the following code for your discount: {ReferralCode}",
"message": "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",
"message": "Use the following code for your discount: {ReferralCode}\n",
"translation": "",
"placeholders": [
{
@ -89,13 +153,15 @@
"argNum": 1,
"expr": "c"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:74:10"
},
{
"id": [
"msgOutOfOrder",
"{Device} is out of order!"
],
"key": "%s is out of order!",
"message": "{Device} is out of order!",
"translation": "",
"comment": "FOO\n",
@ -108,10 +174,12 @@
"argNum": 1,
"expr": "device"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:82:10"
},
{
"id": "{Miles} miles traveled ({Miles_1})",
"key": "%.2[1]f miles traveled (%[1]f)",
"message": "{Miles} miles traveled ({Miles_1})",
"translation": "",
"placeholders": [
@ -131,7 +199,8 @@
"argNum": 1,
"expr": "miles"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract/main.go:86:10"
}
]
}

View File

@ -4,7 +4,8 @@
package main
//go:generate gotext update -out catalog.go
//go:generate gotext extract --lang=de,zh
//go:generate gotext generate -out catalog.go
import (
"golang.org/x/text/language"

View File

@ -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

View File

@ -2,9 +2,9 @@
"language": "de",
"messages": [
{
"id": "Hello {From}!",
"id": "Hello {From}!\n",
"key": "Hello %s!\n",
"message": "Hello {From}!",
"message": "Hello {From}!\n",
"translation": "",
"placeholders": [
{
@ -19,9 +19,9 @@
"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",
"message": "Do you like your browser ({User_Agent})?",
"message": "Do you like your browser ({User_Agent})?\n",
"translation": "",
"placeholders": [
{

View File

@ -2,9 +2,9 @@
"language": "en-US",
"messages": [
{
"id": "Hello {From}!",
"id": "Hello {From}!\n",
"key": "Hello %s!\n",
"message": "Hello {From}!",
"message": "Hello {From}!\n",
"translation": "",
"placeholders": [
{
@ -19,9 +19,9 @@
"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",
"message": "Do you like your browser ({User_Agent})?",
"message": "Do you like your browser ({User_Agent})?\n",
"translation": "",
"placeholders": [
{

View File

@ -1,11 +1,11 @@
{
"language": "en",
"language": "en-US",
"messages": [
{
"id": "Hello {From}!",
"message": "Hello {From}!",
"translation": "Hello {From}!",
"translatorComment": "Copied from source.",
"id": "Hello {From}!\n",
"key": "Hello %s!\n",
"message": "Hello {From}!\n",
"translation": "",
"placeholders": [
{
"id": "From",
@ -16,13 +16,13 @@
"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})?",
"message": "Do you like your browser ({User_Agent})?",
"translation": "Do you like your browser ({User_Agent})?",
"translatorComment": "Copied from source.",
"id": "Do you like your browser ({User_Agent})?\n",
"key": "Do you like your browser (%s)?\n",
"message": "Do you like your browser ({User_Agent})?\n",
"translation": "",
"placeholders": [
{
"id": "User_Agent",
@ -33,7 +33,7 @@
"expr": "r.Header.Get(\"User-Agent\")"
}
],
"fuzzy": true
"position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:24:11"
}
]
}

View File

@ -2,8 +2,9 @@
"language": "zh",
"messages": [
{
"id": "Hello {From}!",
"message": "Hello {From}!",
"id": "Hello {From}!\n",
"key": "Hello %s!\n",
"message": "Hello {From}!\n",
"translation": "",
"placeholders": [
{
@ -14,11 +15,13 @@
"argNum": 1,
"expr": "r.Header.Get(\"From\")"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:22:11"
},
{
"id": "Do you like your browser ({User_Agent})?",
"message": "Do you like your browser ({User_Agent})?",
"id": "Do you like your browser ({User_Agent})?\n",
"key": "Do you like your browser (%s)?\n",
"message": "Do you like your browser ({User_Agent})?\n",
"translation": "",
"placeholders": [
{
@ -29,7 +32,8 @@
"argNum": 1,
"expr": "r.Header.Get(\"User-Agent\")"
}
]
],
"position": "golang.org/x/text/cmd/gotext/examples/extract_http/pkg/pkg.go:24:11"
}
]
}

View File

@ -4,7 +4,7 @@
package main
//go:generate gotext -srclang=en update -out=catalog_gen.go -lang=en,zh
//go:generate gotext extract --lang=de,zh
import (
"net/http"

View File

@ -5,6 +5,13 @@
package main
import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"golang.org/x/text/internal"
"golang.org/x/text/language"
"golang.org/x/text/message/pipeline"
)
@ -14,7 +21,13 @@ import (
// - handle features (gender, plural)
// - message rewriting
var (
srcLang *string
lang *string
)
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")
}
@ -24,17 +37,45 @@ var cmdExtract = &Command{
Short: "extracts strings to be translated from code",
}
func runExtract(cmd *Command, config *pipeline.Config, args []string) error {
config.Packages = args
state, err := pipeline.Extract(config)
func runExtract(cmd *Command, args []string) error {
tag, err := language.Parse(*srcLang)
if err != nil {
return wrap(err, "extract failed")
return wrap(err, "")
}
if err := state.Import(); err != nil {
return wrap(err, "import failed")
config := &pipeline.Config{
SourceLanguage: tag,
Packages: args,
}
if err := state.Merge(); err != nil {
return wrap(err, "merge failed")
out, err := pipeline.Extract(config)
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
}

View File

@ -5,27 +5,100 @@
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
"golang.org/x/text/message/pipeline"
"golang.org/x/tools/go/loader"
)
func init() {
out = cmdGenerate.Flag.String("out", "", "output file to write to")
}
var (
out *string
)
var cmdGenerate = &Command{
Run: runGenerate,
UsageLine: "generate <package>",
Short: "generates code to insert translated messages",
}
func runGenerate(cmd *Command, config *pipeline.Config, args []string) error {
config.Packages = args
s, err := pipeline.Extract(config)
var transRe = regexp.MustCompile(`messages\.(.*)\.json`)
func runGenerate(cmd *Command, args []string) error {
prog, err := loadPackages(&loader.Config{}, args)
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
}

View File

@ -25,8 +25,6 @@ import (
"unicode"
"unicode/utf8"
"golang.org/x/text/message/pipeline"
"golang.org/x/text/language"
"golang.org/x/tools/go/buildutil"
)
@ -35,23 +33,7 @@ func init() {
flag.Var((*buildutil.TagsFlag)(&build.Default.BuildTags), "tags", buildutil.TagsFlagDoc)
}
var (
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
}
var dir = flag.String("dir", "locales", "default subdirectory to store translation files")
// NOTE: the Command struct is copied from the go tool in core.
@ -60,7 +42,7 @@ func config() (*pipeline.Config, error) {
type Command struct {
// Run runs the command.
// 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.
// 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.
// The order here is the order in which they are printed by 'go help'.
var commands = []*Command{
cmdUpdate,
cmdExtract,
cmdRewrite,
cmdGenerate,
@ -143,11 +124,7 @@ func main() {
cmd.Flag.Usage = func() { cmd.Usage() }
cmd.Flag.Parse(args[1:])
args = cmd.Flag.Args()
config, err := config()
if err != nil {
fatalf("gotext: %+v", err)
}
if err := cmd.Run(cmd, config, args); err != nil {
if err := cmd.Run(cmd, args); err != nil {
fatalf("gotext: %+v", err)
}
exit()

View File

@ -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
if *overwrite {
w = nil

View File

@ -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
}