Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExtractedKey ¶
type ExtractedKey struct {
Key string // the translation key
DefaultValue string // default value if provided (from TD or WithDefaults)
File string // source file path
Pattern string // which pattern matched (e.g., "Translate", "T", "WithDefaults")
Line int // line number
Col int // column number
ArgCount int // number of variadic arguments; -1 if not a format call
Kind KeyKind // distinguishes extraction source
}
ExtractedKey represents a translation key found in source code.
func Extract ¶
func Extract(dirs, excludePatterns []string) ([]ExtractedKey, error)
Extract scans Go source files in the given directories and returns all translation keys found. It deduplicates and sorts the result by key.
func ExtractFromSource ¶
func ExtractFromSource(filename, src string) ([]ExtractedKey, error)
ExtractFromSource parses a Go source string and extracts translation keys. This is used for testing without file I/O.
type KeyKind ¶
type KeyKind int
KeyKind classifies how a translation key was extracted from source code.
const ( // KindStandard is a plain Translate, T, Has, HasKey, or Key call. KindStandard KeyKind = iota // KindFormat is a TranslateWithArgs or TF call (records arg count). KindFormat // KindPlural is a TranslatePlural call. KindPlural // KindGender is a TranslateGender call. KindGender // KindStructField is a Msg.Get().FieldName pattern. KindStructField // KindWithDefault is a TD call or WithDefaults map entry. KindWithDefault )
Click to show internal directories.
Click to hide internal directories.