Package translate :: Package storage :: Module xliff :: Class xlifffile
[hide private]
[frames] | no frames]

Class xlifffile

source code

           object --+        
                    |        
base.TranslationStore --+    
                        |    
            lisa.LISAfile --+
                            |
                           xlifffile
Known Subclasses:

Class representing a XLIFF file store.

Nested Classes [hide private]
  UnitClass
A single term in the xliff file.
Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
Constructs a blank TranslationStore.
source code
 
addheader(self)
Initialise the file header.
source code
 
createfilenode(self, filename, sourcelanguage=None, targetlanguage=None, datatype='plaintext')
creates a filenode with the given filename.
source code
 
getfilename(self, filenode)
returns the name of the given file
source code
 
getfilenames(self)
returns all filenames in this XLIFF file
source code
 
getfilenode(self, filename)
finds the filenode with the given name
source code
 
getdatatype(self, filename=None)
Returns the datatype of the stored file.
source code
 
getdate(self, filename=None)
Returns the date attribute for the file.
source code
 
removedefaultfile(self)
We want to remove the default file-tag as soon as possible if we know if still present and empty.
source code
 
getheadernode(self, filenode, createifmissing=False)
finds the header node for the given filenode
source code
 
getbodynode(self, filenode, createifmissing=False)
finds the body node for the given filenode
source code
TranslationUnit
addsourceunit(self, source, filename='NoName', createifmissing=False)
adds the given trans-unit to the last used body node if the filename has changed it uses the slow method instead (will create the nodes required if asked).
source code
 
switchfile(self, filename, createifmissing=False)
adds the given trans-unit (will create the nodes required if asked).
source code
 
creategroup(self, filename='NoName', createifmissing=False, restype=None)
adds a group tag into the specified file
source code
 
__str__(self)
Converts to a string containing the file's XML
source code

Inherited from lisa.LISAfile: addunit, initbody, namespaced, parse, setsourcelanguage, settargetlanguage

Inherited from base.TranslationStore: findunit, getunits, isempty, makeindex, save, savefile, translate, unit_iter

Inherited from base.TranslationStore (private): _assignname

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

Class Methods [hide private]
 
parsestring(cls, storestring)
Parses the string to return the correct file object

Inherited from base.TranslationStore: parsefile

Class Variables [hide private]
  Name = 'XLIFF file'
  Mimetypes = ['application/x-xliff', 'application/x-xliff+xml']
  Extensions = ['xlf', 'xliff']
  rootNode = 'xliff'
  bodyNode = 'body'
  XMLskeleton = '<?xml version="1.0" ?>\n<xliff version=\'1.1\' ...
  namespace = 'urn:oasis:names:tc:xliff:document:1.1'
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 

Constructs a blank TranslationStore.

Overrides: object.__init__
(inherited documentation)

addheader(self)

source code 

Initialise the file header.

Overrides: lisa.LISAfile.addheader

createfilenode(self, filename, sourcelanguage=None, targetlanguage=None, datatype='plaintext')

source code 

creates a filenode with the given filename. All parameters are needed for XLIFF compliance.

getdatatype(self, filename=None)

source code 

Returns the datatype of the stored file. If no filename is given, the datatype of the first file is given.

getdate(self, filename=None)

source code 

Returns the date attribute for the file. If no filename is given, the date of the first file is given. If the date attribute is not specified, None is returned.

addsourceunit(self, source, filename='NoName', createifmissing=False)

source code 

adds the given trans-unit to the last used body node if the filename has changed it uses the slow method instead (will create the nodes required if asked). Returns success

Returns: TranslationUnit
Overrides: base.TranslationStore.addsourceunit

switchfile(self, filename, createifmissing=False)

source code 

adds the given trans-unit (will create the nodes required if asked). Returns success

__str__(self)
(Informal representation operator)

source code 

Converts to a string containing the file's XML

Overrides: object.__str__
(inherited documentation)

parsestring(cls, storestring)
Class Method

 

Parses the string to return the correct file object

Overrides: base.TranslationStore.parsestring

Class Variable Details [hide private]

XMLskeleton

Value:
'''<?xml version="1.0" ?>
<xliff version=\'1.1\' xmlns=\'urn:oasis:names:tc:xliff:document:1.1\'\
>
<file original=\'NoName\' source-language=\'en\' datatype=\'plaintext\\
'>
<body>
</body>
</file>
...