compile

package
v2.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2025 License: MIT Imports: 13 Imported by: 0

README

Compiler

structure

Documentation

Index

Constants

View Source
const (
	LittleEndian = util.LittleEndian
	BigEndian    = util.BigEndian
	NativeEndian = util.NativeEndian
)

Variables

This section is empty.

Functions

func MoToBytes

func MoToBytes[T po.EntriesOrFile](f T, opts ...MoOption) []byte

func MoToFile

func MoToFile[T po.EntriesOrFile](f T, path string, opts ...MoOption) error

func MoToWriter

func MoToWriter[T po.EntriesOrFile](f T, w io.Writer, opts ...MoOption) error

func PoToBytes

func PoToBytes[T po.EntriesOrFile](f T, opts ...PoOption) []byte

func PoToFile

func PoToFile[T po.EntriesOrFile](f T, path string, opts ...PoOption) error

func PoToString

func PoToString[T po.EntriesOrFile](f T, opts ...PoOption) string

func PoToWriter

func PoToWriter[T po.EntriesOrFile](f T, w io.Writer, opts ...PoOption) error

Types

type Endianness added in v2.3.0

type Endianness = util.Endianness

type MoCompiler

type MoCompiler struct {
	File   *po.File
	Config MoConfig
}

func NewMo

func NewMo(file *po.File, opts ...MoOption) MoCompiler

func (*MoCompiler) SetFile

func (mc *MoCompiler) SetFile(f *po.File)

func (MoCompiler) ToBytes

func (mc MoCompiler) ToBytes() []byte

func (*MoCompiler) ToBytesWithOptions

func (mc *MoCompiler) ToBytesWithOptions(options ...MoOption) []byte

func (MoCompiler) ToFile

func (mc MoCompiler) ToFile(f string) error

func (*MoCompiler) ToFileWithOptions

func (mc *MoCompiler) ToFileWithOptions(f string, options ...MoOption) error

func (MoCompiler) ToWriter

func (mc MoCompiler) ToWriter(w io.Writer) error

func (*MoCompiler) ToWriterWithOptions

func (mc *MoCompiler) ToWriterWithOptions(w io.Writer, opts ...MoOption) error

type MoConfig

type MoConfig struct {
	Logger       *log.Logger
	Force        bool
	Verbose      bool
	IgnoreErrors bool
	Endianness   Endianness
	HashTable    bool
	// contains filtered or unexported fields
}

func DefaultMoConfig

func DefaultMoConfig(opts ...MoOption) MoConfig

func (*MoConfig) ApplyOptions

func (mc *MoConfig) ApplyOptions(opts ...MoOption)

func (*MoConfig) RestoreLastCfg

func (mc *MoConfig) RestoreLastCfg()

type MoOption

type MoOption func(c *MoConfig)

func MoWithConfig

func MoWithConfig(n MoConfig) MoOption

func MoWithEndianness added in v2.3.0

func MoWithEndianness(e Endianness) MoOption

func MoWithForce

func MoWithForce(f bool) MoOption

func MoWithHashTable added in v2.3.0

func MoWithHashTable(h bool) MoOption

func MoWithIgnoreErrors

func MoWithIgnoreErrors(i bool) MoOption

func MoWithLogger

func MoWithLogger(l *log.Logger) MoOption

func MoWithVerbose

func MoWithVerbose(v bool) MoOption

type PoCompiler

type PoCompiler struct {
	File   *po.File // The source file containing translation entries.
	Config PoConfig // Configuration settings for compilation.
	// contains filtered or unexported fields
}

func NewPo

func NewPo(file *po.File, options ...PoOption) PoCompiler

func (*PoCompiler) SetFile

func (c *PoCompiler) SetFile(f *po.File)

func (PoCompiler) ToBytes

func (c PoCompiler) ToBytes() []byte

func (*PoCompiler) ToBytesWithOptions

func (c *PoCompiler) ToBytesWithOptions(opts ...PoOption) []byte

func (PoCompiler) ToFile

func (c PoCompiler) ToFile(f string) error

func (*PoCompiler) ToFileWithOptions

func (c *PoCompiler) ToFileWithOptions(f string, opts ...PoOption) error

func (PoCompiler) ToString

func (c PoCompiler) ToString() string

func (*PoCompiler) ToStringWithOptions

func (c *PoCompiler) ToStringWithOptions(opts ...PoOption) string

func (PoCompiler) ToWriter

func (c PoCompiler) ToWriter(w io.Writer) error

func (*PoCompiler) ToWriterWithOptions

func (c *PoCompiler) ToWriterWithOptions(w io.Writer, opts ...PoOption) error

type PoConfig

type PoConfig struct {
	Logger          *log.Logger
	ForcePo         bool           // If true, forces the creation of a `.po` file, even if not strictly needed.
	OmitHeader      bool           // If true, omits the header section in the generated `.po` file.
	PackageName     string         // Name of the package associated with the translation.
	CopyrightHolder string         // Name of the entity holding copyright over the translation.
	ForeignUser     bool           // If true, marks the translation as public domain.
	Title           string         // Title to be included in the `.po` file header.
	NoLocation      bool           // If true, suppresses location comments in the `.po` file.
	AddLocation     PoLocationMode // Specifies how location comments should be included ("never", "file", "full").
	MsgstrPrefix    string         // Prefix added to all translation strings.
	MsgstrSuffix    string         // Suffix added to all translation strings.
	IgnoreErrors    bool           // If true, allows compilation to proceed despite non-critical errors.
	Verbose         bool
	CommentFuzzy    bool
	HeaderComments  bool
	HeaderFields    bool
	WordWrap        bool

	UseCustomObsoletePrefix  bool
	CustomObsoletePrefixRune rune
	// contains filtered or unexported fields
}

PoConfig holds the settings for the compiler, affecting how translations are processed.

func DefaultPoConfig

func DefaultPoConfig(opts ...PoOption) PoConfig

func NewPoConfigFromOptions

func NewPoConfigFromOptions(opts ...PoOption) PoConfig

func (*PoConfig) ApplyOptions

func (c *PoConfig) ApplyOptions(opts ...PoOption)

func (*PoConfig) RestoreLastCfg

func (c *PoConfig) RestoreLastCfg()

func (PoConfig) Validate

func (c PoConfig) Validate() error

type PoLocationMode

type PoLocationMode string
const (
	PoLocationModeFull  PoLocationMode = "full"
	PoLocationModeNever PoLocationMode = "never"
	PoLocationModeFile  PoLocationMode = "file"
)

type PoOption

type PoOption func(*PoConfig)

func PoWithAddLocation

func PoWithAddLocation(loc PoLocationMode) PoOption

func PoWithCommentFuzzy

func PoWithCommentFuzzy(c bool) PoOption

func PoWithConfig

func PoWithConfig(cfg PoConfig) PoOption

func PoWithCopyrightHolder

func PoWithCopyrightHolder(holder string) PoOption

func PoWithCustomObsoletePrefixRune

func PoWithCustomObsoletePrefixRune(r rune) PoOption

func PoWithForcePo

func PoWithForcePo(f bool) PoOption

func PoWithForeignUser

func PoWithForeignUser(f bool) PoOption

func PoWithHeaderComments

func PoWithHeaderComments(hc bool) PoOption

func PoWithHeaderFields

func PoWithHeaderFields(w bool) PoOption

func PoWithIgnoreErrors

func PoWithIgnoreErrors(i bool) PoOption

func PoWithLogger

func PoWithLogger(logger *log.Logger) PoOption

func PoWithMsgstrPrefix

func PoWithMsgstrPrefix(prefix string) PoOption

func PoWithMsgstrSuffix

func PoWithMsgstrSuffix(suffix string) PoOption

func PoWithNoLocation

func PoWithNoLocation(n bool) PoOption

func PoWithOmitHeader

func PoWithOmitHeader(o bool) PoOption

func PoWithPackageName

func PoWithPackageName(name string) PoOption

func PoWithTitle

func PoWithTitle(t string) PoOption

func PoWithUseCustomObsoletePrefix

func PoWithUseCustomObsoletePrefix(u bool) PoOption

func PoWithVerbose

func PoWithVerbose(v bool) PoOption

func PoWithWordWrap

func PoWithWordWrap(w bool) PoOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL