Provides lexicon data level and variable name translations for log messages.
Initializes the translation by processing the schema and xml documents for the lexicon translation definitions:
>>> from simo.builder.translation.lexicontranslationtable import LexiconTransTableDef
>>> tdf = open('../../simulator/xml/schemas/Typedefs_SIMO.xsd')
>>> typedef = tdf.read()
>>> tdf.close()
>>> sf = open('../../simulator/xml/schemas/lexicon_translation_table.xsd')
>>> schema = sf.read()
>>> sf.close()
>>> xml = u'''<lexicon_translation_table
... xmlns="http://www.simo-project.org/simo"
... xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
... <level>
... <name>
... <from>comp_unit</from>
... <to>
... <lang name="fi">kuvio</lang>
... <lang name="se">nånting</lang>
... </to>
... </name>
... <variables>
... <variable>
... <name>
... <from>DEVEL_CLASS</from>
... <to>
... <lang name="fi">kehitysluokka</lang>
... </to>
... </name>
... <values>
... <value>
... <from>Open regeneration site</from>
... <to>
... <lang name="fi">aukea</lang>
... </to>
... </value>
... <value>
... <from>Young seedling stand (less than 1,3 m)</from>
... <to>
... <lang name="fi">pieni taimikko</lang>
... </to>
... </value>
... </values>
... </variable>
... <variable>
... <name>
... <from>INVENTORY_METHOD</from>
... <to>
... <lang name="fi">inventointitapa</lang>
... <lang name="se">så ska det vara</lang>
... </to>
... </name>
... <values>
... <value>
... <from>some method</from>
... <to>
... <lang name="fi">joku inventointi</lang>
... <lang name="se">ju inventering ja</lang>
... </to>
... </value>
... </values>
... </variable>
... </variables>
... </level>
... </lexicon_translation_table>'''
>>> ltd = LexiconTransTableDef(typedef)
>>> ltd.schema = schema
>>> ltd.xml = ('testxml',xml, None)
>>> ltd.xml['testxml'][:26]
u'<lexicon_translation_table'
Construct lexicon data level name and variable name translation tables from the parsed translation table xml.
Only one translation table, keyed as ‘default’ is supported.
The lexicon data level name table is a dictionary (by data level name in single quotes) of language codes yielding unicode translation strings:
>>> lt = ltd.obj['testxml']
>>> lt.level_table["'comp_unit'"]['fi']
u"'kuvio'"
The data level variable table is similar dictionary yielding unicode translation strings:
>>> lt.var_table["'DEVEL_CLASS'"]['fi']
u"'kehitysluokka'"
Lexicon translation definitions.
Attributes:
Parses the XML data into a class instance