Package translate :: Package storage :: Module poheader :: Class poheader

[hide private]
[frames] | no frames]

# Class poheader

source code

This class implements functionality for manipulation of po file headers. This class is a mix-in class and useless on its own. It must be used from all classes which represent a po file

Instance Methods | [hide private]

init_headers(self, charset=`'``utf-8``'`, encoding=`'``8bit``'`, **kwargs) sets default values for po headers | source code

dict

makeheaderdict(self, charset=`'``CHARSET``'`, encoding=`'``ENCODING``'`, project_id_version=None, pot_creation_date=None, po_revision_date=None, last_translator=None, language_team=None, mime_version=None, plural_forms=None, report_msgid_bugs_to=None, **kwargs) Create a header dictionary with useful defaults. | source code

header(self) Returns the header element, or None. | source code

parseheader(self) Parses the PO header and returns the interpreted values as a dictionary. | source code

updateheader(self, add=False, **kwargs) Updates the fields in the PO style header. | source code

_insert_header(self, header) | source code

getheaderplural(self) Returns the nplural and plural values from the header. | source code

updateheaderplural(self, nplurals, plural) Update the Plural-Form PO header. | source code

gettargetlanguage(self) Return the target language based on information in the header. | source code

settargetlanguage(self, lang) Set the target language in the header. | source code

getprojectstyle(self) Return the project based on information in the header. | source code

setprojectstyle(self, project_style) Set the project in the header. | source code

mergeheaders(self, otherstore) Merges another header with this header. | source code

updatecontributor(self, name, email=None) Add contribution comments if necessary. | source code

makeheader(self, **kwargs) Create a header for the given filename. | source code

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

Class Variables | [hide private]

| x_generator = ``'``Translate Toolkit 1.8.1``'``
| header_order = ``[``'``Project-Id-Version``'``,` `'``Report-Msgid-Bugs-To``'``,` `...``

Properties | [hide private]

Inherited from `object`: `__class__`

Method Details | [hide private]

### makeheaderdict(self, charset=`'``CHARSET``'`, encoding=`'``ENCODING``'`, project_id_version=None, pot_creation_date=None, po_revision_date=None, last_translator=None, language_team=None, mime_version=None, plural_forms=None, report_msgid_bugs_to=None, **kwargs)

source code

Create a header dictionary with useful defaults.

pot_creation_date can be None (current date) or a value (datetime or string) po_revision_date can be None (form), False (=pot_creation_date), True (=now), or a value (datetime or string)

Returns: dict
  Dictionary with the header items

### header(self)

source code

Returns the header element, or None. Only the first element is allowed to be a header. Note that this could still return an empty header element, if present.

### updateheader(self, add=False, **kwargs)

source code

Updates the fields in the PO style header.

This will create a header if add == True.

### gettargetlanguage(self)

source code

Return the target language based on information in the header.

The target language is determined in the following sequence:

1. Use the 'Language' entry in the header.
2. Poedit's custom headers.
3. Analysing the 'Language-Team' entry.

### settargetlanguage(self, lang)

source code

Set the target language in the header.

This removes any custom Poedit headers if they exist.

Parameters:
  - `lang` (str) - the new target language code

### getprojectstyle(self)

source code

Return the project based on information in the header.

The project is determined in the following sequence:

1. Use the 'X-Project-Style' entry in the header.
2. Use 'Report-Msgid-Bug-To' entry
3. Use the 'X-Accelerator' entry
4. Use the Project ID
5. Analyse the file itself (not yet implemented)

### setprojectstyle(self, project_style)

source code

Set the project in the header.

Parameters:
  - `project_style` (str) - the new project

### mergeheaders(self, otherstore)

source code

Merges another header with this header.

This header is assumed to be the template.

Parameters:
  - `otherstore` (base.TranslationStore)

### makeheader(self, **kwargs)

source code

Create a header for the given filename.

Check .makeheaderdict() for information on parameters.

Class Variable Details | [hide private]

### header_order

Value:

      ['Project-Id-Version',
       'Report-Msgid-Bugs-To',
       'POT-Creation-Date',
       'PO-Revision-Date',
       'Last-Translator',
       'Language-Team',
       'Language',
       'MIME-Version',
      ...