parser

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: BSD-3-Clause, MIT Imports: 13 Imported by: 4 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Domain

type Domain struct {
	Translations        TranslationMap
	ContextTranslations map[string]TranslationMap
}

Domain holds all translations of one domain

func (*Domain) AddTranslation

func (d *Domain) AddTranslation(translation *Translation)

AddTranslation to the domain

func (*Domain) Dump

func (d *Domain) Dump() string

Dump the domain as string

func (*Domain) Save

func (d *Domain) Save(path string) error

Save domain to file

type DomainMap

type DomainMap struct {
	Domains map[string]*Domain
	Default string
}

DomainMap contains multiple domains as map with name as key

func (*DomainMap) AddTranslation

func (m *DomainMap) AddTranslation(domain string, translation *Translation)

AddTranslation to domain map

func (*DomainMap) Save

func (m *DomainMap) Save(directory string) (err error)

Save domains to directory

type GetterDef

type GetterDef struct {
	ID      int
	Plural  int
	Context int
	Domain  int
}

GetterDef describes a getter

func (*GetterDef) MaxArgIndex added in v1.7.2

func (d *GetterDef) MaxArgIndex() int

MaxArgIndex returns the largest argument index

type GoFile

type GoFile struct {
	FilePath string
	BasePath string
	Data     *DomainMap

	FileSet *token.FileSet
	PkgConf *packages.Config

	ImportedPackages map[string]*packages.Package
}

GoFile handles the parsing of one go file

func (*GoFile) CheckType added in v1.7.2

func (g *GoFile) CheckType(rawType types.Type) bool

CheckType for gotext object

func (*GoFile) GetType added in v1.7.2

func (g *GoFile) GetType(ident *ast.Ident) types.Object

GetType from ident object

func (*GoFile) InspectCallExpr added in v1.7.2

func (g *GoFile) InspectCallExpr(n *ast.CallExpr)

InspectCallExpr inspects the call expression

func (*GoFile) ParseGetter added in v1.7.2

func (g *GoFile) ParseGetter(def GetterDef, args []*ast.BasicLit, pos string)

ParseGetter parses the getter function

type Translation

type Translation struct {
	MsgID       string
	MsgIDPlural string
	Context     string
	// HasContext reports whether Context was present in source, including an empty value.
	HasContext      bool
	SourceLocations []string
}

Translation for a text to translate

func (*Translation) AddLocations

func (t *Translation) AddLocations(locations []string)

AddLocations to translation

func (*Translation) Dump

func (t *Translation) Dump() string

Dump translation as string

type TranslationMap

type TranslationMap map[string]*Translation

TranslationMap contains a map of translations with the ID as key

func (TranslationMap) Dump

func (m TranslationMap) Dump() string

Dump the translation map as string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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