aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/text/cmd/gotext/examples/extract/catalog.go
blob: 1a0d6d0ca8625df86d4ca44b8abde857da0ac136 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// 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)": 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{ // 8 elements
	0x00000000, 0x00000011, 0x00000023, 0x0000003d,
	0x00000057, 0x00000076, 0x00000076, 0x00000076,
} // 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!"

var en_USIndex = []uint32{ // 8 elements
	0x00000000, 0x00000012, 0x00000024, 0x00000042,
	0x00000060, 0x000000a3, 0x000000ba, 0x000000d9,
} // Size: 56 bytes

const en_USData string = "" + // Size: 217 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!\x14\x01\x81\x01\x00\x02\x14\x02One file remaini" +
	"ng!\x00&\x02There are %[1]d more files remaining!\x02%[1]s is out of ord" +
	"er!\x02%.2[1]f miles traveled (%[1]f)"

var zhIndex = []uint32{ // 8 elements
	0x00000000, 0x00000000, 0x00000000, 0x00000000,
	0x00000000, 0x00000000, 0x00000000, 0x00000000,
} // Size: 56 bytes

const zhData string = ""

// Total table size 503 bytes (0KiB); checksum: A968BD6