Package translate :: Package storage :: Module cpo :: 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', gpo_message=None)
Constructs a TranslationUnit containing the given source string.
source code
 
setmsgidcomment(self, msgidcomment) source code
 
setmsgid_plural(self, msgid_plural) source code
string
getid(self)
The unique identifier for this unit according to the convensions in .mo files.
source code
 
copy(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) source code
 
hasmarkedcomment(self, commentmarker) 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) source code
 
resurrect(self) source code
 
hasplural(self)
Tells whether or not this specific unit has plural strings.
source code
String
_extract_msgidcomments(self, text=None)
Extract KDE style msgid comments from the unit.
source code
 
__str__(self)
str(x)
source code
 
getcontext(self)
Get the message context.
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) source code
 
setsource(self, source) source code

Inherited from base.TranslationUnit: getsourcelanguage

    Target
 
gettarget(self) source code
 
settarget(self, target)
Sets the target string to the given value.
source code

Inherited from base.TranslationUnit: gettargetlanguage, gettargetlen

    Notes
 
getnotes(self, origin=None)
Returns all notes about this unit.
source code
 
addnote(self, text, origin=None, position='append')
Adds a note (comment).
source code
 
removenotes(self)
Remove all the translator's notes.
source code
    Locations
List
getlocations(self)
A list of source code locations.
source code
 
addlocation(self, location)
Add one location to the list of locations.
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]
  msgidcomment
  msgid_plural

Inherited from object: __class__

    Source
  source
    Target
  target
Method Details [hide private]

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

source code 

Constructs a TranslationUnit containing the given source string.

Overrides: object.__init__
(inherited documentation)

settarget(self, target)

source code 

Sets the target string to the given value.

Overrides: base.TranslationUnit.settarget
(inherited documentation)

getid(self)

source code 

The unique identifier for this unit according to the convensions in .mo files.

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

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)

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

source code 

Adds a note (comment).

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
(inherited documentation)

removenotes(self)

source code 

Remove all the translator's notes.

Overrides: base.TranslationUnit.removenotes
(inherited documentation)

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 

Tells whether or not this specific unit has plural strings.

Overrides: base.TranslationUnit.hasplural
(inherited documentation)

_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.

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

getlocations(self)

source code 

A list of source code locations.

Returns: List
Overrides: base.TranslationUnit.getlocations
(inherited documentation)

addlocation(self, location)

source code 

Add one location to the list of locations.

Overrides: base.TranslationUnit.addlocation
(inherited documentation)

getcontext(self)

source code 

Get the message context.

Overrides: base.TranslationUnit.getcontext
(inherited documentation)

Property Details [hide private]

msgidcomment

Set Method:
setmsgidcomment(self, msgidcomment)

msgid_plural

Set Method:
setmsgid_plural(self, msgid_plural)

source

Get Method:
getsource(self)
Set Method:
setsource(self, source)

target

Get Method:
gettarget(self)
Set Method:
settarget(self, target) - Sets the target string to the given value.