internal

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(param *Param) (err error)

Run 运行解析任务

func Writer

func Writer(fileName string) (wr *os.File, err error)

Writer 根据输出参数返回写入目标。 fileName 为空或为 - 时输出到 stdout,否则覆盖写入指定文件。

Types

type Context

type Context struct {
	*Param
	Keywords  []Keyword
	Functions template.FuncMap
	Output    *os.File
	// contains filtered or unexported fields
}

Context 保存一次提取任务运行期间的上下文。 除了解析参数外,也负责缓存 keyword/function 映射、收集 entry 以及输出目标。

func (*Context) Add

func (ctx *Context) Add(entry *translator.Entry) error

Add 合并一条抽取结果;相同 msgid 会合并来源注释。

func (*Context) Close added in v0.1.1

func (ctx *Context) Close() error

Close 在输出目标是普通文件时关闭它;stdout/stderr 无需关闭。

func (*Context) Write

func (ctx *Context) Write() error

Write 将当前收集到的条目写入 POT。

type Keyword

type Keyword struct {
	Name    string
	MsgCtxt int
	MsgID   int
	MsgID2  int
}

Keyword gettext keyword

func ParseKeywords

func ParseKeywords(str string) (result []Keyword, err error)

ParseKeywords 解析 xgettext 风格的关键字声明,例如: gettext;T:1;N:1,2;X:1c,2;XN:1c,2,3

type Param

type Param struct {
	Input      string
	Left       string
	Right      string
	Keyword    string
	Function   string
	OutputFile string
	Debug      bool
}

Param 输入参数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL