improve packge gi18n

This commit is contained in:
jflyfox
2021-01-04 14:43:17 +08:00
parent 3ab32faccc
commit b3b1418e11

View File

@ -1,4 +1,4 @@
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
@ -13,8 +13,6 @@ import (
"strings"
"sync"
"github.com/gogf/gf/os/glog"
"github.com/gogf/gf/os/gfsnotify"
"github.com/gogf/gf/text/gregex"
@ -235,11 +233,11 @@ func (m *Manager) init() {
m.data[lang] = make(map[string]string)
}
if j, err := gjson.LoadContent(file.Content()); err == nil {
for k, v := range j.ToMap() {
for k, v := range j.Map() {
m.data[lang][k] = gconv.String(v)
}
} else {
glog.Errorf("load i18n file '%s' failed: %v", name, err)
intlog.Errorf("load i18n file '%s' failed: %v", name, err)
}
}
}
@ -270,11 +268,11 @@ func (m *Manager) init() {
m.data[lang] = make(map[string]string)
}
if j, err := gjson.LoadContent(gfile.GetBytes(file)); err == nil {
for k, v := range j.ToMap() {
for k, v := range j.Map() {
m.data[lang][k] = gconv.String(v)
}
} else {
glog.Errorf("load i18n file '%s' failed: %v", file, err)
intlog.Errorf("load i18n file '%s' failed: %v", file, err)
}
}
// Monitor changes of i18n files for hot reload feature.