mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 05:37:05 +02:00
Basic i18n setup
This commit is contained in:
parent
20f1732858
commit
a41318d822
10 changed files with 700 additions and 9 deletions
75
internal/translations/catalog.go
Normal file
75
internal/translations/catalog.go
Normal file
|
@ -0,0 +1,75 @@
|
|||
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
|
||||
|
||||
package translations
|
||||
|
||||
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, ok := messageKeyToIndex[key]
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
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": &dictionary{index: enIndex, data: enData},
|
||||
}
|
||||
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{
|
||||
"During the import the following errors occurred:": 4,
|
||||
"Error: %v\n": 5,
|
||||
"From timestamp: %v (%v)": 1,
|
||||
"Import failed, last reported timestamp was %v (%v)": 2,
|
||||
"Imported %v of %v %s into %v.": 3,
|
||||
"Latest timestamp: %v (%v)\n": 6,
|
||||
"Transferring %s from %s to %s...": 0,
|
||||
}
|
||||
|
||||
var deIndex = []uint32{ // 8 elements
|
||||
0x00000000, 0x00000029, 0x00000047, 0x00000087,
|
||||
0x000000b2, 0x000000e9, 0x000000fc, 0x00000125,
|
||||
} // Size: 56 bytes
|
||||
|
||||
const deData string = "" + // Size: 293 bytes
|
||||
"\x02Übertrage %[1]s von %[2]s nach %[3]s...\x02Ab Zeitstempel: %[1]v (%[" +
|
||||
"2]v)\x02Import fehlgeschlagen, der letzte Zeitstempel war %[1]v (%[2]v)" +
|
||||
"\x02%[1]v von %[2]v %[3]s in %[4]v importiert.\x02Während des Imports si" +
|
||||
"nd folgende Fehler aufgetreten:\x04\x00\x01\x0a\x0e\x02Fehler: %[1]v\x04" +
|
||||
"\x00\x01\x0a$\x02Neuester Zeitstempel: %[1]v (%[2]v)"
|
||||
|
||||
var enIndex = []uint32{ // 8 elements
|
||||
0x00000000, 0x0000002a, 0x00000048, 0x00000081,
|
||||
0x000000ab, 0x000000dc, 0x000000ee, 0x00000113,
|
||||
} // Size: 56 bytes
|
||||
|
||||
const enData string = "" + // Size: 275 bytes
|
||||
"\x02Transferring %[1]s from %[2]s to %[3]s...\x02From timestamp: %[1]v (" +
|
||||
"%[2]v)\x02Import failed, last reported timestamp was %[1]v (%[2]v)\x02Im" +
|
||||
"ported %[1]v of %[2]v %[3]s into %[4]v.\x02During the import the followi" +
|
||||
"ng errors occurred:\x04\x00\x01\x0a\x0d\x02Error: %[1]v\x04\x00\x01\x0a " +
|
||||
"\x02Latest timestamp: %[1]v (%[2]v)"
|
||||
|
||||
// Total table size 680 bytes (0KiB); checksum: D0CBF9F5
|
Loading…
Add table
Add a link
Reference in a new issue