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

# Class xlifffile

source code

Class representing a XLIFF file store.

Nested Classes | [hide private]
| UnitClass The class of units that will be instantiated and used by this class

Instance Methods | [hide private]
__init__(self, *args, **kwargs) Constructs a blank TranslationStore. | source code
initbody(self) Initialises self.body so it never needs to be retrieved from the XML again. | 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
setfilename(self, filenode, filename) set 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`, `namespaced`, `parse` Inherited from `base.TranslationStore`: `__getstate__`, `__setstate__`, `add_unit_to_index`, `findid`, `findunit`, `findunits`, `getsourcelanguage`, `gettargetlanguage`, `getunits`, `isempty`, `makeindex`, `remove_unit_from_index`, `require_index`, `save`, `savefile`, `setsourcelanguage`, `settargetlanguage`, `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 | source code
Inherited from `base.TranslationStore`: `parsefile`

Class Variables | [hide private]
| Name = `_("XLIFF Translation File")` The human usable name of this store type
| Mimetypes = `["application/x-xliff", "application/x-xliff+xml"]` A list of MIME types associated with this store type
| Extensions = `["xlf", "xliff"]` A list of file extentions associated with this store type
| rootNode = `"xliff"`
| bodyNode = `"body"`
| XMLskeleton = `'''<?xml version="1.0"`...``
| namespace = `'urn:oasis:names:tc:xliff:document:1.1'` Parse an instance of this class from the start of the given string.
| suggestions_in_format = `True` xliff units have alttrans tags which can be used to store suggestions
Inherited from `base.TranslationStore` (private): `_binary`

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)

### initbody(self) | source code
Initialises self.body so it never needs to be retrieved from the XML again. Overrides: lisa.LISAfile.initbody (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 | source code
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>
      </xliff>'''