parser

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportToTranslationsMap

func ExportToTranslationsMap(projectPath string) (translationsMap map[string]map[string]string, err error)

get translationsMap from projectPath

func ImportFromTranslationsMap

func ImportFromTranslationsMap(projectPath string, translationsMap map[string]map[string]string) (err error)

compare the translation structs and translationsMap update the new value from translationsMap overwrite new content to files

func ParseDir

func ParseDir(fset *token.FileSet, path string, filter func(fs.FileInfo) bool, mode parser.Mode) (pkgs map[string]*ast.Package, first error)

Types

type MessageStruct

type MessageStruct struct {
	PkgName    string
	StructName string
}

type Visitor

type Visitor struct {
	// map[locale][]MessageStruct
	// example:
	//{
	//      "English": [
	//              {
	//                      "PkgName": "x/i18n",
	//                      "StructName": "Messages_en_US"
	//              }
	//      ],
	//}
	RigisterMap map[string][]MessageStruct

	// map[locale][]MessageStruct
	// example:
	//{
	//      "Messages_en_US": "English",
	//      "Messages_zh_CN": "SimplifiedChinese"
	//}
	LocalesMap map[string]string

	// map[pkgName][]structs
	// example:
	//{
	//      "x/i18n": []*ast.GenDecl,
	//}
	Variables map[string][]*ast.GenDecl
	// contains filtered or unexported fields
}

func (*Visitor) Visit

func (v *Visitor) Visit(node ast.Node) ast.Visitor

Jump to

Keyboard shortcuts

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