-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocales.go
47 lines (39 loc) · 1.98 KB
/
locales.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
package locales
import "github.com/nyaruka/go-locales/localedata"
const (
LC_IDENTIFICATION localedata.LC = "LC_IDENTIFICATION" // Versions and status of categories
LC_CTYPE localedata.LC = "LC_CTYPE" // Character classification, case conversion and code transformation.
LC_COLLATE localedata.LC = "LC_COLLATE" // Collation order.
LC_TIME localedata.LC = "LC_TIME" // Date and time formats.
LC_NUMERIC localedata.LC = "LC_NUMERIC" // Numeric, non-monetary formatting.
LC_MONETARY localedata.LC = "LC_MONETARY" // Monetary formatting.
LC_MESSAGES localedata.LC = "LC_MESSAGES" // Formats of informative and diagnostic messages and interactive responses.
LC_XLITERATE localedata.LC = "LC_MESSAGES" // Character transliteration.
LC_NAME localedata.LC = "LC_NAME" // Format of writing personal names.
LC_ADDRESS localedata.LC = "LC_ADDRESS" // Format of postal addresses.
LC_TELEPHONE localedata.LC = "LC_TELEPHONE" // Format for telephone numbers, and other telephone information.
)
var database *localedata.Database
func init() {
var err error
database, err = localedata.LoadDatabase()
if err != nil {
panic(err)
}
}
// Query returns the operands of the given locale + category + keyword
func Query(localeName string, lc localedata.LC, keyword string) ([]string, error) {
return database.Query(localeName, lc, keyword)
}
// QueryString is a helper for keywords which are a single string
func QueryString(localeName string, lc localedata.LC, keyword string) (string, error) {
return database.QueryString(localeName, lc, keyword)
}
// QueryInteger is a helper for keywords which are a single integer
func QueryInteger(localeName string, lc localedata.LC, keyword string) (int, error) {
return database.QueryInteger(localeName, lc, keyword)
}
// Codes returns the list of all locale codes, sorted alphabetically
func Codes() []string {
return database.Codes()
}