Module pylupdate :: Class Translation
[hide private]
[frames] | no frames]

Class Translation

source code

object --+
         |
        Translation

Wrapper for a Qt linguist translation file

Instance Methods [hide private]
 
__init__(self, filename, language)
Instantiates a new Translation object
source code
 
_loadXml(self)
Parses the xml document from self.filename and creates corresponding context objects
source code
 
read(self, filename=None)
Read the translation file given by the filename
source code
 
write(self, language, dtd=None, filename=None)
Writes the data to a file.
source code
bool
__contains__(self, key)
Checks, if a context is contained
source code
Context
__getitem__(self, key)
Returns the context object references by its name
source code
str
__iter__(self)
Yields each context name contained in the translation
source code
 
addContext(self, key)
Creates a new context.
source code
 
removeContext(self, key)
Remove a context.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, filename, language)
(Constructor)

source code 

Instantiates a new Translation object

Parameters:
  • filename (str) - path to read from resp. write to
  • language (str) - the target language code
Overrides: object.__init__

read(self, filename=None)

source code 

Read the translation file given by the filename

Parameters:
  • filename (str) - if given, the path to the file to read. Defaults to None

write(self, language, dtd=None, filename=None)

source code 

Writes the data to a file.

Parameters:
  • language (str) - the target language code
  • dtd (str) - if set, the xml is validated before written, defaults to None, throws Exception if validation failed
  • filename (str) - if given, the path to write to, defaults to None

__contains__(self, key)
(In operator)

source code 

Checks, if a context is contained

Parameters:
  • key (str) - the context name
Returns: bool
returns True, if a context is contained by key's name

__getitem__(self, key)
(Indexing operator)

source code 

Returns the context object references by its name

Parameters:
  • key (str) - the name of the context
Returns: Context
the context

__iter__(self)

source code 

Yields each context name contained in the translation

Returns: str
the context names

addContext(self, key)

source code 

Creates a new context. A previous context with that name will be overwritten

Parameters:
  • key (str) - the name of the context

removeContext(self, key)

source code 

Remove a context.

Parameters:
  • key (str) - the name of the context