Add sync to PO parse

This commit is contained in:
Leonel Quinteros 2016-06-19 19:47:28 -03:00
parent 9107e9b75a
commit a7ccd4bbdb

8
po.go
View file

@ -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)
}