tmx

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version                                = "1.4"
	FileExtension                          = "tmx"
	MIMEType                               = "application/x-tmx+xml"
	XMLNS                                  = "http://www.lisa.org/tmx14"
	DefaultCreationTool                    = version.PackageName
	DefaultCreationToolVersion             = version.Version
	DataTypePlainText                      = "plaintext"
	SegmentTypeSentence                    = "sentence"
	DefaultOriginalTranslationMemoryFormat = version.DisplayName + " TMX"
	DefaultUserName                        = "anonymous"
	TimeFormat                             = "20060102T150405Z"
)

const ...

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	XMLName xml.Name `xml:"body"`
	TUList  []*TU    `xml:"tu"`
}

Body : The <body> element encloses the main data, the set of <tu> elements that are comprised within the file.

type Header struct {
	XMLName xml.Name `xml:"header"`
	// The creationtool attribute identifies the tool that created the TMX document. Its possible values are not specified by the standard but each tool provider will publish the string identifier it uses.
	CreationTool string `xml:"creationtool,attr"`
	// The creationtoolversion attribute identifies the version of the tool that created the TMX document. Its possible values are not specified by the standard but each tool provider will publish the string identifier it uses.
	CreationToolVersion string `xml:"creationtoolversion,attr"`
	// The datatype attribute specifies the type of data contained in an element. Its default value is "unknown". See the recommended values section for more information.
	DataType string `xml:"datatype,attr"`
	// The segtype attribute specifies the kind of segmentation used in the <tu> element. Its value must be either "block", "paragraph", "sentence" or "phrase". If a<tu> element does not have a segtype attribute specified, it is of the type defined in the <header> element.
	// See the Implementation Notes for examples of how to use segtype.
	SegmentType string `xml:"segtype,attr"`
	// The o-tmf (Original Translation Memory Format) element specifies the format of the Translation Memory file from which the TMX document or segment thereof have been generated.
	OriginalTranslationMemoryFormat string `xml:"o-tmf,attr,omitempty"`
	// The srclang attribute specifies the language or locale of the source text. Its value must be one of the values used by a xml:lang attribute or the value "*all*" to indicate that any language combination can be used.
	SourceLang string `xml:"srclang,attr,omitempty"`
	// The adminlang attribute is used in the <header> element to specify the default language for the administrative and informative elements <note> and <prop>. Its value must be one of the values used by a xml:lang attribute.
	AdminLang string `xml:"adminlang,attr,omitempty"`
	// The creationdate attribute specifies the date of the creation of the element.
	// Its value must be in ASCII, in the format YYYYMMDDThhmmssZ.
	// (e.g. 19970811T133402Z for August 11th 1997 at 1:34pm 2 seconds.)
	// This is one of the options described in ISO 8601:1988. The value is always given in UTC (as indicated by the terminal Z).
	CreationDate string `xml:"creationdate,attr,omitempty"`
	// The creationid attribute specifies the user who created the element.
	CreationID string `xml:"creationid,attr,omitempty"`
	// The changedate attribute specifies the date of the modification of the element.
	// Its value must be in ASCII, in the format YYYYMMDDThhmmssZ.
	// (e.g. 19970811T133402Z for August 11th 1997 at 1:34pm 2 seconds.)
	// This is one of the options described in ISO 8601:1988. The value is always given in UTC (as indicated by the terminal Z).
	ChangeDate string `xml:"changedate,attr,omitempty"`
	// The changeid attribute specifies the user who modified the element.
	ChangeID string `xml:"changeid,attr,omitempty"`
}

Header : The <header> element contains zero, one or more <note> elements; zero, one or more <ude> elements; and zero, one or more <prop> elements.

type Option

type Option func(tmx *TMX)

Option ...

func AdminLanguageOption

func AdminLanguageOption(tag language.Tag) Option

AdminLanguageOption ...

func ChangeOption

func ChangeOption(t time.Time, id string) Option

ChangeOption ...

func CreationOption

func CreationOption(t time.Time, id string) Option

CreationOption ...

func CreationToolOption

func CreationToolOption(name, version string) Option

CreationToolOption ...

func DataTypeOption

func DataTypeOption(dataType string) Option

DataTypeOption ...

func OriginalTranslationMemoryFormatOption

func OriginalTranslationMemoryFormatOption(otmf string) Option

OriginalTranslationMemoryFormatOption ...

func SegmentTypeOption

func SegmentTypeOption(segmentType string) Option

SegmentTypeOption ...

func SourceLanguageOption

func SourceLanguageOption(tag language.Tag) Option

SourceLanguageOption ...

func UseUTF16BEXMLEncodingOption

func UseUTF16BEXMLEncodingOption() Option

UseUTF16BEXMLEncodingOption ...

func UseUTF16LEXMLEncodingOption

func UseUTF16LEXMLEncodingOption() Option

UseUTF16LEXMLEncodingOption ...

func UseUTF8XMLEncodingOption

func UseUTF8XMLEncodingOption() Option

UseUTF8XMLEncodingOption ...

type TMX

type TMX struct {
	XMLName xml.Name `xml:"tmx"`
	XMLNS   string   `xml:"xmlns,attr"`
	Version string   `xml:"version,attr"`
	Header  Header   `xml:"header"`
	Body    Body     `xml:"body"`

	tm.TM
}

TMX ...

func New

func New(opts ...Option) (*TMX, error)

New : [Translation Memory eXchange](https://en.wikipedia.org/wiki/Translation_Memory_eXchange)

func (*TMX) AddTU

func (t *TMX) AddTU(id string, list ...*TUV) error

AddTU ...

type TU

type TU struct {
	XMLName xml.Name `xml:"tu"`
	// The ID attribute specifies an identifier for the <TU> element. Its value is not defined by the standard (it could be unique or not, numeric or alphanumeric, etc.).
	ID      string `xml:"id,attr,omitempty"`
	TUVList []*TUV `xml:"tuv"`
}

TU : Each <tu> (Translation Unit) element contains zero, one or more <note> elements or <prop> elements, followed by one or more <tuv> elements. Logically, a complete translation-memory database will contain at least two <tuv> elements in each Translation Unit.

type TUV

type TUV struct {
	XMLName xml.Name `xml:"tuv"`
	XMLLang string   `xml:"http://www.w3.org/XML/1998/namespace lang,attr"`
	Segment string   `xml:"seg"`
	// The creationdate attribute specifies the date of the creation of the element.
	// Its value must be in ASCII, in the format YYYYMMDDThhmmssZ.
	// (e.g. 19970811T133402Z for August 11th 1997 at 1:34pm 2 seconds.)
	// This is one of the options described in ISO 8601:1988. The value is always given in UTC (as indicated by the terminal Z).
	CreationDate string `xml:"creationdate,attr,omitempty"`
	// The creationid attribute specifies the user who created the element.
	CreationID string `xml:"creationid,attr,omitempty"`
	// The changedate attribute specifies the date of the modification of the element.
	// Its value must be in ASCII, in the format YYYYMMDDThhmmssZ.
	// (e.g. 19970811T133402Z for August 11th 1997 at 1:34pm 2 seconds.)
	// This is one of the options described in ISO 8601:1988. The value is always given in UTC (as indicated by the terminal Z).
	ChangeDate string `xml:"changedate,attr,omitempty"`
	// The changeid attribute specifies the user who modified the element.
	ChangeID string `xml:"changeid,attr,omitempty"`
}

TUV : Each <tuv> (Translation Unit Variant) element specifies text in a given language. It contains zero, one or more <note> elements or <prop> elements, followed by one <seg> element.

func NewTUV

func NewTUV(opts ...TUVOption) *TUV

NewTUV ...

type TUVOption

type TUVOption func(tuv *TUV)

TUVOption ...

func ChangeTUVOption

func ChangeTUVOption(t time.Time, id string) TUVOption

ChangeTUVOption ...

func CreationTUVOption

func CreationTUVOption(t time.Time, id string) TUVOption

CreationTUVOption ...

func SegmentTUVOption

func SegmentTUVOption(segment string) TUVOption

SegmentTUVOption ...

func XMLLangTUVOption

func XMLLangTUVOption(tag language.Tag) TUVOption

XMLLangTUVOption ...

Jump to

Keyboard shortcuts

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