Package translate :: Package storage :: Package placeables |
[hide private]
[frames] | no frames]

# Package placeables

source code

This module implements basic functionality to support placeables.

A placeable is used to represent things like:

1. Substitutions

   For example, in ODF, footnotes appear in the ODF XML where they are defined; so if we extract a paragraph with some footnotes, the translator will have a lot of additional XML to with; so we separate the footnotes out into separate translation units and mark their positions in the original text with placeables.

2. Hiding of inline formatting data

   The translator doesn't want to have to deal with all the weird formatting conventions of wherever the text came from.

3. Marking variables

   This is an old issue - translators translate variable names which should remain untranslated. We can wrap placeables around variable names to avoid this.

The placeables model follows the XLIFF standard's list of placeables. Please refer to the XLIFF specification to get a better understanding.

Submodules | [hide private]
translate.storage.placeables.base: Contains base placeable classes with names based on XLIFF placeables. translate.storage.placeables.general: Contains general placeable implementations. translate.storage.placeables.interfaces: This file contains abstract (semantic) interfaces for placeable implementations. translate.storage.placeables.lisa translate.storage.placeables.parse translate.storage.placeables.parse': Contains the `parse` function that parses normal strings into StringElem- based "rich" string element trees. translate.storage.placeables.strelem: Contains the base StringElem class that represents a node in a parsed rich- string tree. translate.storage.placeables.terminology: Contains the placeable that represents a terminology term. translate.storage.placeables.xliff: Contains XLIFF-specific placeables.

Classes | [hide private]
| Sub
| G
| Ept
| It
| Ex
| X
| Ph
| Bx
| Bpt
| StringElem This class represents a sub-tree of a string parsed into a rich structure.

Functions | [hide private]
to_base_placeables(tree) | source code
parse(tree, parse_funcs) Parse placeables from the given string or sub-tree by using the parsing functions provided. | source code

Variables | [hide private]
| all_your_base = ``[``'``Bpt``'``,` `'``Ept``'``,` `'``Ph``'``,` `'``It``'``,` `'``G``'``,` `'``Bx``'``,` `'``Ex``'``,` `'``X``...``

Imports: lisa, strelem

Function Details | [hide private]

### parse(tree, parse_funcs) | source code
Parse placeables from the given string or sub-tree by using the parsing functions provided. The output of this function is heavily dependent on the order of the parsing functions. This is because of the algorithm used. An over-simplification of the algorithm: the leaves in the `StringElem` tree are expanded to the output of the first parsing function in `parse_funcs`. The next level of recursion is then started on the new set of leaves with the used parsing function removed from `parse_funcs`. Parameters: `tree` (unicode|StringElem) - The string or string element sub-tree to parse. `parse_funcs` (A list of parsing functions. It must take exactly one argument (a `unicode` string to parse) and return a list of `StringElem`s which, together, form the original string. If nothing could be parsed, it should return `None`.)

Variables Details | [hide private]

  ### all_your_base Value:
      ['Bpt',
       'Ept',
       'Ph',
       'It',
       'G',
       'Bx',
       'Ex',
       'X',
      ...