Module pylupdate
[hide private]
[frames] | no frames]

Module pylupdate

source code


pylupdate parses python files to search for calls to pytson.tr resp
pytson.Translatable._tr to generate a Qt linguist translation file

These are the two valid usecases from module pytson:

class Translatable(object):
    @classmethod
    def _tr(cls, sourcetext, *, disambiguation="", n=-1, context=None):
        pass

def tr(context, sourcetext, *, disambiguation="", n=-1):
        pass

Classes [hide private]
  Message
Wrapper for a translated message
  Context
Wrapper for a translation context
  Translation
Wrapper for a Qt linguist translation file
  ParentVisitor
ast Visitor which sets links to the parent node
  FunctionValidator
ast Visitor to find calls to pyTSon's translation functions
Functions [hide private]
ElementTree.Element
_findallRecursive(node, path)
Finds all matching subelements, by tag name or path, searches recursively
source code
list[tuple(str, Message)]
_getUiTexts(inputfile)
Extracts all translatable string properties from a Qt ui file
source code
list[tuple(str, Message)]
getSourceTexts(inputfile)
Extracts all translate function info from a python source file or Qt ui file
source code
 
main(argv)
Main function of pylupdate
source code
Variables [hide private]
  DTD = r"""<...
Function Details [hide private]

_findallRecursive(node, path)

source code 

Finds all matching subelements, by tag name or path, searches recursively

Parameters:
  • node (ElementTree.Element) - the xml element to search in
  • path (str) - what element to look for
Returns: ElementTree.Element
yields each matching element

_getUiTexts(inputfile)

source code 

Extracts all translatable string properties from a Qt ui file

Parameters:
  • inputfile (str) - path to the ui file
Returns: list[tuple(str, Message)]
a list of tuples, containing the contextname and the message

getSourceTexts(inputfile)

source code 

Extracts all translate function info from a python source file or Qt ui file

Parameters:
  • inputfile (str) - path to the python source file/ui file
Returns: list[tuple(str, Message)]
a list of tuples, containing the contextname and the message

main(argv)

source code 

Main function of pylupdate

Parameters:
  • argv (list[str]) - the arguments passed to the scripts

Variables Details [hide private]

DTD

Value:
r"""<!--
 !
 ! Some notes to the DTD:
 !
 ! The location element is set as optional since it was introduced fir\
st in
 ! Qt 4.2.
 ! The userdata element is set as optional since it was introduced fir\
...