Package translate :: Package storage :: Module tmx :: Class tmxunit
[hide private]
[frames] | no frames]

Class tmxunit

source code

          object --+        
                   |        
base.TranslationUnit --+    
                       |    
           lisa.LISAunit --+
                           |
                          tmxunit

A single unit in the TMX file.

Instance Methods [hide private]
 
createlanguageNode(self, lang, text, purpose)
returns a langset xml Element setup with given parameters
source code
string
getid(self)
Returns the identifier for this unit.
source code
 
istranslatable(self)
Indicates whether this unit can be translated.
source code
 
copy(self)
Make a copy of the translation unit.
source code

Inherited from lisa.LISAunit: __eq__, __init__, __str__, createPHnodes, getNodeText, getlanguageNode, getlanguageNodes, namespaced

Inherited from base.TranslationUnit: getcontext, getunits, hasplural, isblank, isfuzzy, isheader, isreview, istranslated, markfuzzy, markreviewneeded, merge, unit_iter

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

    Source

Inherited from lisa.LISAunit: getsource, setsource

Inherited from base.TranslationUnit: getsourcelanguage

    Target

Inherited from lisa.LISAunit: gettarget, settarget

Inherited from base.TranslationUnit: gettargetlanguage, gettargetlen

    Notes
 
addnote(self, text, origin=None)
Add a note specifically in a "note" tag.
source code
 
getnotelist(self, origin=None)
Private method that returns the text from notes.
source code
 
getnotes(self, origin=None)
Returns all notes about this unit.
source code
 
removenotes(self)
Remove all the translator notes.
source code
    Locations

Inherited from base.TranslationUnit: addlocation, addlocations, getlocations

    Errors
 
adderror(self, errorname, errortext)
Adds an error message to this unit.
source code
Dictionary
geterrors(self)
Get all error messages.
source code
Class Methods [hide private]

Inherited from lisa.LISAunit: createfromxmlElement

Inherited from base.TranslationUnit: buildfromunit

Class Variables [hide private]
  rootNode = 'tu'
  languageNode = 'tuv'
  textNode = 'seg'

Inherited from lisa.LISAunit: namespace

Properties [hide private]

Inherited from object: __class__

    Source

Inherited from lisa.LISAunit: source

    Target

Inherited from lisa.LISAunit: target

Method Details [hide private]

createlanguageNode(self, lang, text, purpose)

source code 

returns a langset xml Element setup with given parameters

Overrides: lisa.LISAunit.createlanguageNode

getid(self)

source code 

Returns the identifier for this unit. The optional tuid property is used if available, otherwise we inherit .getid(). Note that the tuid property is only mandated to be unique from TMX 2.0.

Returns: string
an identifier for this unit that is unique in the store

Derived classes should override this in a way that guarantees a unique identifier for each unit in the store.

Overrides: base.TranslationUnit.getid

istranslatable(self)

source code 

Indicates whether this unit can be translated.

This should be used to distinguish real units for translation from header, obsolete, binary or other blank units.

Overrides: base.TranslationUnit.istranslatable
(inherited documentation)

addnote(self, text, origin=None)

source code 

Add a note specifically in a "note" tag.

The origin parameter is ignored

Parameters:
  • text - Usually just a sentence or two.
  • origin - Specifies who/where the comment comes from. Origin can be one of the following text strings:
    • 'translator'
    • 'developer', 'programmer', 'source code' (synonyms)
Overrides: base.TranslationUnit.addnote

getnotelist(self, origin=None)

source code 

Private method that returns the text from notes.

The origin parameter is ignored..

getnotes(self, origin=None)

source code 

Returns all notes about this unit.

It will probably be freeform text or something reasonable that can be synthesised by the format. It should not include location comments (see getlocations()).

Overrides: base.TranslationUnit.getnotes
(inherited documentation)

removenotes(self)

source code 

Remove all the translator notes.

Overrides: base.TranslationUnit.removenotes

adderror(self, errorname, errortext)

source code 

Adds an error message to this unit.

Parameters:
  • errorname - A single word to id the error.
  • errortext - The text describing the error.
Overrides: base.TranslationUnit.adderror

geterrors(self)

source code 

Get all error messages.

Returns: Dictionary
Overrides: base.TranslationUnit.geterrors

copy(self)

source code 

Make a copy of the translation unit.

We don't want to make a deep copy - this could duplicate the whole XML tree. For now we just serialise and reparse the unit's XML.