Package translate :: Package storage :: Module xliff :: Class xliffunit

[hide private]
[frames] | no frames]

# Class xliffunit

source code

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

Known Subclasses:
  - poxliff.PoXliffUnit

A single term in the xliff file.

Instance Methods | [hide private]

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) 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) 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__`, `__init__`, `__str__`, `createPHnodes`, `getNodeText`, `getlanguageNode`, `namespaced` 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
Inherited from `lisa.LISAunit`: `getsource`, `setsource` Inherited from `base.TranslationUnit`: `getsourcelanguage`
Target

settarget(self, text, lang=`'``xx``'`, append=False) Sets the target string to the given value. | source code

Inherited from `lisa.LISAunit`: `gettarget` 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 matching 'origin' or all 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

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]

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``'``

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

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)

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)

source code

Do basic format agnostic merging.

Overrides: base.TranslationUnit.merge
  (inherited documentation)