...
1
2
3
4
5 package message
6
7
8
9
10 import (
11 "golang.org/x/text/language"
12 "golang.org/x/text/message/catalog"
13 )
14
15
16
17 func MatchLanguage(preferred ...string) language.Tag {
18 c := DefaultCatalog
19 tag, _ := language.MatchStrings(c.Matcher(), preferred...)
20 return tag
21 }
22
23
24 var DefaultCatalog catalog.Catalog = defaultCatalog
25
26 var defaultCatalog = catalog.NewBuilder()
27
28
29 func SetString(tag language.Tag, key string, msg string) error {
30 return defaultCatalog.SetString(tag, key, msg)
31 }
32
33
34 func Set(tag language.Tag, key string, msg ...catalog.Message) error {
35 return defaultCatalog.Set(tag, key, msg...)
36 }
37
View as plain text