Add sync to PO parse
This commit is contained in:
parent
9107e9b75a
commit
a7ccd4bbdb
1 changed files with 8 additions and 0 deletions
8
po.go
8
po.go
|
@ -6,10 +6,15 @@ import (
|
|||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Po struct {
|
||||
// Storage
|
||||
translations map[string]string
|
||||
|
||||
// Sync Mutex
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
// ParseFile tries to read the file by its provided path (f) and parse its content as a .po file.
|
||||
|
@ -36,6 +41,9 @@ func (po *Po) ParseFile(f string) {
|
|||
|
||||
// Parse loads the translations specified in the provided string (str)
|
||||
func (po *Po) Parse(str string) {
|
||||
po.Lock()
|
||||
defer po.Unlock()
|
||||
|
||||
if po.translations == nil {
|
||||
po.translations = make(map[string]string)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue