Documentation
¶
Overview ¶
Package l10nkeys extracts localization message key usages from Go source (Localizer.T, Localizer.Plural, Localizer.Format, Catalog.T, Catalog.Plural, Catalog.Format), scenes (*.scene.yaml), screens (*.screen.yaml), cutscenes (*.cutscene.yaml), and data tables (registered or Go struct-tagged `table:"...,textkey"`), and compares them against a project's YAML string tables to report used, missing, and unused keys.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// DataTables, when non-nil, binds YAML file patterns to Go row types for
// extracting `textkey` columns from data tables. When nil, Scan falls back
// to Go AST discovery of struct fields tagged `table:"...,textkey"`.
DataTables *datatable.Registry
// TableDir, when non-empty, restricts string table discovery to this
// slash-separated fs.FS-relative directory while still scanning the entire
// project for code and asset key usages.
TableDir string
// IncludeTests controls whether *_test.go files are scanned (default false).
IncludeTests bool
}
Options configures Scan.
type Report ¶
type Report struct {
Tables []TableFile
Locales []string
Usages []Usage
Used []UsedKey
Missing []Usage
Unused []UnusedKey
}
Report is the result of Scan.
type TableFile ¶
type TableFile struct {
Path string
Locale string
Table *l10n.StringTable
Data []byte
}
TableFile describes one discovered YAML l10n string table.
type Usage ¶
type Usage struct {
Key string `json:"key"`
File string `json:"file"`
Line int `json:"line"`
Column int `json:"column,omitempty"`
Kind UsageKind `json:"kind"`
Plural bool `json:"plural,omitempty"`
Detail string `json:"detail,omitempty"`
}
Usage is one occurrence of a localization key in Go source or an asset file.
func ScanGoFiles ¶
ScanGoFiles parses the given Go files in fsys and returns all extracted localization key usages sorted by file, line, column, and key.
func ScanSceneFile ¶
ScanSceneFile extracts localization key properties from component maps in a *.scene.yaml file (including nested children and instance overrides).