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]

Classes [hide private]
  StringElem
This class represents a sub-tree of a string parsed into a rich structure.
  Bpt
  Bx
  Ept
  Ex
  G
  It
  Ph
  Sub
  X
Functions [hide private]
 
parse(tree, parse_funcs)
Parse placeables from the given string or sub-tree by using the parsing functions provided.
source code
 
to_base_placeables(tree) 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 StringElems 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',
...