gettext

package
v0.0.0-...-66b2615 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluralTypeZero = PluralType(iota)
	PluralTypeOne
	PluralTypeTwo
	PluralTypeFew
	PluralTypeMany
	PluralTypeOther
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	IsEmpty bool
	Comment string
}

type DefaultPluralRulesNotFoundError

type DefaultPluralRulesNotFoundError struct {
	Locale string
}

func (DefaultPluralRulesNotFoundError) Error

type Document

type Document struct {
	Header  DocumentHeader
	Entries []Entry
}

func CreateDocument

func CreateDocument(entries []Entry) (Document, error)

func ParseDocument

func ParseDocument(r io.Reader) (Document, error)

func ParseDocumentString

func ParseDocumentString(d string) (Document, error)

type DocumentHeader

type DocumentHeader struct {
	Tag         language.Tag
	PluralRules PluralRules
}

func CreateHeaderFromEntry

func CreateHeaderFromEntry(entry Entry) (DocumentHeader, error)

type DocumentHeaderParseError

type DocumentHeaderParseError struct {
	Entry  Entry
	Reason string
}

func (DocumentHeaderParseError) Error

func (e DocumentHeaderParseError) Error() string

type DocumentLineParseError

type DocumentLineParseError struct {
	Line            int
	UnderlyingError error
}

func (DocumentLineParseError) Error

func (e DocumentLineParseError) Error() string

type DocumentMissingHeaderError

type DocumentMissingHeaderError struct{}

func (DocumentMissingHeaderError) Error

type DocumentParseError

type DocumentParseError struct {
	Reason          string
	UnderlyingError error
}

func (DocumentParseError) Error

func (e DocumentParseError) Error() string

type Entry

type Entry struct {
	EntryKey

	Header     EntryHeader
	IsObsolete bool

	Value        string
	PluralValues []string

	Lines []Line
}

func ParseEntry

func ParseEntry(lines []Line) (Entry, error)

the original c# implementation has a keyword->value map, which makes this method a bit more maintainable when supporting new keywords but in practice, this doesn't happen, and hard-coded keywords provide a simpler implementation

type EntryHeader

type EntryHeader struct {
	References []string
	Flags      []string
}

func ExtractEntryHeader

func ExtractEntryHeader(lines []Line) EntryHeader

type EntryKey

type EntryKey struct {
	IsContextual bool
	Context      string

	Id string

	IsPlural bool
	PluralId string
}

type EntryLineParseError

type EntryLineParseError struct {
	Line   Line
	Reason string
}

func (EntryLineParseError) Error

func (e EntryLineParseError) Error() string

type EntryParseError

type EntryParseError struct {
	Reason string
}

func (EntryParseError) Error

func (e EntryParseError) Error() string

type Keyword

type Keyword struct {
	IsEmpty   bool
	Keyword   string
	Index     int
	IsIndexed bool
}

func IndexedKeyword

func IndexedKeyword(keyword string, index int) Keyword

func SimpleKeyword

func SimpleKeyword(keyword string) Keyword

type Line

type Line struct {
	Keyword Keyword
	Value   LineValue
	Comment Comment
	RawLine string

	IsCommentOrWhiteSpace, IsWhiteSpace, IsComment, IsMarkedObsolete bool
}

func CommentLine

func CommentLine(comment Comment) Line

func CompleteLine

func CompleteLine(keyword Keyword, lineValue LineValue, comment Comment) Line

func KeywordedValueLine

func KeywordedValueLine(keyword Keyword, lineValue LineValue) Line

func ParseLine

func ParseLine(line string) (Line, error)

func ValueLine

func ValueLine(lineValue LineValue) Line

type LineParseError

type LineParseError struct {
	Line string
}

func (LineParseError) Error

func (err LineParseError) Error() string

type LineValue

type LineValue struct {
	IsEmpty    bool
	Raw, Value string
}

func LineValueFromRaw

func LineValueFromRaw(raw string) LineValue

func LineValueFromValue

func LineValueFromValue(value string) LineValue

type PluralRuleOperation

type PluralRuleOperation func(decimal.Decimal) bool

type PluralRuleValidationError

type PluralRuleValidationError struct {
	RuleString     string
	InvalidSamples []decimal.Decimal
}

func (PluralRuleValidationError) Error

type PluralRules

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

func (*PluralRules) Evaluate

func (p *PluralRules) Evaluate(d decimal.Decimal) PluralType

type PluralRulesDefinition

type PluralRulesDefinition struct {
	Zero, One, Two, Few, Many, Other string
}

func GetDefaultPluralRulesDefinition

func GetDefaultPluralRulesDefinition(localeCode string) (PluralRulesDefinition, error)

func (*PluralRulesDefinition) Parse

type PluralType

type PluralType int

func (PluralType) String

func (t PluralType) String() string

Jump to

Keyboard shortcuts

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