...

Source file src/golang.org/x/text/cmd/gotext/examples/extract/catalog.go

Documentation: golang.org/x/text/cmd/gotext/examples/extract

     1  // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
     2  
     3  package main
     4  
     5  import (
     6  	"golang.org/x/text/language"
     7  	"golang.org/x/text/message"
     8  	"golang.org/x/text/message/catalog"
     9  )
    10  
    11  type dictionary struct {
    12  	index []uint32
    13  	data  string
    14  }
    15  
    16  func (d *dictionary) Lookup(key string) (data string, ok bool) {
    17  	p, ok := messageKeyToIndex[key]
    18  	if !ok {
    19  		return "", false
    20  	}
    21  	start, end := d.index[p], d.index[p+1]
    22  	if start == end {
    23  		return "", false
    24  	}
    25  	return d.data[start:end], true
    26  }
    27  
    28  func init() {
    29  	dict := map[string]catalog.Dictionary{
    30  		"de":    &dictionary{index: deIndex, data: deData},
    31  		"en_US": &dictionary{index: en_USIndex, data: en_USData},
    32  		"zh":    &dictionary{index: zhIndex, data: zhData},
    33  	}
    34  	fallback := language.MustParse("en-US")
    35  	cat, err := catalog.NewFromMap(dict, catalog.Fallback(fallback))
    36  	if err != nil {
    37  		panic(err)
    38  	}
    39  	message.DefaultCatalog = cat
    40  }
    41  
    42  var messageKeyToIndex = map[string]int{
    43  	"%.2[1]f miles traveled (%[1]f)":                 8,
    44  	"%[1]s is visiting %[3]s!\n":                     3,
    45  	"%d files remaining!":                            5,
    46  	"%d more files remaining!":                       4,
    47  	"%s is out of order!":                            7,
    48  	"%s is visiting %s!\n":                           2,
    49  	"Hello %s!\n":                                    1,
    50  	"Hello world!\n":                                 0,
    51  	"Use the following code for your discount: %d\n": 6,
    52  }
    53  
    54  var deIndex = []uint32{ // 10 elements
    55  	0x00000000, 0x00000011, 0x00000023, 0x0000003d,
    56  	0x00000057, 0x00000076, 0x00000076, 0x00000076,
    57  	0x00000076, 0x00000076,
    58  } // Size: 64 bytes
    59  
    60  const deData string = "" + // Size: 118 bytes
    61  	"\x04\x00\x01\x0a\x0c\x02Hallo Welt!\x04\x00\x01\x0a\x0d\x02Hallo %[1]s!" +
    62  	"\x04\x00\x01\x0a\x15\x02%[1]s besucht %[2]s!\x04\x00\x01\x0a\x15\x02%[1]" +
    63  	"s besucht %[3]s!\x02Noch %[1]d Bestände zu gehen!"
    64  
    65  var en_USIndex = []uint32{ // 10 elements
    66  	0x00000000, 0x00000012, 0x00000024, 0x00000042,
    67  	0x00000060, 0x000000a3, 0x000000ba, 0x000000ef,
    68  	0x00000106, 0x00000125,
    69  } // Size: 64 bytes
    70  
    71  const en_USData string = "" + // Size: 293 bytes
    72  	"\x04\x00\x01\x0a\x0d\x02Hello world!\x04\x00\x01\x0a\x0d\x02Hello %[1]sn" +
    73  	"\x04\x00\x01\x0a\x19\x02%[1]s is visiting %[2]s!\x04\x00\x01\x0a\x19\x02" +
    74  	"%[1]s is visiting %[3]s!\x14\x01\x81\x01\x00\x02\x14\x02One file remaini" +
    75  	"ng!\x00&\x02There are %[1]d more files remaining!\x02%[1]d files remaini" +
    76  	"ng!\x04\x00\x01\x0a0\x02Use the following code for your discount: %[1]d" +
    77  	"\x02%[1]s is out of order!\x02%.2[1]f miles traveled (%[1]f)"
    78  
    79  var zhIndex = []uint32{ // 10 elements
    80  	0x00000000, 0x00000000, 0x00000000, 0x00000000,
    81  	0x00000000, 0x00000000, 0x00000000, 0x00000000,
    82  	0x00000000, 0x00000000,
    83  } // Size: 64 bytes
    84  
    85  const zhData string = ""
    86  
    87  // Total table size 603 bytes (0KiB); checksum: 1D2754EE
    88  

View as plain text