Documentation
¶
Overview ¶
Package extract 提供从 Go 源码中提取本地化内容的功能
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Extract ¶
func Extract(ctx context.Context, lang, root string, r bool, log Logger, f ...string) (*message.Messages, error)
Extract 提取本地化内容
lang 代码的文本所使用的语言; root 需要提取本地化内容的源码目录; f 表示被用于本地化的函数,所有 f 指定的函数,其参数都将被提取为本地化的内容。 f 每个元素的格式为 mod/path[.struct].func,mod/path 为包的导出路径, struct 为结构体名称,可以省略,func 为函数或方法名。 f 至少需要一个参数,且其第一个参数的类型必须为 string。 如果 f 指向的是方法,那么在调用此方法的结构必须有明确类型声明,不能由类型推荐获得。 比如,当 f 为 golang.org/x/text/message.Printer.Printf 时:
// 以下无法提取内容 p := message.NewPrinter(); p.Printf(...) // 以下可以 var p *message.Printer = message.NewPrinter(); p.Printf(...)
Types ¶
Click to show internal directories.
Click to hide internal directories.