Package translate :: Package storage :: Module pypo :: Class pounit
[hide private]
[frames] | no frames]

Class pounit

source code

          object --+        
                   |        
base.TranslationUnit --+    
                       |    
         pocommon.pounit --+
                           |
                          pounit

Base class for translation units.

Our concept of a translation unit is influenced heavily by XLIFF: http://www.oasis-open.org/committees/xliff/documents/xliff-specification.htm

As such most of the method- and variable names borrows from XLIFF terminology.

A translation unit consists of the following:

Instance Methods [hide private]
 
__init__(self, source=None, encoding='UTF-8')
Constructs a TranslationUnit containing the given source string.
source code
 
_initallcomments(self, blankall=False)
Initialises allcomments
source code
 
copy(self) source code
 
msgidlen(self) source code
 
msgstrlen(self) source code
 
merge(self, otherpo, overwrite=False, comments=True, authoritative=False)
Merges the otherpo (with the same msgid) into this one.
source code
 
isheader(self)
Indicates whether this unit is a header.
source code
 
isblank(self)
Used to see if this unit has no source or target string.
source code
 
hastypecomment(self, typecomment)
check whether the given type comment is present
source code
 
hasmarkedcomment(self, commentmarker)
check whether the given comment marker is present as # (commentmarker) ...
source code
 
settypecomment(self, typecomment, present=True)
alters whether a given typecomment is present
source code
 
istranslated(self)
Indicates whether this unit is translated.
source code
 
istranslatable(self)
Indicates whether this unit can be translated.
source code
 
isfuzzy(self)
Indicates whether this unit is fuzzy.
source code
 
markfuzzy(self, present=True)
Marks the unit as fuzzy or not.
source code
 
isreview(self)
Indicates whether this unit needs review.
source code
 
isobsolete(self) source code
 
makeobsolete(self)
Makes this unit obsolete
source code
 
resurrect(self)
Makes an obsolete unit normal
source code
 
hasplural(self)
returns whether this pounit contains plural strings...
source code
 
parselines(self, lines) source code
 
parse(self, src) source code
 
_getmsgpartstr(self, partname, partlines, partcomments='') source code
 
_encodeifneccessary(self, output)
encodes unicode strings and returns other strings unchanged
source code
 
__str__(self)
convert to a string.
source code
 
_getoutput(self)
return this po element as a string
source code
String
_extract_msgidcomments(self, text=None)
Extract KDE style msgid comments from the unit.
source code
 
getcontext(self)
Get the message context.
source code
string
getid(self)
Returns a unique identifier for this unit.
source code

Inherited from pocommon.pounit: markreviewneeded

Inherited from base.TranslationUnit: __eq__, getunits, unit_iter

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

    Source
 
getsource(self)
Returns the unescaped msgid
source code
 
setsource(self, source)
Sets the msgid to the given (unescaped) value.
source code

Inherited from base.TranslationUnit: getsourcelanguage

    Target
 
gettarget(self)
Returns the unescaped msgstr
source code
 
settarget(self, target)
Sets the msgstr to the given (unescaped) value
source code

Inherited from base.TranslationUnit: gettargetlanguage, gettargetlen

    Notes
 
getnotes(self, origin=None)
Return comments based on origin value (programmer, developer, source code and translator)
source code
 
addnote(self, text, origin=None, position='append')
This is modeled on the XLIFF method.
source code
 
removenotes(self)
Remove all the translator's notes (other comments)
source code
    Locations
List
getlocations(self)
Get a list of locations from sourcecomments in the PO unit
source code
 
addlocation(self, location)
Add a location to sourcecomments in the PO unit
source code

Inherited from base.TranslationUnit: addlocations

    Errors

Inherited from pocommon.pounit: adderror, geterrors

Class Methods [hide private]

Inherited from base.TranslationUnit: buildfromunit

Properties [hide private]

Inherited from object: __class__

    Source
  source
Returns the unescaped msgid
    Target
  target
Returns the unescaped msgstr
Method Details [hide private]

__init__(self, source=None, encoding='UTF-8')
(Constructor)

source code 

Constructs a TranslationUnit containing the given source string.

Overrides: object.__init__
(inherited documentation)

setsource(self, source)

source code 

Sets the msgid to the given (unescaped) value.

Parameters:
  • source - an unescaped source string.

settarget(self, target)

source code 

Sets the msgstr to the given (unescaped) value

Overrides: base.TranslationUnit.settarget

getnotes(self, origin=None)

source code 

Return comments based on origin value (programmer, developer, source code and translator)

Overrides: base.TranslationUnit.getnotes

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

source code 

This is modeled on the XLIFF method. See xliff.py::xliffunit.addnote

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

removenotes(self)

source code 

Remove all the translator's notes (other comments)

Overrides: base.TranslationUnit.removenotes

merge(self, otherpo, overwrite=False, comments=True, authoritative=False)

source code 

Merges the otherpo (with the same msgid) into this one.

Overwrite non-blank self.msgstr only if overwrite is True merge comments only if comments is True

Overrides: base.TranslationUnit.merge

isheader(self)

source code 

Indicates whether this unit is a header.

Overrides: base.TranslationUnit.isheader
(inherited documentation)

isblank(self)

source code 

Used to see if this unit has no source or target string.

Overrides: base.TranslationUnit.isblank
(inherited documentation)

istranslated(self)

source code 

Indicates whether this unit is translated.

This should be used rather than deducing it from .target, to ensure that other classes can implement more functionality (as XLIFF does).

Overrides: base.TranslationUnit.istranslated
(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)

isfuzzy(self)

source code 

Indicates whether this unit is fuzzy.

Overrides: base.TranslationUnit.isfuzzy
(inherited documentation)

markfuzzy(self, present=True)

source code 

Marks the unit as fuzzy or not.

Overrides: base.TranslationUnit.markfuzzy
(inherited documentation)

isreview(self)

source code 

Indicates whether this unit needs review.

Overrides: base.TranslationUnit.isreview
(inherited documentation)

hasplural(self)

source code 

returns whether this pounit contains plural strings...

Overrides: base.TranslationUnit.hasplural

__str__(self)
(Informal representation operator)

source code 

convert to a string. double check that unicode is handled somehow here

Overrides: object.__str__

getlocations(self)

source code 

Get a list of locations from sourcecomments in the PO unit

rtype: List return: A list of the locations with '#: ' stripped

Returns: List
Overrides: base.TranslationUnit.getlocations

addlocation(self, location)

source code 

Add a location to sourcecomments in the PO unit

Parameters:
  • location (String) - Text location e.g. 'file.c:23' does not include #:
Overrides: base.TranslationUnit.addlocation

_extract_msgidcomments(self, text=None)

source code 

Extract KDE style msgid comments from the unit.

Returns: String
Returns the extracted msgidcomments found in this unit's msgid.

getcontext(self)

source code 

Get the message context.

Overrides: base.TranslationUnit.getcontext

getid(self)

source code 

Returns 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

Property Details [hide private]

source

Returns the unescaped msgid

Get Method:
getsource(self) - Returns the unescaped msgid
Set Method:
setsource(self, source) - Sets the msgid to the given (unescaped) value.

target

Returns the unescaped msgstr

Get Method:
gettarget(self) - Returns the unescaped msgstr
Set Method:
settarget(self, target) - Sets the msgstr to the given (unescaped) value