xliff

package
v0.0.0-...-8f05a37 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadTranslationUnits

func LoadTranslationUnits(reader io.Reader) (<-chan TranslationUnit, <-chan error)

LoadTranslationUnits returns a channel of TranslationUnit values and will start processing the xliff file passed in via the reader argument asynchronously. Whenever it it has read a TranslationUnit, this will written to the channel.

func SaveTranslationUnits

func SaveTranslationUnits(srcChan <-chan TranslationUnit, writer io.Writer) (n int)

SaveTranslationUnits will take a channel with translation units and stream them to writer in xliff xml format. The function will return when all translation units have been written. The goroutine feeding srcChan should close the channel once it has finished. The closing of the channel indicates to SaveTranslation that it can finish too. The function then returns the number of translation units it has written to the writer.

func XMLEscapeLoose

func XMLEscapeLoose(s string) string

XMLEscapeLoose will propertly XML escape the passed in text and return the escape text. The loose escaping will only replace the bare minimum so the text can be included as the text of an element, but not as an attribute value.

func XMLEscapeStrict

func XMLEscapeStrict(s string) (t string, err error)

XMLEscapeStrict will propertly XML escape the passed in text and return the escape text or an error. The result can be used e.g. as the value of an xml attribute value.

func XMLUnescape

func XMLUnescape(s string) string

XMLUnescape will remove the XML escaping from the passed in text and return the unescaped text.

Types

type TranslationFile

type TranslationFile struct {
	Original       string
	SourceLanguage string
	Datatype       string
	TargetLanguage string
}

TranslationFile contains meta information about the xliff file. There is one entry per xliff file. Every TranslationUnit carries a pointer to its TranslationFile.

func LoadTranslationMap

func LoadTranslationMap(reader io.Reader) (tf *TranslationFile, translation map[string]string, err error)

LoadTranslationMap reads xliff translation units from an xml file and then creates a translation map out of them. The mandatory id attribute in the trans-unit element is expected to match the id in the strings file. Both ID and Target value from the xliff file are unescaped before being written to the translation table.

type TranslationUnit

type TranslationUnit struct {
	File   *TranslationFile
	ID     string
	Source string
	Target string
	Note   string
}

TranslationUnit contains information about a single string to be translated. There are multiple entries per xliff file. Note that text in Source and Target fields is supposed to be properly escaped XML text. e.g. the character '&' replaced with '&amp;'

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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