Package translate :: Package storage :: Module xliff :: Class xliffunit |
[hide private]
[frames] | no frames]

# Class xliffunit

source code

A single term in the xliff file.

Instance Methods | [hide private]
__init__(self, source, empty=False, **kwargs) Override the constructor to set xml:space="preserve". | source code
createlanguageNode(self, lang, text, purpose) Returns an xml Element setup with given parameters. | source code
getlanguageNodes(self) We override this to get source and target nodes. | source code
addalttrans(self, txt, origin=None, lang=None, sourcetxt=None, matchquality=None) Adds an alt-trans tag and alt-trans components to the unit. | source code
getalttrans(self, origin=None) Returns <alt-trans> for the given origin as a list of units. | source code
delalttrans(self, alternative) Removes the supplied alternative from the list of alt-trans tags | source code
isapproved(self) States whether this unit is approved. | source code
markapproved(self, value=True) Mark this unit as approved. | source code
isreview(self) States whether this unit needs to be reviewed | source code
markreviewneeded(self, needsreview=True, explanation=None) Marks the unit to indicate whether it needs review. | source code
isfuzzy(self) Indicates whether this unit is fuzzy. | source code
markfuzzy(self, value=True) Marks the unit as fuzzy or not. | source code
istranslatable(self) Indicates whether this unit can be translated. | source code
marktranslated(self) | source code
setid(self, id) | source code
string |
getid(self) A unique identifier for this unit. | source code
createcontextgroup(self, name, contexts=None, purpose=None) Add the context group to the trans-unit with contexts a list with (type, text) tuples describing each context. | source code
getcontextgroups(self, name) Returns the contexts in the context groups with the specified name | source code
getrestype(self) returns the restype attribute in the trans-unit tag | source code
merge(self, otherunit, overwrite=False, comments=True, authoritative=False) Do basic format agnostic merging. | source code
correctorigin(self, node, origin) Check against node tag's origin (e.g note or alt-trans) | source code
Inherited from `lisa.LISAunit`: `__eq__`, `__str__`, `createPHnodes`, `getNodeText`, `getlanguageNode`, `namespaced` Inherited from `lisa.LISAunit` (private): `_set_property` Inherited from `base.TranslationUnit`: `getcontext`, `getunits`, `hasplural`, `isblank`, `isheader`, `istranslated`, `unit_iter` Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`
Source
set_rich_source(self, value, sourcelang='en') | source code
get_rich_source(self) | source code
Inherited from `lisa.LISAunit`: `get_source_dom`, `getsource`, `set_source_dom`, `setsource` Inherited from `base.TranslationUnit`: `getsourcelanguage` Inherited from `base.TranslationUnit` (private): `_get_rich_source`, `_set_rich_source`
Target
set_rich_target(self, value, lang='xx', append=False) | source code
get_rich_target(self, lang=None) retrieves the "target" text (second entry), or the entry in the specified language, if it exists | source code
settarget(self, text, lang='xx', append=False) Sets the target string to the given value. | source code
Inherited from `lisa.LISAunit`: `get_target_dom`, `gettarget`, `set_target_dom`, `target_dom` Inherited from `base.TranslationUnit`: `gettargetlanguage`, `gettargetlen` Inherited from `base.TranslationUnit` (private): `_get_rich_target`, `_set_rich_target`
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 matching 'origin' or all notes. | source code
getnotes(self, origin=None) Returns all notes about this unit. | source code
removenotes(self, origin="translator") Remove all the translator notes. | source code
Locations
addlocation(self, location) Add one location to the list of locations. | source code
List |
getlocations(self) A list of source code locations. | source code
Inherited from `base.TranslationUnit`: `addlocations`
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]
multistring_to_rich(self, mstr) Override TranslationUnit.multistring_to_rich which is used by the `rich_source` and `rich_target` properties. | source code
rich_to_multistring(self, elem_list) Override TranslationUnit.rich_to_multistring which is used by the `rich_source` and `rich_target` properties. | source code
Inherited from `lisa.LISAunit`: `createfromxmlElement` Inherited from `base.TranslationUnit`: `buildfromunit`

Class Variables | [hide private]
| rootNode = `"trans-unit"`
| languageNode = `"source"`
| textNode = `""`
| namespace = `'urn:oasis:names:tc:xliff:document:1.1'` Parse an instance of this class from the start of the given string.
| _default_xml_space = `"default"` The default handling of spacing in the absense of an xml:space attribute.
Inherited from `lisa.LISAunit`: `rid`, `xid` Inherited from `base.TranslationUnit`: `rich_parsers`
Source
| rich_source = `property(get_rich_source, set_rich_source)`
Inherited from `lisa.LISAunit`: `source`, `source_dom`
Target
| rich_target = `property(get_rich_target, set_rich_target)`
Inherited from `lisa.LISAunit`: `target`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, source, empty=False, **kwargs) (Constructor) | source code
Override the constructor to set xml:space="preserve". Overrides: object.__init__

### createlanguageNode(self, lang, text, purpose) | source code
Returns an xml Element setup with given parameters. Overrides: lisa.LISAunit.createlanguageNode

### getlanguageNodes(self) | source code
We override this to get source and target nodes. Overrides: lisa.LISAunit.getlanguageNodes

### addalttrans(self, txt, origin=None, lang=None, sourcetxt=None, matchquality=None) | source code
Adds an alt-trans tag and alt-trans components to the unit. Parameters: `txt` (String) - Alternative translation of the source text.

### getalttrans(self, origin=None) | source code
Returns <alt-trans> for the given origin as a list of units. No origin means all alternatives.

### addnote(self, text, origin=None) | source code
Add a note specifically in a "note" tag 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

### 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, origin="translator") | 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

### isreview(self) | source code
States whether this unit needs to be reviewed Overrides: base.TranslationUnit.isreview

### markreviewneeded(self, needsreview=True, explanation=None) | source code
Marks the unit to indicate whether it needs review. Adds an optional explanation as a note. Parameters: `needsreview` - Defaults to True. `explanation` - Adds an optional explanation as a note. Overrides: base.TranslationUnit.markreviewneeded

### isfuzzy(self) | source code
Indicates whether this unit is fuzzy. Overrides: base.TranslationUnit.isfuzzy (inherited documentation)

### markfuzzy(self, value=True) | source code
Marks the unit as fuzzy or not. Overrides: base.TranslationUnit.markfuzzy (inherited documentation)

### settarget(self, text, lang='xx', append=False) | source code
Sets the target string to the given value. Overrides: base.TranslationUnit.settarget

### 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)

### getid(self) | source code
A unique identifier for this unit. 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 (inherited documentation)

### addlocation(self, location) | source code
Add one location to the list of locations. Overrides: base.TranslationUnit.addlocation (inherited documentation)

### getlocations(self) | source code
A list of source code locations. Returns: List Overrides: base.TranslationUnit.getlocations (inherited documentation)

### merge(self, otherunit, overwrite=False, comments=True, authoritative=False) | source code
Do basic format agnostic merging. Overrides: base.TranslationUnit.merge (inherited documentation)

### multistring_to_rich(self, mstr) Class Method | source code
Override TranslationUnit.multistring_to_rich which is used by the `rich_source` and `rich_target` properties. Overrides: base.TranslationUnit.multistring_to_rich

### rich_to_multistring(self, elem_list) Class Method | source code
Override TranslationUnit.rich_to_multistring which is used by the `rich_source` and `rich_target` properties. Overrides: base.TranslationUnit.rich_to_multistring

Class Variable Details | [hide private]

  ### rich_source See Also: rich_to_multistring, multistring_to_rich Value:
      property(get_rich_source, set_rich_source)

  ### rich_target See Also: rich_to_multistring, multistring_to_rich Value:
      property(get_rich_target, set_rich_target)