Documentation
¶
Index ¶
- Constants
- func Mo(path string, opts ...MoOption) (*po.File, error)
- func MoFromBytes(b []byte, name string, opts ...MoOption) (*po.File, error)
- func MoFromFile(f *os.File, opts ...MoOption) (*po.File, error)
- func MoFromReader(r io.Reader, name string, opts ...MoOption) (*po.File, error)
- func Po(path string, opts ...PoOption) (*po.File, error)
- func PoFromBytes(b []byte, name string, opts ...PoOption) (*po.File, error)
- func PoFromFile(f *os.File, opts ...PoOption) (*po.File, error)
- func PoFromReader(r io.Reader, name string, opts ...PoOption) (*po.File, error)
- func PoFromString(s, name string, opts ...PoOption) (*po.File, error)
- type Endianness
- type MoConfig
- type MoOption
- type MoParser
- type PoConfig
- type PoOption
- func PoWithCleanDuplicates(cd bool) PoOption
- func PoWithConfig(cfg PoConfig) PoOption
- func PoWithCustomObsoletePrefix(r rune) PoOption
- func PoWithIgnoreAllComments(iag bool) PoOption
- func PoWithIgnoreComments(ig bool) PoOption
- func PoWithLogger(logger *log.Logger) PoOption
- func PoWithParseObsolete(p bool) PoOption
- func PoWithSkipHeader(s bool) PoOption
- func PoWithUseCustomObsoletePrefix(u bool) PoOption
- func PoWithVerbose(v bool) PoOption
- type PoParser
- func NewPo(path string, options ...PoOption) (*PoParser, error)
- func NewPoFromBytes(data []byte, name string, options ...PoOption) *PoParser
- func NewPoFromFile(f *os.File, options ...PoOption) (*PoParser, error)
- func NewPoFromReader(r io.Reader, name string, options ...PoOption) (*PoParser, error)
- func NewPoFromString(s, name string, options ...PoOption) *PoParser
Constants ¶
const ( LittleEndian = util.LittleEndian // Force little-endian parsing BigEndian = util.BigEndian // Force big-endian parsing NativeEndian = util.NativeEndian // Auto-detect byte order )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Endianness ¶ added in v2.3.0
type Endianness = util.Endianness
Endianness represents byte order options for MO files.
type MoConfig ¶ added in v2.3.0
type MoConfig struct {
// The logger can be nil, otherwise this logger will be used to print all errors by default.
Logger *log.Logger
// Specifies the endianness to work with,
// if [NativeEndian], the endianness
// automatically determined by the magic number will be used,
// otherwise, the specified endianness will be used.
Endianness Endianness
// Causes parsing to fail if the entries are not sorted properly.
MustBeSorted bool
// contains filtered or unexported fields
}
MoConfig holds configuration options for MO file parsing.
func DefaultMoConfig ¶ added in v2.3.0
func (*MoConfig) ApplyOptions ¶ added in v2.3.0
Overwrite the configuration with the options provided, saving the previous state so that it can be restored later with MoConfig.RestoreLastCfg if desired.
func (*MoConfig) RestoreLastCfg ¶ added in v2.3.0
func (mc *MoConfig) RestoreLastCfg()
Restores the configuration state prior to the last MoConfig.ApplyOptions if it exists, otherwise it does nothing.
type MoOption ¶ added in v2.3.0
type MoOption func(*MoConfig)
MoOption defines a function type for modifying MoConfig.
func MoWithConfig ¶ added in v2.3.0
MoWithConfig creates an option to replace the entire configuration.
func MoWithEndianness ¶ added in v2.3.0
func MoWithEndianness(e Endianness) MoOption
MoWithEndianness creates an option to set the byte order.
func MoWithLogger ¶ added in v2.5.0
MoWithLogger creates an option to set the error logger.
func MoWithMustBeSorted ¶ added in v2.5.0
MoWithMustBeSorted creates an option to enforce entry sorting.
type MoParser ¶
type MoParser struct {
Config MoConfig // Configuration for parsing behavior
// contains filtered or unexported fields
}
MoParser handles parsing of MO files into po.File structures.
func NewMoFromBytes ¶
NewMoFromBytes creates a new MoParser from a byte slice.
func NewMoFromFile ¶
NewMoFromFile creates a new MoParser from an open *os.File.
func NewMoFromReader ¶
NewMoFromReader creates a new MoParser from an io.Reader.
type PoConfig ¶
type PoConfig struct {
// IgnoreComments controls whether to discard translator comments.
IgnoreComments bool
// IgnoreAllComments controls whether to discard all comments including extracted comments and flags.
IgnoreAllComments bool
// Logger is an optional logger for error output. If nil, errors are only stored internally.
Logger *log.Logger
// Verbose enables more detailed logging when true.
Verbose bool
// SkipHeader controls whether to skip the metadata header entry.
SkipHeader bool
// CleanDuplicates controls whether to remove duplicate entries during parsing.
CleanDuplicates bool
// ParseObsoletes controls whether to parse obsolete entries (marked with #~).
ParseObsoletes bool
// UseCustomObsoletePrefix enables using a custom prefix for obsolete entries.
UseCustomObsoletePrefix bool
// CustomObsoletePrefix defines the custom marker for obsolete entries.
CustomObsoletePrefix rune
// contains filtered or unexported fields
}
func DefaultPoConfig ¶
DefaultPoConfig returns a new PoConfig with recommended defaults: - CleanDuplicates: true - ParseObsoletes: true.
func (*PoConfig) ApplyOptions ¶
ApplyOptions overwrite the configuration with the options provided, saving the previous state so that it can be restored later with PoConfig.RestoreLastCfg if desired.
func (*PoConfig) RestoreLastCfg ¶
func (p *PoConfig) RestoreLastCfg()
RestoreLastCfg restores the configuration state prior to the last PoConfig.ApplyOptions if it exists, otherwise it does nothing.
type PoOption ¶
type PoOption func(*PoConfig)
PoOption defines a function type for modifying PoConfig.
func PoWithCleanDuplicates ¶
PoWithCleanDuplicates creates an option to control duplicate removal.
func PoWithConfig ¶
PoWithConfig creates an option to replace the entire configuration.
func PoWithCustomObsoletePrefix ¶
PoWithCustomObsoletePrefix creates an option to set a custom obsolete marker.
func PoWithIgnoreAllComments ¶
PoWithIgnoreAllComments creates an option to discard all comments.
func PoWithIgnoreComments ¶
PoWithIgnoreComments creates an option to discard translator comments.
func PoWithLogger ¶
PoWithLogger creates an option to set the error logger.
func PoWithParseObsolete ¶
PoWithParseObsolete creates an option to control obsolete entry parsing.
func PoWithSkipHeader ¶
PoWithSkipHeader creates an option to skip the metadata header.
func PoWithUseCustomObsoletePrefix ¶
PoWithUseCustomObsoletePrefix creates an option to enable custom obsolete markers.
func PoWithVerbose ¶ added in v2.5.0
PoWithVerbose creates an option to enable verbose logging.
type PoParser ¶
type PoParser struct {
Config PoConfig // Configuration for parsing behavior
// contains filtered or unexported fields
}
PoParser handles parsing of PO files into po.File structures.
func NewPoFromBytes ¶
NewPoFromBytes creates a new PoParser from a byte slice.
func NewPoFromFile ¶
NewPoFromFile creates a new PoParser from an open *os.File.
func NewPoFromReader ¶
NewPoFromReader creates a new PoParser from an io.Reader.
func NewPoFromString ¶
NewPoFromString creates a new PoParser from a string.
func (*PoParser) ParseWithOptions ¶
ParseWithOptions parses the PO file with temporary configuration options. The original configuration is restored after parsing.
