message

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 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 Language added in v0.15.0

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

Language 某一语言的本地化内容

type MarshalFunc added in v0.15.0

type MarshalFunc = func(any) ([]byte, error)

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 Messages added in v0.15.0

type Messages struct {
	XMLName   struct{}    `xml:"messages" json:"-" yaml:"-"`
	Languages []*Language `xml:"language" json:"languages" yaml:"languages"`
}

Messages 本地化对象

func (*Messages) Bytes added in v0.15.0

func (m *Messages) Bytes(f MarshalFunc) ([]byte, error)

Bytes 将当前对象转换为 []byte

func (*Messages) Catalog added in v0.15.0

func (m *Messages) Catalog(b *catalog.Builder) (err error)

Catalog 将当前对象附加在 catalog.Catalog

func (*Messages) Load added in v0.15.0

func (m *Messages) Load(data []byte, u UnmarshalFunc) error

Load 加载内容

func (*Messages) LoadFS added in v0.15.0

func (m *Messages) LoadFS(fsys fs.FS, name string, u UnmarshalFunc) error

func (*Messages) LoadFSGlob added in v0.15.0

func (m *Messages) LoadFSGlob(fsys fs.FS, glob string, u UnmarshalFunc) error

func (*Messages) LoadFile added in v0.15.0

func (m *Messages) LoadFile(path string, u UnmarshalFunc) error

func (*Messages) LoadGlob added in v0.15.0

func (m *Messages) LoadGlob(glob string, u UnmarshalFunc) error

func (*Messages) SaveFile added in v0.15.0

func (m *Messages) SaveFile(dir, ext string, f MarshalFunc) error

SaveFile 将当前对象编码为文本并存入 path

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 UnmarshalFunc added in v0.15.0

type UnmarshalFunc = func([]byte, any) error

UnmarshalFunc 解析文本内容至对象的方法

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"`
}

Jump to

Keyboard shortcuts

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