Ejemplo n.º 1
0
 def php2po(self, phpsource, phptemplate=None):
     """helper that converts .php source to po source without requiring files"""
     inputfile = wStringIO.StringIO(phpsource)
     inputphp = php.phpfile(inputfile)
     convertor = php2po.php2po()
     if phptemplate:
         templatefile = wStringIO.StringIO(phptemplate)
         templatephp = php.phpfile(templatefile)
         outputpo = convertor.mergestore(templatephp, inputphp)
     else:
         outputpo = convertor.convertstore(inputphp)
     return outputpo
Ejemplo n.º 2
0
 def php2po(self, phpsource, phptemplate=None):
     """helper that converts .phperties source to po source without requiring files"""
     inputfile = wStringIO.StringIO(phpsource)
     inputphp = php.phpfile(inputfile)
     convertor = php2po.php2po()
     if phptemplate:
         templatefile = wStringIO.StringIO(phptemplate)
         templatephp = php.phpfile(templatefile)
         outputpo = convertor.mergestore(templatephp, inputphp)
     else:
         outputpo = convertor.convertstore(inputphp)
     return outputpo
Ejemplo n.º 3
0
def convertphp(inputfile, outputfile, templatefile, pot=False, duplicatestyle="msgctxt"):
    """reads in inputfile using php, converts using php2po, writes to outputfile"""
    inputstore = php.phpfile(inputfile)
    convertor = php2po()
    if templatefile is None:
        outputstore = convertor.convertstore(inputstore, duplicatestyle=duplicatestyle)
    else:
        templatestore = php.phpfile(templatefile)
        outputstore = convertor.mergestore(templatestore, inputstore, blankmsgstr=pot, duplicatestyle=duplicatestyle)
    if outputstore.isempty():
        return 0
    outputfile.write(str(outputstore))
    return 1
Ejemplo n.º 4
0
def convertphp(inputfile, outputfile, templatefile, pot=False,
               duplicatestyle="msgctxt"):
    """Read inputfile using php, convert using php2po, write to outputfile."""
    inputstore = php.phpfile(inputfile)
    convertor = php2po()
    if templatefile is None:
        outputstore = convertor.convertstore(inputstore,
                                             duplicatestyle=duplicatestyle)
    else:
        templatestore = php.phpfile(templatefile)
        outputstore = convertor.mergestore(templatestore, inputstore,
                                           blankmsgstr=pot,
                                           duplicatestyle=duplicatestyle)
    if outputstore.isempty():
        return 0
    outputstore.serialize(outputfile)
    return 1
Ejemplo n.º 5
0
 def __init__(self, templatefile, inputstore):
     self.outputstore = php.phpfile(templatefile)
     self.inputstore = inputstore
     self.inmultilinemsgid = False
     self.inecho = False
     self.inarray = False
     self.equaldel = "="
     self.enddel = ";"
     self.prename = ""
     self.quotechar = ""
Ejemplo n.º 6
0
 def phpparse(self, phpsource):
     """helper that parses php source without requiring files"""
     dummyfile = BytesIO(phpsource.encode())
     return php.phpfile(dummyfile)
Ejemplo n.º 7
0
 def phpparse(self, phpsource):
     """helper that parses php source without requiring files"""
     dummyfile = wStringIO.StringIO(phpsource)
     phpfile = php.phpfile(dummyfile)
     return phpfile
Ejemplo n.º 8
0
 def phpparse(self, phpsource):
     """helper that parses php source without requiring files"""
     dummyfile = wStringIO.StringIO(phpsource)
     phpfile = php.phpfile(dummyfile)
     return phpfile