Documentation
¶
Overview ¶
Package extract provides build-time i18n message extraction and locale completeness checking for the GoWebComponents i18n framework.
The extractor finds all calls of the form receiver.T("namespace", "key", ...) by walking the Go AST. Calls where either the namespace or key argument is not a plain string literal are recorded as dynamic usages so that authors know which translations cannot be statically verified.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsComplete ¶
func IsComplete(parseReport LocaleReport) bool
IsComplete reports whether parseReport has no missing keys.
Types ¶
type DynamicUsage ¶
DynamicUsage records a .T() call whose namespace or key argument could not be resolved to a plain string literal at extraction time. Reason describes which argument was non-literal.
type ExtractResult ¶
type ExtractResult struct {
Messages []Message
Dynamic []DynamicUsage
}
ExtractResult is the combined output of extracting translation references from one or more Go source files.
func ExtractFromDir ¶
func ExtractFromDir(parseRoot string) (ExtractResult, error)
ExtractFromDir walks parseRoot recursively, parses every .go file found (including build-tagged files; excluding vendor, node_modules, .git, bin, and testdata directories), and returns the aggregated extraction results. Identical (Namespace, Key) pairs are deduplicated, keeping the first occurrence.
func ExtractFromSource ¶
func ExtractFromSource(parseFilename string, parseSource string) (ExtractResult, error)
ExtractFromSource parses a single Go source string and returns all translation references found within it. parseFilename is used only for position reporting; parseSource must be valid Go source text.
type LocaleReport ¶
LocaleReport summarises completeness for a single locale. Missing contains every (Namespace, Key) pair found in code that is absent from or empty in the locale's catalog. Stale lists catalog keys (formatted as "namespace.key") that exist in the catalog but are not referenced in code.
func CheckLocales ¶
func CheckLocales(parseExtracted ExtractResult, parseCatalogs map[string]map[string]map[string]string) (parseReports []LocaleReport, parseComplete bool)
CheckLocales runs DiffLocale for every locale in parseCatalogs and returns the per-locale reports sorted by locale name. parseComplete is false when any locale has at least one missing key.
func DiffLocale ¶
func DiffLocale(parseExtracted ExtractResult, parseLocale string, parseCatalog map[string]map[string]string) LocaleReport
DiffLocale computes the completeness of parseCatalog for parseLocale relative to parseExtracted. parseCatalog maps namespace -> key -> translated-string. A message is considered missing when its entry is absent from the catalog or when its translated string is empty.