package msgfile
import "zgo.at/z18n/msgfile"
Package msgfile manages message files.
Index ¶
- Constants
- type Entries
- func FindGo(dir string, funs ...string) (Entries, error)
- func FindTemplate(dir string, ext []string, funs ...string) (Entries, error)
- func (e Entries) Equal(cmp Entries) bool
- func (e Entries) Merge(src Entries)
- func (e Entries) Sorted() []Entry
- func (e Entries) Untranslated() int
- type Entry
- type File
- func FromTOML(t string) (File, error)
- func New(fsys fs.FS, language string) (File, error)
- func ReadFile(fsys fs.FS, path string) (File, error)
- func (f File) List() (string, error)
- func (f File) TOML() (string, error)
- func (f *File) UnmarshalTOML(d interface{}) error
- func (f File) WriteTo(path string) error
Constants ¶
const ( UpdatedRemoved = "removed" UpdatedChanged = "changed" )
Types ¶
type Entries ¶
Entries are a list of translatable entries.
func FindGo ¶
Go finds all translatable strings in dir.
func FindTemplate ¶
FindTemplate finds all strings in Go templates.
func (Entries) Equal ¶
Equal reports if all entries in cmp are equal.
func (Entries) Merge ¶
Merge strings from src in to this Entries.
func (Entries) Sorted ¶
Sorted returns a list of entries sorted by ID.
func (Entries) Untranslated ¶
Untranslated reports the number of untranslated messages.
type Entry ¶
type Entry struct { ID string `toml:"id" json:"id"` // Translation ID. Loc []string `toml:"loc" json:"loc"` // Locations in code. Context string `toml:"context,omitempty" json:"context,omitempty"` // Translation context. Updated string `toml:"updated,omitempty" json:"updated,omitempty"` // Updated? // Messages. Default string `toml:"default,omitempty" json:"default,omitempty"` Zero string `toml:"zero,omitempty" json:"zero,omitempty"` One string `toml:"one,omitempty" json:"one,omitempty"` Two string `toml:"two,omitempty" json:"two,omitempty"` Few string `toml:"few,omitempty" json:"few,omitempty"` Many string `toml:"many,omitempty" json:"many,omitempty"` }
Entry is a single translatable entry.
func (Entry) Empty ¶
Empty reports if all messages are empty.
type File ¶
type File struct { // Is this a template file? Template bool `toml:"template,omitempty" json:"template,omitempty"` // Don't update with "z18n update" NoUpdate bool `toml:"no-update,omitempty" json:"no_update,omitempty"` // Updated date. Generated time.Time `toml:"generated,omitempty" json:"generated,omitempty"` // Language this is for. Language string `toml:"language" json:"language"` // Maintainer(s) of this file. Maintainers []string `toml:"maintainers" json:"maintainers"` // Comments for translators. Comments string `toml:"comments" json:"comments"` // CLI options; only if template=true. Options map[string]interface{} `toml:"options,omitempty" json:"options,omitempty"` // Translate strings. Strings Entries `toml:"strings" json:"strings"` // File path; used internally. Path string `toml:"-" json:"-"` }
File is a translation file.
func FromTOML ¶
FromTOML reads a message file from a TOML string.
func New ¶
TODO: what we really want is a new "Dir" type; would come in handy in a few other places too.
func ReadFile ¶
ReadFile reads a message file.
func (File) List ¶
List all entries in this file.
func (File) TOML ¶
TOML formats all entries as TOML.
TODO: Implement MarshalTOML instead.
func (*File) UnmarshalTOML ¶
Custom unmarshal to treat __meta__ as special.
func (File) WriteTo ¶
WriteTo writes out a message file.
Source Files ¶
find_go.go find_tpl.go fmt_go.go fmt_list.go fmt_toml.go msgfile.go new.go
- Version
- v0.0.0-20240522230155-4d5af439f8c4 (latest)
- Published
- May 22, 2024
- Platform
- linux/amd64
- Imports
- 23 packages
- Last checked
- 3 weeks ago –
Tools for package owners.