/
init.go
39 lines (34 loc) · 843 Bytes
/
init.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
// Copyright 2017 NDP Systèmes. All Rights Reserved.
// See LICENSE file for full licensing details.
package actions
import (
"github.com/gleke/hexya/src/i18n"
"github.com/gleke/hexya/src/tools/logging"
)
var (
log logging.Logger
bootstrapped bool
)
// BootStrap actions.
// This function must be called prior to any access to the actions Registry.
func BootStrap() {
if bootstrapped {
log.Panic("Actions are already bootstrapped.")
}
for _, a := range Registry.GetAll() {
a.Sanitize()
// Populate translations
if a.names == nil {
a.names = make(map[string]string)
}
for _, lang := range i18n.Langs {
nameTrans := i18n.TranslateResourceItem(lang, a.XMLID, a.Name)
a.names[lang] = nameTrans
}
}
bootstrapped = true
}
func init() {
log = logging.GetLogger("actions")
Registry = NewCollection()
}