fix: 多语言翻译值转化key进行查询
This commit is contained in:
@@ -3,6 +3,7 @@ package i18n
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
systemService "be.ems/src/modules/system/service"
|
||||
)
|
||||
@@ -70,6 +71,26 @@ func UpdateKeyValue(language, key, value string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// TFindKeyPrefix 翻译值查找键 值前缀匹配
|
||||
func TFindKeyPrefix(language, keyPrefix, value string) string {
|
||||
key := value
|
||||
if value == "" {
|
||||
return key
|
||||
}
|
||||
arr, ok := localeMap[language]
|
||||
if !ok || len(arr) == 0 {
|
||||
arr = LoadLocaleData(language)
|
||||
}
|
||||
|
||||
for _, v := range arr {
|
||||
if strings.HasPrefix(v.Key, keyPrefix) && strings.HasPrefix(v.Value, value) {
|
||||
key = v.Key
|
||||
break
|
||||
}
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
// TKey 翻译键
|
||||
func TKey(language, key string) string {
|
||||
value := key
|
||||
|
||||
Reference in New Issue
Block a user