nptl

package
v0.0.0-...-2155e2d Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2020 License: BSD-3-Clause Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	// Handle takes in the source bytes (usually from a file) and returns modified target bytes
	// where the translatable content has been pseudo translated.
	Handle(ctx context.Context, source []byte) ([]byte, error)
}

A Handler is able to pseudo translate the translatble content for a specific format.

type PTCombination

type PTCombination struct {
	SourceFile        string
	TargetFile        string
	Handler           Handler
	TargetPermissions os.FileMode
}

func (PTCombination) PseudoTranslate

func (r PTCombination) PseudoTranslate(ctx context.Context) error

type Runes

type Runes []rune

Runes are used to pass around translatable content in an unambigous format.

func FromBytes

func FromBytes(buf []byte) (Runes, error)

FromBytes reads a slice of bytes in ASCII or UTF-8 and then creates and returns new Runes.

func FromString

func FromString(s string) (Runes, error)

FromString creates and returns new Runes based on the provided string content.

func (Runes) String

func (rs Runes) String() string

func (Runes) ToUTF8Bytes

func (rs Runes) ToUTF8Bytes() ([]byte, error)

ToUTF8Bytes returns bytes representing the Runes in UTF-8 encoding.

type Translator

type Translator interface {
	// Translate accepts Runes and returns a pseudo translated variant.
	Translate(context.Context, Runes) (Runes, error)
}

A Translator is able to apply a pseudo translation algorithm to Runes.

Jump to

Keyboard shortcuts

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