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

Class pounit

source code


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
 
__deepcopy__(self, memo={}) 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
 
isobsolete(self)
indicate whether a unit is obsolete
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
 
parse(self, src) source code
 
__str__(self)
convert to 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: isreview, markreviewneeded

Inherited from base.TranslationUnit: __eq__, getunits, multistring_to_rich, setcontext, setid, unit_iter

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

    Source
 
getsource(self) source code
 
setsource(self, source)
Sets the source string to the given 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]
 
buildfromunit(cls, unit)
Build a native unit from a foreign unit, preserving as much information as possible.
source code

Inherited from base.TranslationUnit: rich_to_multistring

Class Variables [hide private]
  __shallow__ = ['_store']

Inherited from base.TranslationUnit: rich_parsers

    Source
  source = property(getsource, setsource)
    Target
  target = property(gettarget, settarget)
Properties [hide private]

Inherited from base.TranslationUnit: rid, xid

Inherited from object: __class__

    Source

Inherited from base.TranslationUnit: rich_source

    Target

Inherited from base.TranslationUnit: rich_target

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 source string to the given value.

Overrides: base.TranslationUnit.setsource
(inherited documentation)

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)

isobsolete(self)

source code 

indicate whether a unit is obsolete

Overrides: base.TranslationUnit.isobsolete
(inherited documentation)

makeobsolete(self)

source code 

Makes this unit obsolete

Overrides: base.TranslationUnit.makeobsolete

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

buildfromunit(cls, unit)
Class Method

source code 

Build a native unit from a foreign unit, preserving as much information as possible.

Overrides: base.TranslationUnit.buildfromunit