Skip to content

Commit

Permalink
fix(messae): 修正卖出时在深层函数调用中不能导出的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Oct 15, 2024
1 parent 2e0d02a commit b203225
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion locale.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# 依赖 gitub.com/issue9/web

web locale -l=und -f=yaml ./
web update-locale -src=./locales/und.yaml -dest=./locales/cmn-Hans.yaml
web update-locale -src=./locales/und.yaml -dest=./locales/zh.yaml
3 changes: 2 additions & 1 deletion locales/und.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
id: und
languages:
- und
messages:
- key: can not covert to message at %s:%d
message:
Expand Down
4 changes: 3 additions & 1 deletion locales/cmn-Hans.yaml → locales/zh.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
id: cmn-Hans
languages:
- zh-Hans
- cmn-Hans
messages:
- key: can not covert to message at %s:%d
message:
Expand Down
8 changes: 3 additions & 5 deletions message/extract/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package extract
import (
"cmp"
"context"
"fmt"
"go/ast"
"go/token"
"go/types"
Expand Down Expand Up @@ -144,8 +143,6 @@ func (ex *extractor) inspect(expr *ast.CallExpr, info *types.Info) bool {
obj = info.ObjectOf(ft.Sel)
case *ast.Ident:
obj = info.ObjectOf(ft)
default:
panic(fmt.Sprintf("未处理的 expr.Func 类型 %+T", ft))
}
if obj == nil {
return true
Expand Down Expand Up @@ -184,8 +181,9 @@ func (ex *extractor) inspect(expr *ast.CallExpr, info *types.Info) bool {
}
case *types.Named: // type X string; X('key')
obj := typ.Obj()
ex.tryAppendMsg(expr, obj.Pkg().Path(), "", obj.Name())
return false
if !ex.tryAppendMsg(expr, obj.Pkg().Path(), "", obj.Name()) {
return false
}
case *types.Basic:
return false
}
Expand Down
2 changes: 1 addition & 1 deletion message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type (
// File 单个本地化语言组成的文件
File struct {
XMLName struct{} `xml:"language" json:"-" yaml:"-"`
Languages []language.Tag `xml:"languages>language" json:"language" yaml:"language"` // 如果用字符串,还需要处理大小写以及不同值表示同一个 language.Tag 对象的问题
Languages []language.Tag `xml:"languages>language" json:"languages" yaml:"languages"` // 如果用字符串,还需要处理大小写以及不同值表示同一个 language.Tag 对象的问题
Messages []Message `xml:"message" json:"messages" yaml:"messages"`
}

Expand Down
2 changes: 1 addition & 1 deletion message/serialize/testdata/cmn-hans.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"language": [
"languages": [
"cmn-hans"
],
"messages": [
Expand Down

0 comments on commit b203225

Please sign in to comment.