Documentation ¶
Overview ¶
Package labels offes types and functions to load and save XLIFF v1 and TYPO3 locallang XML files
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Label ¶
type Label struct { ID string `json:"id"` Translations []*Translation `json:"trans"` }
Label is a single label, containing one or more translations
type Labels ¶
type Labels struct { File string `json:"documentTitle"` Type XMLType `json:"format"` FromFile string `json:"-"` SrcXlif *Xliff `json:"-"` SrcLegacy *T3Root `json:"-"` Languages []string `json:"languages"` Data []*Label `json:"labels"` }
Labels is the root object of all translations
func New ¶
New create a new Labels object for the given file That file should not exist yet, because its content will be overwritten upon the first save
type LocallangConverter ¶
type LocallangConverter struct {
// contains filtered or unexported fields
}
LocallangConverter translates a Labels structure to a T3Root structure that can be marshalled to XML
func (*LocallangConverter) File ¶
func (c *LocallangConverter) File() string
File returns the file name and path of the source
func (*LocallangConverter) XML ¶
func (c *LocallangConverter) XML() LangFile
XML will convert the Labels in src into a LangFile
type T3Data ¶
type T3Data struct { Type string `xml:"type,attr,omitempty"` Languages []*T3Lang `xml:"languageKey,omitempty"` }
T3Data is the blocks of translations
type T3Label ¶
T3Label is a singe label and key pair
func (*T3Label) MarshalXML ¶
MarshalXML will marshal a labels content to a XML element
type T3Lang ¶
type T3Lang struct { Type string `xml:"type,attr,omitempty"` Language string `xml:"index,attr,omitempty"` Labels []*T3Label `xml:"label,omitempty"` }
T3Lang is a list of labels for a single language
type T3Meta ¶
type T3Meta struct { Type string `xml:"type,attr,omitempty"` For string `xml:"type,omitempty"` Content string `xml:"description,omitempty"` }
T3Meta is the meta block of a legacy XML
type T3Root ¶
type T3Root struct { XMLName string `xml:"T3locallang"` Meta *T3Meta `xml:"meta,omitempty"` Data *T3Data `xml:"data"` SourceFile string `xml:"-"` }
T3Root is the root element of a legacy XML
func (*T3Root) IndentChar ¶ added in v0.4.0
IndentChar determines the string for indentation or XML tags
type Translation ¶
type Translation struct { Content string `json:"content"` Approved string `json:"approved"` Language string `json:"lng"` }
Translation is the text of a label in the given language
type XliffBody ¶
type XliffBody struct {
Units []*XliffUnit `xml:"trans-unit,omitempty"`
}
XliffBody contains the units of a Xliff document
type XliffConverter ¶
type XliffConverter struct {
// contains filtered or unexported fields
}
XliffConverter will convert a Xliff structure to struct Labels
func (*XliffConverter) File ¶
func (c *XliffConverter) File() string
File determines the desired target file of this document
func (*XliffConverter) XML ¶
func (c *XliffConverter) XML() LangFile
XML will return the Xliff structure of a Labels structure
type XliffFile ¶
type XliffFile struct { SrcLang string `xml:"source-language,attr"` ToLang string `xml:"target-language,attr,omitempty"` Orig string `xml:"original,attr"` Datatype string `xml:"datatype,attr"` Name string `xml:"product-name,attr,omitempty"` Date string `xml:"date,attr,omitempty"` Header *XliffHeader `xml:"header,omitempty"` Body *XliffBody `xml:"body,omitempty"` }
XliffFile is the actual root node of a Xliff document
type XliffHeader ¶
type XliffHeader struct { Skl string `xml:"skl,omitempty"` PhaseGrp string `xml:"phase-group,omitempty"` Glossary string `xml:"glossary,omitempty"` Ref string `xml:"reference,omitempty"` CountGrp string `xml:"count-group,omitempty"` Tool string `xml:"tool,omitempty"` PopGrp string `xml:"pop-group,omitempty"` Note string `xml:"note,omitempty"` // Non-standard, but common in TYPO3 Type string `xml:"type,omitempty"` Description string `xml:"description,omitempty"` AuthName string `xml:"authorName,omitempty"` AuthMail string `xml:"authorEmail,omitempty"` AuthCompany string `xml:"authorCompany,omitempty"` Generator string `xml:"generator,omitempty"` }
XliffHeader is a collection of common metadata
type XliffRoot ¶
type XliffRoot struct { XMLName string `xml:"xliff"` Version string `xml:"version,attr,omitempty"` XMLNS string `xml:"xmlns,attr,omitempty"` File *XliffFile `xml:"file,omitempty"` Language string `xml:"-"` SourceFile string `xml:"-"` }
XliffRoot is the virtual root node of a XML document
func (*XliffRoot) IndentChar ¶ added in v0.4.0
IndentChar determines the string for indentation or XML tags