parser

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: BSD-3-Clause, MIT Imports: 11 Imported by: 5

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) 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
	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