message

package
v0.26.5 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 6 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 Language added in v0.15.0

type Language struct {
	XMLName  struct{}     `xml:"language" json:"-" yaml:"-"`
	ID       language.Tag `xml:"id,attr" json:"id" yaml:"id"`
	Messages []Message    `xml:"message" json:"messages" yaml:"messages"`
}

Language 某一语言的本地化内容

func (*Language) Catalog added in v0.20.0

func (l *Language) Catalog(b *catalog.Builder) (err error)

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

func (*Language) Join added in v0.20.0

func (l *Language) Join(l2 *Language)

Join 将 l2.Messages 并入 l.Messages

执行以下操作:

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

func (*Language) MergeTo added in v0.20.0

func (l *Language) MergeTo(log LogFunc, dest []*Language)

Merge 将 l.Messages 写入 dest 中的每个元素

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

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

最终内容是 dest 为准。 log 所有删除的记录都将通过此输出;

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