message

package
v0.29.3 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: MIT Imports: 7 Imported by: 2

Documentation

Overview

Package message 本地化信息的定义

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Case added in v0.15.0

type Case struct {
	Case  string `xml:"case,attr" json:"case" yaml:"case"`
	Value string `xml:",chardata"`
}

type File added in v0.28.0

type File struct {
	XMLName   struct{}       `xml:"language" json:"-" yaml:"-"`
	Languages []language.Tag `xml:"languages>language" json:"languages" yaml:"languages"` // 如果用字符串,还需要处理大小写以及不同值表示同一个 language.Tag 对象的问题
	Messages  []Message      `xml:"message" json:"messages" yaml:"messages"`
}

File 单个本地化语言组成的文件

func (*File) Catalog added in v0.28.0

func (f *File) Catalog(b *catalog.Builder) (err error)

Catalog 将本地化信息附加在 catalog.Catalog

func (*File) Join added in v0.28.0

func (l *File) Join(l2 *File)

Join 将 l2.Messages 并入 l.Messages

执行以下操作:

-如果 l2 的 [Message.Key] 存在于 l,则覆盖 l 的项;
-如果 l2 的 [Message.Key] 不存在于 l,则写入 l;

func (*File) MergeTo added in v0.28.0

func (f *File) MergeTo(log LogFunc, dest *File, destFile string)

Merge 将 l.Messages 写入 dest

这将会执行以下几个步骤:

-删除只存在于 dest 元素中而不存在于 l 的内容;
-将 l 独有的项写入 dest;

最终内容是 dest 为准。 log 所有删除的记录都将通过此输出; destFile 最终输出的文件名,该值仅在错误信息中;

type LogFunc added in v0.22.0

type LogFunc = func(localeutil.Stringer)

type Message added in v0.15.0

type Message struct {
	Key     string `xml:"key" json:"key" yaml:"key"`
	Message Text   `xml:"message" json:"message" yaml:"message"`
}

Message 单条本地化内容

type Select added in v0.15.0

type Select struct {
	Arg    int     `xml:"arg,attr" json:"arg" yaml:"arg"`
	Format string  `xml:"format,attr,omitempty" json:"format,omitempty" yaml:"format,omitempty"`
	Cases  []*Case `xml:"case,omitempty" json:"cases,omitempty" yaml:"cases,omitempty"`
}

type Text added in v0.15.0

type Text struct {
	Msg    string  `xml:"msg,omitempty" json:"msg,omitempty"  yaml:"msg,omitempty"`
	Select *Select `xml:"select,omitempty" json:"select,omitempty" yaml:"select,omitempty"`
	Vars   []*Var  `xml:"var,omitempty" json:"vars,omitempty" yaml:"vars,omitempty"`
}

type Var added in v0.15.0

type Var struct {
	Name   string  `xml:"name,attr" json:"name" yaml:"name"`
	Arg    int     `xml:"arg,attr" json:"arg" yaml:"arg"`
	Format string  `xml:"format,attr,omitempty" json:"format,omitempty" yaml:"format,omitempty"`
	Cases  []*Case `xml:"case,omitempty" json:"cases,omitempty" yaml:"cases,omitempty"`
}

Directories

Path Synopsis
Package extract 提供从 Go 源码中提取本地化内容的功能
Package extract 提供从 Go 源码中提取本地化内容的功能
Package serialize 提供对 message 包的序列化操作
Package serialize 提供对 message 包的序列化操作

Jump to

Keyboard shortcuts

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