-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathi18n.go
50 lines (43 loc) · 1.23 KB
/
i18n.go
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
package tbcomctl
import (
"golang.org/x/text/language"
"golang.org/x/text/message"
)
const (
MsgUnexpected = "🤯 (500) Unexpected error occurred."
MsgRetry = "Incorrect choice."
MsgChooseVal = "Choose the value from the list:"
MsgOK = "✅"
MsgVoteCounted = "✅ Vote counted."
MsgSubCheck = "? Check subscription >>"
MsgSubNoSub = "❌ You're not subscribed to one or more of the required channels."
)
var translations = map[language.Tag][]i18nmsg{
language.Russian: {
{MsgUnexpected, "🤯 (500) Произошло недоразумение."},
{MsgRetry, "Неверный выбор"},
{MsgChooseVal, "Выберите значение из списка:"},
{MsgVoteCounted, "✅ Голос учтен."},
{MsgSubCheck, "? Проверить подписку >>"},
{MsgSubNoSub, "❌ Вы не подписались на один или более необходимых каналов."},
},
}
type i18nmsg struct {
key string
translation string
}
func init() {
initMessages()
}
func initMessages() {
for l, tt := range translations {
for _, t := range tt {
must(message.SetString(l, t.key, t.translation))
}
}
}
func must(err error) {
if err != nil {
panic(err)
}
}