Package translate :: Package storage :: Module poxliff :: Class PoXliffUnit
[hide private]
[frames] | no frames]

Class PoXliffUnit

source code


A class to specifically handle the plural units created from a po file.

Instance Methods [hide private]
 
__init__(self, source=None, empty=False, encoding="UTF-8")
Override the constructor to set xml:space="preserve".
source code
Boolean
__eq__(self, other)
Compares two units
source code
 
multistring_to_rich(cls, mulstring)
Convert a multistring to a list of "rich" string trees:
source code
 
markfuzzy(self, value=True)
Marks the unit as fuzzy or not.
source code
 
marktranslated(self) source code
 
setid(self, id)
Sets the unique identified for this unit.
source code
 
getautomaticcomments(self)
Returns the automatic comments (x-po-autocomment), which corresponds to the #.
source code
 
gettranslatorcomments(self)
Returns the translator comments (x-po-trancomment), which corresponds to the # style po comments.
source code
 
isheader(self)
Indicates whether this unit is a header.
source code
 
istranslatable(self)
Indicates whether this unit can be translated.
source code
 
hasplural(self)
Tells whether or not this specific unit has plural strings.
source code

Inherited from xliff.xliffunit: addalttrans, correctorigin, createcontextgroup, createlanguageNode, delalttrans, getalttrans, getcontextgroups, getid, getlanguageNodes, getrestype, isapproved, isfuzzy, isreview, markapproved, markreviewneeded, merge

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

Inherited from lisa.LISAunit (private): _set_property

Inherited from base.TranslationUnit: getcontext, getunits, isblank, isobsolete, istranslated, makeobsolete, setcontext, unit_iter

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

    Source
 
setsource(self, source, sourcelang="en")
Sets the source string to the given value.
source code
 
getsource(self) source code

Inherited from xliff.xliffunit: get_rich_source, set_rich_source

Inherited from lisa.LISAunit: get_source_dom, set_source_dom

Inherited from base.TranslationUnit: getsourcelanguage

    Target
 
settarget(self, text, lang='xx', append=False)
Sets the target string to the given value.
source code
 
gettarget(self)
retrieves the "target" text (second entry), or the entry in the specified language, if it exists
source code

Inherited from xliff.xliffunit: get_rich_target, set_rich_target

Inherited from lisa.LISAunit: get_target_dom, set_target_dom, target_dom

Inherited from base.TranslationUnit: gettargetlanguage, gettargetlen

    Notes
 
addnote(self, text, origin=None, position="append")
Add a note specifically in a "note" tag
source code
 
getnotes(self, origin=None)
Returns all notes about this unit.
source code

Inherited from xliff.xliffunit: getnotelist, removenotes

    Locations
List
getlocations(self)
Returns all the references (source locations)
source code

Inherited from xliff.xliffunit: addlocation

Inherited from base.TranslationUnit: addlocations

    Errors

Inherited from xliff.xliffunit: adderror, geterrors

Class Methods [hide private]
 
rich_to_multistring(cls, elem_list)
Convert a "rich" string tree to a multistring:
 
createfromxmlElement(cls, element, namespace=None) source code

Inherited from base.TranslationUnit: buildfromunit

Class Variables [hide private]
  rich_parsers = [<bound method type.regex_parse of <class 'tran...
A list of functions to use for parsing a string into a rich string tree.

Inherited from xliff.xliffunit: languageNode, namespace, rootNode, textNode

Inherited from xliff.xliffunit (private): _default_xml_space

Inherited from lisa.LISAunit: rid, xid

    Source
  source = property(getsource, setsource)

Inherited from lisa.LISAunit: source_dom

    Target
  target = property(gettarget, settarget)
Properties [hide private]

Inherited from object: __class__

    Source
  rich_source
    Target
  rich_target
Method Details [hide private]

__init__(self, source=None, empty=False, encoding="UTF-8")
(Constructor)

source code 

Override the constructor to set xml:space="preserve".

Overrides: object.__init__
(inherited documentation)

__eq__(self, other)
(Equality operator)

source code 

Compares two units

Parameters:
Returns: Boolean
Returns True if the supplied TranslationUnit equals this unit.
Overrides: base.TranslationUnit.__eq__
(inherited documentation)

setsource(self, source, sourcelang="en")

source code 

Sets the source string to the given value.

Overrides: base.TranslationUnit.setsource
(inherited documentation)

multistring_to_rich(cls, mulstring)

source code 

Convert a multistring to a list of "rich" string trees:

>>> target = multistring([u'foo', u'bar', u'baz'])
>>> TranslationUnit.multistring_to_rich(target)
[<StringElem([<StringElem([u'foo'])>])>,
 <StringElem([<StringElem([u'bar'])>])>,
 <StringElem([<StringElem([u'baz'])>])>]
Overrides: base.TranslationUnit.multistring_to_rich

rich_to_multistring(cls, elem_list)
Class Method

 

Convert a "rich" string tree to a multistring:

>>> from translate.storage.placeables.interfaces import X
>>> rich = [StringElem(['foo', X(id='xxx', sub=[' ']), 'bar'])]
>>> TranslationUnit.rich_to_multistring(rich)
multistring(u'foo bar')
Overrides: base.TranslationUnit.rich_to_multistring

getsource(self)

source code 
Overrides: lisa.LISAunit.getsource

settarget(self, text, lang='xx', append=False)

source code 

Sets the target string to the given value.

Overrides: base.TranslationUnit.settarget
(inherited documentation)

gettarget(self)

source code 

retrieves the "target" text (second entry), or the entry in the specified language, if it exists

Overrides: lisa.LISAunit.gettarget
(inherited documentation)

addnote(self, text, origin=None, position="append")

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)

markfuzzy(self, value=True)

source code 

Marks the unit as fuzzy or not.

Overrides: base.TranslationUnit.markfuzzy
(inherited documentation)

marktranslated(self)

source code 
Overrides: xliff.xliffunit.marktranslated

setid(self, id)

source code 

Sets the unique identified for this unit.

only implemented if format allows ids independant from other unit properties like source or context

Overrides: base.TranslationUnit.setid
(inherited documentation)

getlocations(self)

source code 

Returns all the references (source locations)

Returns: List
Overrides: base.TranslationUnit.getlocations

getautomaticcomments(self)

source code 

Returns the automatic comments (x-po-autocomment), which corresponds to the #. style po comments.

isheader(self)

source code 

Indicates whether this unit is a header.

Overrides: base.TranslationUnit.isheader
(inherited documentation)

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)

createfromxmlElement(cls, element, namespace=None)
Class Method

source code 
Overrides: lisa.LISAunit.createfromxmlElement

hasplural(self)

source code 

Tells whether or not this specific unit has plural strings.

Overrides: base.TranslationUnit.hasplural
(inherited documentation)

Class Variable Details [hide private]

rich_parsers

A list of functions to use for parsing a string into a rich string tree.

Value:
[<bound method type.regex_parse of <class 'translate.storage.placeable\
s.general.NewlinePlaceable'>>,
 <bound method type.regex_parse of <class 'translate.storage.placeable\
s.general.XMLTagPlaceable'>>,
 <bound method type.regex_parse of <class 'translate.storage.placeable\
s.general.AltAttrPlaceable'>>,
 <bound method type.regex_parse of <class 'translate.storage.placeable\
s.general.XMLEntityPlaceable'>>,
...

Property Details [hide private]

rich_source

Get Method:
_get_rich_source(self)
Set Method:
_set_rich_source(self, value)

rich_target

Get Method:
_get_rich_target(self)
Set Method:
_set_rich_target(self, value)