forked from olivia-ai/olivia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
locales.go
106 lines (94 loc) 路 1.87 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package locales
import (
// Import these packages to trigger the init() function
_ "github.com/NerdDoc/server/res/locales/ca"
_ "github.com/NerdDoc/server/res/locales/de"
_ "github.com/NerdDoc/server/res/locales/el"
_ "github.com/NerdDoc/server/res/locales/en"
_ "github.com/NerdDoc/server/res/locales/es"
_ "github.com/NerdDoc/server/res/locales/fr"
_ "github.com/NerdDoc/server/res/locales/it"
_ "github.com/NerdDoc/server/res/locales/nl"
_ "github.com/NerdDoc/server/res/locales/tr"
_ "github.com/NerdDoc/server/res/locales/el"
_ "github.com/NerdDoc/server/res/locales/ru"
)
// Locales is the list of locales's tags and names
// Please check if the language is supported in https://github.com/tebeka/snowball,
// if it is please add the correct language name.
var Locales = []Locale{
{
Tag: "en",
Name: "english",
},
{
Tag: "de",
Name: "german",
},
{
Tag: "fr",
Name: "french",
},
{
Tag: "es",
Name: "spanish",
},
{
Tag: "ca",
Name: "catalan",
},
{
Tag: "it",
Name: "italian",
},
{
Tag: "tr",
Name: "turkish",
},
{
Tag: "nl",
Name: "dutch",
},
{
Tag: "el",
Name: "greek",
},
{
Tag: "ru",
Name: "russian",
},
}
// A Locale is a registered locale in the file
type Locale struct {
Tag string
Name string
}
// GetNameByTag returns the name of the given locale's tag
func GetNameByTag(tag string) string {
for _, locale := range Locales {
if locale.Tag != tag {
continue
}
return locale.Name
}
return ""
}
// GetTagByName returns the tag of the given locale's name
func GetTagByName(name string) string {
for _, locale := range Locales {
if locale.Name != name {
continue
}
return locale.Tag
}
return ""
}
// Exists checks if the given tag exists in the list of locales
func Exists(tag string) bool {
for _, locale := range Locales {
if locale.Tag == tag {
return true
}
}
return false
}