common

package
v0.0.0-...-21d24d8 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: BSD-3-Clause Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ProjectIDVersion        = "Project-Id-Version"
	ReportMsgidBugsTo       = "Report-Msgid-Bugs-To"
	PotCreationDate         = "POT-Creation-Date"
	PoRevisionDate          = "PO-Revision-Date"
	LastTranslator          = "Last-Translator"
	LanguageTeam            = "Language-Team"
	Language                = "Language"
	MimeVersion             = "MIME-Version"
	ContentType             = "Content-Type"
	ContentTransferEncoding = "Content-Transfer-Encoding"
	PluralForms             = "Plural-Forms"
	XGenerator              = "X-Generator"
)

ProjectIDVersion is the key of a header rendered as => Project-Id-Version: PACKAGE VERSION ReportMsgidBugsTo is the key of a header rendered as => Report-Msgid-Bugs-To: FIRST AUTHOR <EMAIL@ADDRESS> PotCreationDate is the key of a header rendered as => POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE PoRevisionDate is the key of a header rendered as => PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE LastTranslator is the key of a header rendered as => Last-Translator: FIRST AUTHOR <EMAIL@ADDRESS> LanguageTeam is the key of a header rendered as => Language-Team: golang-china Language is the key of a header rendered as => Language: zh_CN MimeVersion is the key of a header rendered as => MIME-Version: 1.0 ContentType is the key of a header rendered as => Content-Type: text/plain; charset=UTF-8 ContentTransferEncoding is the key of a header rendered as => Content-Transfer-Encoding: 8bit PluralForms is the key of a header rendered as => Plural-Forms: nplurals=2; plural=n == 1 ? 0 : 1; XGenerator is the key of a header rendered as => X-Generator: Poedit 1.5.5

Variables

This section is empty.

Functions

func DecodePoString

func DecodePoString(text string) string

DecodePoString returns a plain text representation of a gettext encoded message

func EncodeCommentPoString

func EncodeCommentPoString(text string) string

EncodeCommentPoString returns a gettet encoded representation of a comment text

func EncodePoString

func EncodePoString(text string) string

EncodePoString returns a gettext encoded representation of a text message

Types

type ByMessages

type ByMessages []Message

ByMessages represents a list of messages

func (ByMessages) Len

func (d ByMessages) Len() int

func (ByMessages) Less

func (d ByMessages) Less(i, j int) bool

func (ByMessages) Swap

func (d ByMessages) Swap(i, j int)

type Comment

type Comment struct {
	StartLine         int      // comment start line
	TranslatorComment string   // #  translator-comments // TrimSpace
	ExtractedComment  string   // #. extracted-comments
	ReferenceFile     []string // #: src/msgcmp.c:338 src/po-lex.c:699
	ReferenceLine     []int    // #: src/msgcmp.c:338 src/po-lex.c:699
	Flags             []string // #, fuzzy,c-format,range:0..10
	PrevMsgContext    string   // #| msgctxt previous-context
	PrevMsgID         string   // #| msgid previous-untranslated-string
}

Comment represents every message's comments.

func (*Comment) GetFuzzy

func (p *Comment) GetFuzzy() bool

GetFuzzy gets the fuzzy flag.

func (*Comment) SetFuzzy

func (p *Comment) SetFuzzy(fuzzy bool)

SetFuzzy sets the fuzzy flag.

func (Comment) String

func (p Comment) String() string

String returns the po format comment string.

type Header struct {
	Comment // Header Comments
	// ProjectIDVersion        HeaderValue // Project-Id-Version: PACKAGE VERSION
	// ReportMsgidBugsTo       HeaderValue // Report-Msgid-Bugs-To: FIRST AUTHOR <EMAIL@ADDRESS>
	// POTCreationDate         HeaderValue // POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE
	// PORevisionDate          HeaderValue // PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE
	// LastTranslator          HeaderValue // Last-Translator: FIRST AUTHOR <EMAIL@ADDRESS>
	// LanguageTeam            HeaderValue // Language-Team: golang-china
	// Language                HeaderValue // Language: zh_CN
	// MimeVersion             HeaderValue // MIME-Version: 1.0
	// ContentType             HeaderValue // Content-Type: text/plain; charset=UTF-8
	// ContentTransferEncoding HeaderValue // Content-Transfer-Encoding: 8bit
	// PluralForms             HeaderValue // Plural-Forms: nplurals=2; plural=n == 1 ? 0 : 1;
	// XGenerator              HeaderValue // X-Generator: Poedit 1.5.5
	Fields       map[string]string
	UnknowFields map[string]string
}

Header is the initial comments "SOME DESCRIPTIVE TITLE", "YEAR" and "FIRST AUTHOR <EMAIL@ADDRESS>, YEAR" ought to be replaced by sensible information.

See http://www.gnu.org/software/gettext/manual/html_node/Header-Entry.html#Header-Entry

func (*Header) Format

func (p *Header) Format(name string) string

Format returns a formatted header field

func (*Header) FromMessage

func (p *Header) FromMessage(msg *Message)

FromMessage parses message headers

func (*Header) Get

func (p *Header) Get(name string) string

Get returns the value of a set standard or non-standard header, or an empty string if the header is not found

func (*Header) Set

func (p *Header) Set(name string, value string)

Set stores the values of both standard and non-standard headers

func (Header) String

func (p Header) String() string

String returns the po format header string.

func (*Header) ToMessage

func (p *Header) ToMessage() Message

ToMessage returns message with headers

type LineReader

type LineReader struct {
	// contains filtered or unexported fields
}

LineReader Define line reader structure

func NewLineReader

func NewLineReader(data string) *LineReader

NewLineReader Create a new line reader

type Message

type Message struct {
	Comment               // Coments
	MsgContext   string   // msgctxt context
	MsgID        string   // msgid untranslated-string
	MsgIDPlural  string   // msgid_plural untranslated-string-plural
	MsgStr       string   // msgstr translated-string
	MsgStrPlural []string // msgstr[0] translated-string-case-0
}

Message represents an original/translatable source message

func (*Message) ReadPoEntry

func (p *Message) ReadPoEntry(r *LineReader) (err error)

ReadPoEntry Get entire entry from line reader

func (Message) String

func (p Message) String() string

String returns the po format entry string.

Jump to

Keyboard shortcuts

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