Package translate :: Package storage :: Module ts2 :: Class tsfile

[hide private]
[frames] | no frames]

# Class tsfile

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. | source code

String

gettargetlanguage(self) Get the target language for this .ts file. | source code

settargetlanguage(self, targetlanguage) Set the target language for this .ts file to `targetlanguage`. | source code

_createcontext(self, contextname, comment=None) Creates a context node with an optional comment | source code

_getcontextname(self, contextnode) Returns the name of the given context node. | source code

_getcontextnames(self) Returns all contextnames in this TS file. | source code

_getcontextnode(self, contextname) Returns the context node with the given name. | source code

addunit(self, unit, new=True, contextname=None, createifmissing=False) Adds the given unit to the last used body node (current context). | source code

_switchcontext(self, contextname, createifmissing=False) Switch the current context to the one named contextname, optionally creating it if it doesn't exist. | source code

nplural(self) | source code

__str__(self) Converts to a string containing the file's XML. | source code

Inherited from `lisa.LISAfile`: `addheader`, `addsourceunit`, `namespaced`, `parse`

Inherited from `base.TranslationStore`: `__getstate__`, `__setstate__`, `add_unit_to_index`, `findid`, `findunit`, `findunits`, `getids`, `getsourcelanguage`, `getunits`, `isempty`, `makeindex`, `remove_unit_from_index`, `require_index`, `save`, `savefile`, `setsourcelanguage`, `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]

Inherited from `base.TranslationStore`: `parsefile`, `parsestring`

Class Variables | [hide private]

| Name = `_("Qt Linguist Translation File")` The human usable name of this store type
| Mimetypes = `["application/x-linguist"]` A list of MIME types associated with this store type
| Extensions = `["ts"]` A list of file extentions associated with this store type
| rootNode = `"TS"`
| bodyNode = `"context"`
| XMLskeleton = `'''<!DOCTYPE `...``
| namespace = `''` Parse an instance of this class from the start of the given string.
Inherited from `base.TranslationStore`: `suggestions_in_format` 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.

Overrides: lisa.LISAfile.initbody

### gettargetlanguage(self)

source code

Get the target language for this .ts file.

Returns: String
  ISO code e.g. af, fr, pt_BR
Overrides: base.TranslationStore.gettargetlanguage

### settargetlanguage(self, targetlanguage)

source code

Set the target language for this .ts file to `targetlanguage`.

Parameters:
  - `targetlanguage` (String) - ISO code e.g. af, fr, pt_BR
Overrides: base.TranslationStore.settargetlanguage

### addunit(self, unit, new=True, contextname=None, createifmissing=False)

source code

Adds the given unit to the last used body node (current context).

If the contextname is specified, switch to that context (creating it if allowed by createifmissing).

Parameters:
  - `unit` - The unit that will be added.
Overrides: base.TranslationStore.addunit

### __str__(self)
(Informal representation operator)

source code

Converts to a string containing the file's XML.

We have to override this to ensure mimic the Qt convention:

- no XML decleration
- plain DOCTYPE that lxml seems to ignore

Overrides: object.__str__

Class Variable Details | [hide private]

### XMLskeleton

Value:

      '''<!DOCTYPE TS>
      <TS>
      </TS>
      '''