diff options
Diffstat (limited to 'i18n')
-rw-r--r-- | i18n/catalog.go | 79 | ||||
-rw-r--r-- | i18n/locales/en-GB/messages.gotext.json | 96 | ||||
-rw-r--r-- | i18n/locales/nl-NL/messages.gotext.json | 70 | ||||
-rw-r--r-- | i18n/translations.go | 181 |
4 files changed, 426 insertions, 0 deletions
diff --git a/i18n/catalog.go b/i18n/catalog.go new file mode 100644 index 0000000..f01b375 --- /dev/null +++ b/i18n/catalog.go @@ -0,0 +1,79 @@ +// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. + +package i18n + +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{ + "en_GB": &dictionary{index: en_GBIndex, data: en_GBData}, + "nl_NL": &dictionary{index: nl_NLIndex, data: nl_NLData}, + } + fallback := language.MustParse("en-GB") + cat, err := catalog.NewFromMap(dict, catalog.Fallback(fallback)) + if err != nil { + panic(err) + } + message.DefaultCatalog = cat +} + +var messageKeyToIndex = map[string]int{ + "Banknotes": 4, + "Coin Collecting": 2, + "Coins": 3, + "Discord": 6, + "Eurozone Languages": 11, + "Feel free to contact us!": 8, + "Found a mistake or want to contribute missing information?": 7, + "Home": 0, + "Jargon": 5, + "News": 1, + "Other Languages": 12, + "Select Your Language": 9, + "Select your preferred language to use on the site.": 10, +} + +var en_GBIndex = []uint32{ // 14 elements + 0x00000000, 0x00000005, 0x0000000a, 0x0000001a, + 0x00000020, 0x0000002a, 0x00000031, 0x00000039, + 0x00000074, 0x0000008d, 0x000000a2, 0x000000d5, + 0x000000e8, 0x000000f8, +} // Size: 80 bytes + +const en_GBData string = "" + // Size: 248 bytes + "\x02Home\x02News\x02Coin Collecting\x02Coins\x02Banknotes\x02Jargon\x02D" + + "iscord\x02Found a mistake or want to contribute missing information?\x02" + + "Feel free to contact us!\x02Select Your Language\x02Select your preferre" + + "d language to use on the site.\x02Eurozone Languages\x02Other Languages" + +var nl_NLIndex = []uint32{ // 14 elements + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, +} // Size: 80 bytes + +const nl_NLData string = "" + +// Total table size 408 bytes (0KiB); checksum: E5CA15 diff --git a/i18n/locales/en-GB/messages.gotext.json b/i18n/locales/en-GB/messages.gotext.json new file mode 100644 index 0000000..64c1a2a --- /dev/null +++ b/i18n/locales/en-GB/messages.gotext.json @@ -0,0 +1,96 @@ +{ + "language": "en-GB", + "messages": [ + { + "id": "Home", + "message": "Home", + "translation": "Home", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "News", + "message": "News", + "translation": "News", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "Coin Collecting", + "message": "Coin Collecting", + "translation": "Coin Collecting", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "Coins", + "message": "Coins", + "translation": "Coins", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "Banknotes", + "message": "Banknotes", + "translation": "Banknotes", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "Jargon", + "message": "Jargon", + "translation": "Jargon", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "Discord", + "message": "Discord", + "translation": "Discord", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "Found a mistake or want to contribute missing information?", + "message": "Found a mistake or want to contribute missing information?", + "translation": "Found a mistake or want to contribute missing information?", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "Feel free to contact us!", + "message": "Feel free to contact us!", + "translation": "Feel free to contact us!", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "Select Your Language", + "message": "Select Your Language", + "translation": "Select Your Language", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "Select your preferred language to use on the site.", + "message": "Select your preferred language to use on the site.", + "translation": "Select your preferred language to use on the site.", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "Eurozone Languages", + "message": "Eurozone Languages", + "translation": "Eurozone Languages", + "translatorComment": "Copied from source.", + "fuzzy": true + }, + { + "id": "Other Languages", + "message": "Other Languages", + "translation": "Other Languages", + "translatorComment": "Copied from source.", + "fuzzy": true + } + ] +}
\ No newline at end of file diff --git a/i18n/locales/nl-NL/messages.gotext.json b/i18n/locales/nl-NL/messages.gotext.json new file mode 100644 index 0000000..d1cd455 --- /dev/null +++ b/i18n/locales/nl-NL/messages.gotext.json @@ -0,0 +1,70 @@ +{ + "language": "nl-NL", + "messages": [ + { + "id": "Home", + "message": "Home", + "translation": "" + }, + { + "id": "News", + "message": "News", + "translation": "" + }, + { + "id": "Coin Collecting", + "message": "Coin Collecting", + "translation": "" + }, + { + "id": "Coins", + "message": "Coins", + "translation": "" + }, + { + "id": "Banknotes", + "message": "Banknotes", + "translation": "" + }, + { + "id": "Jargon", + "message": "Jargon", + "translation": "" + }, + { + "id": "Discord", + "message": "Discord", + "translation": "" + }, + { + "id": "Found a mistake or want to contribute missing information?", + "message": "Found a mistake or want to contribute missing information?", + "translation": "" + }, + { + "id": "Feel free to contact us!", + "message": "Feel free to contact us!", + "translation": "" + }, + { + "id": "Select Your Language", + "message": "Select Your Language", + "translation": "" + }, + { + "id": "Select your preferred language to use on the site.", + "message": "Select your preferred language to use on the site.", + "translation": "" + }, + { + "id": "Eurozone Languages", + "message": "Eurozone Languages", + "translation": "" + }, + { + "id": "Other Languages", + "message": "Other Languages", + "translation": "" + } + ] +}
\ No newline at end of file diff --git a/i18n/translations.go b/i18n/translations.go new file mode 100644 index 0000000..1d35f98 --- /dev/null +++ b/i18n/translations.go @@ -0,0 +1,181 @@ +package i18n + +import ( + "strings" + + "golang.org/x/text/language" + "golang.org/x/text/message" +) + +//go:generate gotext -srclang=en-GB update -out=catalog.go -lang=en-GB,nl-NL git.thomasvoss.com/euro-cash.eu + +type Printer struct { + Lang string + printer *message.Printer +} + +type Locale struct { + Code string + Name string + Eurozone bool + Enabled bool +} + +var ( + Locales = [...]Locale{ + Locale{ + Code: "ca-AD", + Name: "català", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "de-DE", + Name: "Deutsch", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "el-GR", + Name: "ελληνικά", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "en-GB", + Name: "English", + Eurozone: true, + Enabled: true, + }, + Locale{ + Code: "es-ES", + Name: "español", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "et-EE", + Name: "eesti", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "fi-FI", + Name: "suomi", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "fr-FR", + Name: "français", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "ga-IE", + Name: "Gaeilge", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "hr-HR", + Name: "hrvatski", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "it-IT", + Name: "italiano", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "lt-LT", + Name: "lietuvių", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "lv-LV", + Name: "latviešu", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "mt-MT", + Name: "Malti", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "nl-NL", + Name: "Nederlands", + Eurozone: true, + Enabled: true, + }, + Locale{ + Code: "pt-PT", + Name: "português", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "sk-SK", + Name: "slovenčina", + Eurozone: true, + Enabled: false, + }, + Locale{ + Code: "sl-SI", + Name: "slovenščina", + Eurozone: true, + Enabled: false, + }, + + /* Non-Eurozone locales */ + Locale{ + Code: "bg-BG", + Name: "български", + Eurozone: false, + Enabled: false, + }, + Locale{ + Code: "en-US", + Name: "English (US)", + Eurozone: false, + Enabled: false, + }, + Locale{ + Code: "ro-RO", + Name: "română", + Eurozone: false, + Enabled: false, + }, + } + /* Map of language codes to printers. We do this instead of just + using language.MustParse() directly so that we can easily see if a + language is supported or not. */ + Printers map[string]Printer = make(map[string]Printer, len(Locales)) + DefaultPrinter Printer +) + +func InitPrinters() { + for _, loc := range Locales { + if loc.Enabled { + lang := language.MustParse(loc.Code) + Printers[strings.ToLower(loc.Code)] = Printer{ + Lang: loc.Code, + printer: message.NewPrinter(lang), + } + } + } + DefaultPrinter = Printers["en-gb"] +} + +func (p Printer) T(fmt string, args ...any) string { + return p.printer.Sprintf(fmt, args...) +} + +func (l Locale) Language() string { + return l.Code[:2] +} |