Ejemplo n.º 1
0
def main():
    if len(sys.argv) < 3:
        print('You have to specify the product and the new text for domain.')
        sys.exit(1)

    product = getLongProductName(sys.argv[1])
    domain = sys.argv[2]

    os.chdir('..')
    os.chdir('i18n')

    poFiles = getPoFiles(product, all=True)
    if poFiles == []:
        print('No po-files were found for the given product.')
        sys.exit(2)

    for poFile in poFiles:
        try:
            po_ctl = catalog.MessageCatalog(filename=poFile)
        except IOError as e:
            print('I/O Error: %s' % e, file=sys.stderr)
        po_ctl.mime_header['Domain'] = domain
        file = open(poFile, 'w')
        writer = catalog.POWriter(file, po_ctl)
        writer.write(sort=False)
Ejemplo n.º 2
0
def main():
    if len(sys.argv) == 1:
        print 'You have to specify a product or a language code.'
        sys.exit(1)

    product = getLongProductName(sys.argv[1])
    pot = '%s.pot' % product

    os.chdir('..')
    os.chdir('i18n')

    if not os.path.isfile(pot): # no pot? test for language-code
        poFiles = getPoFilesByLanguageCode(product)
        if poFiles:
            potFiles = getPotFiles()
            for po in poFiles:
                for pot in potFiles:
                    if getProduct(po) == getProduct(pot):
                        os.system(__I18NDUDE + (' sync --pot %s %s') % (pot, po))
        else:
            print 'Neither a pot nor po files for the given argument were found.'
            sys.exit(3)

    else: # product was given
        poFiles = getPoFilesAsCmdLine(product)
        if poFiles == []:
            print 'No po-files were found for the given product.'
            sys.exit(4)

        os.system(__I18NDUDE + (' sync --pot %s %s') % (pot, poFiles))
Ejemplo n.º 3
0
def main():
    if len(sys.argv) < 2:
        print 'You have to specify the product.'
        sys.exit(1)

    product = getLongProductName(sys.argv[1])

    os.chdir('..')
    os.chdir('i18n')

    poFiles = getPoFiles(product, all=True)
    if poFiles == []:
        print 'No po-files were found for the given product.'
        sys.exit(2)

    for poFile in poFiles:
        try:
            po_ctl = catalog.MessageCatalog(filename=poFile)
        except IOError, e:
            print >> sys.stderr, 'I/O Error: %s' % e

        try:
            language = po_ctl.commentary_header[0].split('to ')[1:][0]
            po_ctl.commentary_header[0] = 'Translation of '+product+'.pot to '+language
        except IndexError:
            print poFile

        file = open(poFile+'-new', 'w')
        writer = catalog.POWriter(file, po_ctl)
        writer.write(sort=False)
Ejemplo n.º 4
0
def main():
    if len(sys.argv) < 3:
        print 'You have to specify the product and the new text for projectid.'
        sys.exit(1)

    product = getLongProductName(sys.argv[1])
    projectid = sys.argv[2]

    os.chdir('..')
    os.chdir('i18n')

    poFiles = getPoFiles(product, all=True)
    if poFiles == []:
        print 'No po-files were found for the given product.'
        sys.exit(2)

    for poFile in poFiles:
        try:
            po_ctl = catalog.MessageCatalog(filename=poFile)
        except IOError, e:
            print >> sys.stderr, 'I/O Error: %s' % e
        po_ctl.mime_header['Project-Id-Version'] = projectid
        file = open(poFile, 'w')
        writer = catalog.POWriter(file, po_ctl)
        writer.write(sort=False)
Ejemplo n.º 5
0
def main():
    if len(sys.argv) < 3:
        print 'You have to specify the product and the new text for projectid.'
        sys.exit(1)

    product = getLongProductName(sys.argv[1])
    projectid = sys.argv[2]

    os.chdir('..')
    os.chdir('i18n')

    poFiles = getPoFiles(product, all=True)
    if poFiles == []:
        print 'No po-files were found for the given product.'
        sys.exit(2)

    for poFile in poFiles:
        try:
            po_ctl = catalog.MessageCatalog(filename=poFile)
        except IOError, e:
            print >> sys.stderr, 'I/O Error: %s' % e
        po_ctl.mime_header['Project-Id-Version'] = projectid
        file = open(poFile, 'w')
        writer = catalog.POWriter(file, po_ctl)
        writer.write(sort=False)
Ejemplo n.º 6
0
def main():
    if len(sys.argv) < 3:
        print('You have to specify the product and the new text for domain.')
        sys.exit(1)

    product = getLongProductName(sys.argv[1])
    domain = sys.argv[2]

    os.chdir('..')
    os.chdir('i18n')

    poFiles = getPoFiles(product, all=True)
    if poFiles == []:
        print('No po-files were found for the given product.')
        sys.exit(2)

    for poFile in poFiles:
        try:
            po_ctl = catalog.MessageCatalog(filename=poFile)
        except IOError as e:
            print('I/O Error: %s' % e, file=sys.stderr)
        po_ctl.mime_header['Domain'] = domain
        file = open(poFile, 'w')
        writer = catalog.POWriter(file, po_ctl)
        writer.write(sort=False)
Ejemplo n.º 7
0
def main():
    if len(sys.argv) == 1:
        print 'You have to specify a product or a language code.'
        sys.exit(1)

    product = getLongProductName(sys.argv[1])
    pot = '%s.pot' % product

    os.chdir('..')
    os.chdir('i18n')

    if not os.path.isfile(pot):  # no pot? test for language-code
        poFiles = getPoFilesByLanguageCode(product)
        if poFiles:
            potFiles = getPotFiles()
            for po in poFiles:
                for pot in potFiles:
                    if getProduct(po) == getProduct(pot):
                        os.system(__I18NDUDE + (' sync --pot %s %s') %
                                  (pot, po))
        else:
            print 'Neither a pot nor po files for the given argument were found.'
            sys.exit(3)

    else:  # product was given
        poFiles = getPoFilesAsCmdLine(product)
        if poFiles == []:
            print 'No po-files were found for the given product.'
            sys.exit(4)

        os.system(__I18NDUDE + (' sync --pot %s %s') % (pot, poFiles))
Ejemplo n.º 8
0
def main():
    if len(sys.argv) < 2:
        print('You have to specify the product.')
        sys.exit(1)

    product = getLongProductName(sys.argv[1])

    os.chdir('..')
    os.chdir('i18n')

    poFiles = getPoFiles(product, all=True)
    if poFiles == []:
        print('No po-files were found for the given product.')
        sys.exit(2)

    for poFile in poFiles:
        try:
            po_ctl = catalog.MessageCatalog(filename=poFile)
        except IOError as e:
            print('I/O Error: %s' % e, file=sys.stderr)

        try:
            language = po_ctl.commentary_header[0].split('to ')[1:][0]
            po_ctl.commentary_header[
                0] = 'Translation of ' + product + '.pot to ' + language
        except IndexError:
            print(poFile)

        file = open(poFile + '-new', 'w')
        writer = catalog.POWriter(file, po_ctl)
        writer.write(sort=False)
Ejemplo n.º 9
0
def main():
    option = 'all'
    if len(sys.argv) > 1:
        option = sys.argv[1]

    os.chdir('..')
    os.chdir('i18n')

    products = None
    if option == 'all':
        products = [getProduct(p) for p in getPotFiles()]
    elif option in list(PRODUCTS.keys()):
        products = (getLongProductName(option), )

    if products:
        os.system(__I18NDUDE + (' list --products %s') % (' '.join(products)))
Ejemplo n.º 10
0
def main():
    option = 'all'
    if len(sys.argv) > 1:
        option = sys.argv[1]

    os.chdir('..')
    os.chdir('i18n')

    products = None
    if option == 'all':
        products = [getProduct(p) for p in getPotFiles()]
    elif option in list(PRODUCTS.keys()):
        products = (getLongProductName(option), )

    if products:
        os.system(__I18NDUDE + (' list -t --products %s') % (' '.join(products)))
Ejemplo n.º 11
0
Archivo: chart.py Proyecto: dtgit/dtedu
def main():
    option = 'all'
    if len(sys.argv) > 1:
        option = sys.argv[1]

    os.chdir('..')
    os.chdir('i18n')

    products = None
    if option == 'all':
        products = [getProduct(p) for p in getPotFiles()]
    elif option in PRODUCTS.keys():
        products = (getLongProductName(option), )

    if products:
        os.system(__I18NDUDE + (' combinedchart -o plone.gif --title "Plone 3.0" --products %s') % (' '.join(products)))
Ejemplo n.º 12
0
def main():
    option = "all"
    if len(sys.argv) > 1:
        option = sys.argv[1]

    os.chdir("..")
    os.chdir("i18n")

    products = None
    if option == "all":
        products = [getProduct(p) for p in getPotFiles()]
    elif option in PRODUCTS.keys():
        products = (getLongProductName(option),)

    if products:
        os.system(__I18NDUDE + (" list -t --products %s") % (" ".join(products)))
Ejemplo n.º 13
0
def main():
    if len(sys.argv) == 1:
        print 'You have to specify the product.'
        sys.exit(1)

    product = getLongProductName(sys.argv[1])
    pot = '%s.pot' % product
    chart = os.curdir + os.sep + 'charts' + os.sep + '%s-chart.gif' % product

    os.chdir('..')

    if not os.path.isfile(pot):
        print 'No pot was found for the given product.'
        sys.exit(2)

    poFiles = getPoFilesAsCmdLine(product)
    if poFiles == '':
        print 'No po-files were found for the given product.'
        sys.exit(3)

    os.system(__PYTHON + ' ' + __I18NDUDE + (' chart -o %s --pot %s %s') % (chart, pot, poFiles))
Ejemplo n.º 14
0
def main():
    if len(sys.argv) == 1:
        print 'You have to specify the product.'
        sys.exit(1)

    product = getLongProductName(sys.argv[1])
    pot = '%s.pot' % product
    chart = os.curdir + os.sep + 'charts' + os.sep + '%s-chart.gif' % product

    os.chdir('..')

    if not os.path.isfile(pot):
        print 'No pot was found for the given product.'
        sys.exit(2)

    poFiles = getPoFilesAsCmdLine(product)
    if poFiles == '':
        print 'No po-files were found for the given product.'
        sys.exit(3)

    os.system(__PYTHON + ' ' + __I18NDUDE + (' chart -o %s --pot %s %s') %
              (chart, pot, poFiles))
Ejemplo n.º 15
0
def rebuild(product, folder=''):
    product = getLongProductName(product)

    pot = product + '.pot'
    manualpot = '%s-manual.pot' % product
    generatedpot = '%s-generated.pot' % product
    if '/' in product:
        product = product.split('/')[1]

    log = 'rebuild-%s-pot.log' % product
    domain = product

    os.chdir('..')
    os.chdir('i18n')

    if not os.path.isfile(manualpot):
        print 'Manual pot missing for the given product: %s.' % manualpot
        sys.exit(3)

    folder2 = ''
    if product == 'plone':
        packages = (
            'archetypes.kss',
            'plone.contentrules',
            'plone.fieldsets',
            'plone.i18n',
            'plone.locking',
            'plone.memoize',
            'plone.openid',
            'plone.portlets',
            'plone.portlet.collection',
            'plone.portlet.static',
            'plone.session',
            'plone.intelligenttext',
            'plone.app.contentmenu',
            'plone.app.content',
            'plone.app.contentrules',
            'plone.app.controlpanel',
            'plone.app.customerize',
            'plone.app.form',
            'plone.app.i18n',
            'plone.app.imaging',
            'plone.app.iterate',
            'plone.app.kss',
            'plone.app.layout',
            'plone.app.linkintegrity',
            'plone.app.portlets',
            'plone.app.redirector',
            'plone.app.users',
            'plone.app.viewletmanager',
            'plone.app.vocabularies',
            'plone.app.workflow',
            'plone.app.openid',
            'plonetheme.sunburst',
            'plonetheme.classic',
            'Products.Archetypes',
            'Products.CMFDiffTool',
            'Products.validation',
        )
        add_products = (
            'Archetypes',
            'CMFDiffTool',
        )

        src = os.path.join(__INSTANCE_HOME, 'src')
        for package in packages:
            p = os.path.join(src, package)
            if os.path.isdir(p):
                folder2 += ' %s' % p
        src = os.path.join(__INSTANCE_HOME, 'products')
        for prod in add_products:
            p = os.path.join(src, prod)
            if os.path.isdir(p):
                folder2 += ' %s' % p

    foldererror = False
    if not os.path.isdir(folder) and folder == '':
        folder = os.path.join(__INSTANCE_HOME, 'Products')
        if os.path.isdir(folder):
            folder = os.path.join(folder, getProductPath(product))
            if not os.path.isdir(folder):
                # Try the src folder instead
                base = os.path.basename(folder)
                src = os.path.join(__INSTANCE_HOME, 'src')
                package = os.path.join(src, 'Products.%s' % base)
                if os.path.isdir(package):
                    folder = package
                else:
                    foldererror = True
        else:
            foldererror = True
    else:
        foldererror = True

    if foldererror:
        print 'Directory (%s) could not be found.' % folder
        sys.exit(4)

    # Remove the original file
    if os.path.isfile(pot):
        os.remove(pot)

    print 'Using %s to build new pot.\n' % folder
    cmd = __I18NDUDE + (' rebuild-pot --pot %s --create %s --merge %s ') % (pot, domain, manualpot)
    if product == 'plone':
        cmd += '--merge2 %s ' % generatedpot
    if product == 'plone':
        ignores = ('rss_template.pt',
                   'metadata_edit_form.cpt',
                   'metadirectives.py',
                   'Discussion_Item.xml',
                  )
        cmd += '--exclude="%s" ' % ' '.join(ignores)
    if product.startswith('kupu'):
        ignores = ('mmbase',
                   'widgeteer',
                   'kupu_kjax_support.xml.pt',
                   'kupu_migration.xml.pt',
                  )
        cmd += '--exclude="%s" ' % ' '.join(ignores)
    if product == 'plone':
        cmd += '%s %s > %s 2>&1' % (folder, folder2, log)
        # For debugging
        # cmd += '%s %s' % (folder, folder2)
    else:
        cmd += '%s > %s 2>&1' % (folder, log)
    print 'Rebuilding to %s - this takes a while, logging to %s' % (pot, log)
    os.system(cmd)
Ejemplo n.º 16
0
def main():
    if len(sys.argv) < 3:
        print 'You have to specify the product und skins directory.'
        sys.exit(1)

    product = sys.argv[1]

    product = getLongProductName(product)

    pot = product + '.pot-new'
    manualpot = '%s-manual.pot' % product
    generatedpot = '%s-generated.pot' % product
    log = 'rebuild-%s-pot.log' % product

    domain = product

    os.chdir('..')

    if not os.path.isfile(manualpot):
        print 'Manual pot missing for the given product: %s.' % manualpot
        sys.exit(2)

    skins = sys.argv[2]

    skinserror = False
    if not os.path.isdir(skins):
        if skins == '-i':
            skins = os.path.join(__INSTANCE_HOME, 'Products')
            if os.path.isdir(skins):
                if product == 'plonesoftwarecenter':
                    skins = os.path.join(skins, 'PloneSoftwareCenter')
                elif product == 'plone':
                    skins = os.path.join(skins, 'PloneSoftwareCenter')
                skins = os.path.join(skins, 'skins')
            else:
                skinserror = True
        else:
            skinserror = True

    if skinserror:
        print 'Skins directory (%s) could not be found.' % skins
        sys.exit(3)

    print 'Using %s to build new pot.\n' % skins

    cmd = __PYTHON + ' ' + __I18NDUDE + (' rebuild-pot --pot %s --create %s --merge %s ') % (pot, domain, manualpot)
    cmd += '%s > %s 2>&1' % (skins, log)

    print 'Rebuilding to %s - this takes a while, logging to %s' % (pot, log)
    os.system(cmd)

    # Remove ## X more: occurences
    os.system('sed -r "/## [0-9]+ more:/d" %s > %s2' % (pot, pot))

    # Make paths relative to products skins dir
    step3 = pot
    if WIN32:
        step3 = step3 + '3'
    os.system('sed -r "s,%s,\.,g" %s2 > %s' % (string.replace(skins, '\\', '\\\\'), pot, step3))
    os.remove('%s2' % pot)

    if WIN32:
        # Make directory separator unix like
        os.system('sed -r "/^#:.*/s,\\\\,/,g" %s3 > %s' % (pot, pot))
        os.remove('%s3' % pot)
Ejemplo n.º 17
0
def main():
    if len(sys.argv) < 3:
        print 'You have to specify the product und skins directory.'
        sys.exit(1)

    product = sys.argv[1]

    product = getLongProductName(product)

    pot = product + '.pot-new'
    manualpot = '%s-manual.pot' % product
    generatedpot = '%s-generated.pot' % product
    log = 'rebuild-%s-pot.log' % product

    domain = product

    os.chdir('..')

    if not os.path.isfile(manualpot):
        print 'Manual pot missing for the given product: %s.' % manualpot
        sys.exit(2)

    skins = sys.argv[2]

    skinserror = False
    if not os.path.isdir(skins):
        if skins == '-i':
            skins = os.path.join(__INSTANCE_HOME, 'Products')
            if os.path.isdir(skins):
                if product == 'plonehelpcenter':
                    skins = os.path.join(skins, 'PloneHelpCenter')
                elif product == 'plone':
                    skins = os.path.join(skins, 'PloneHelpCenter')
                skins = os.path.join(skins, 'skins')
            else:
                skinserror = True
        else:
            skinserror = True

    if skinserror:
        print 'Skins directory (%s) could not be found.' % skins
        sys.exit(3)

    print 'Using %s to build new pot.\n' % skins

    cmd = __PYTHON + ' ' + __I18NDUDE + (
        ' rebuild-pot --pot %s --create %s --merge %s ') % (pot, domain,
                                                            manualpot)
    cmd += '%s > %s 2>&1' % (skins, log)

    print 'Rebuilding to %s - this takes a while, logging to %s' % (pot, log)
    os.system(cmd)

    # Remove ## X more: occurences
    os.system('sed -r "/## [0-9]+ more:/d" %s > %s2' % (pot, pot))

    # Make paths relative to products skins dir
    step3 = pot
    if WIN32:
        step3 = step3 + '3'
    os.system('sed -r "s,%s,\.,g" %s2 > %s' %
              (string.replace(skins, '\\', '\\\\'), pot, step3))
    os.remove('%s2' % pot)

    if WIN32:
        # Make directory separator unix like
        os.system('sed -r "/^#:.*/s,\\\\,/,g" %s3 > %s' % (pot, pot))
        os.remove('%s3' % pot)
Ejemplo n.º 18
0
def rebuild(product, folder=''):
    product = getLongProductName(product)

    pot = product + '.pot'
    manualpot = '%s-manual.pot' % product
    generatedpot = '%s-generated.pot' % product
    log = 'rebuild-%s-pot.log' % product

    domain = product

    os.chdir('..')
    os.chdir('i18n')

    if not os.path.isfile(manualpot):
        print 'Manual pot missing for the given product: %s.' % manualpot
        sys.exit(3)

    folder2 = ''
    if product == 'plone':
        packages = (
            'archetypes.kss',
            'plone.contentrules',
            'plone.fieldsets',
            'plone.i18n',
            'plone.locking',
            'plone.memoize',
            'plone.openid',
            'plone.portlets',
            'plone.session',
            'plone.intelligenttext',
            'plone.app.contentmenu',
            'plone.app.content',
            'plone.app.contentrules',
            'plone.app.controlpanel',
            'plone.app.customerize',
            'plone.app.form',
            'plone.app.i18n',
            'plone.app.iterate',
            'plone.app.kss',
            'plone.app.layout',
            'plone.app.linkintegrity',
            'plone.app.portlets',
            'plone.app.redirector',
            'plone.app.viewletmanager',
            'plone.app.vocabularies',
            'plone.app.workflow',
            'plone.app.openid',
        )
        add_products = (
            'Archetypes',
            'CMFDiffTool',
        )

        src = os.path.join(__INSTANCE_HOME, 'src')
        for package in packages:
            folder2 += ' %s' % os.path.join(src, package)
        src = os.path.join(__INSTANCE_HOME, 'products')
        for p in add_products:
            folder2 += ' %s' % os.path.join(src, p)

    foldererror = False
    if not os.path.isdir(folder):
        if folder == '':
            folder = os.path.join(__INSTANCE_HOME, 'Products')
            if os.path.isdir(folder):
                folder = os.path.join(folder, getProductPath(product))
            else:
                foldererror = True
        else:
            foldererror = True

    if foldererror:
        print 'Product directory (%s) could not be found.' % folder
        sys.exit(4)

    # Remove the original file
    if os.path.isfile(pot):
        os.remove(pot)

    print 'Using %s to build new pot.\n' % folder
    cmd = __I18NDUDE + (' rebuild-pot --pot %s2 --create %s --merge %s ') % (pot, domain, manualpot)
    if product == 'plone':
        cmd += '--merge2 %s ' % generatedpot
    if product == 'plone':
        ignores = ('rss_template.pt',
                   'metadata_edit_form.cpt',
                   'metadirectives.py',
                   'Discussion_Item.xml',
                  )
        cmd += '--exclude="%s" ' % ' '.join(ignores)
    if product == 'plone':
        cmd += '%s %s > %s 2>&1' % (folder, folder2, log)
        # For debugging
        # cmd += '%s %s' % (folder, folder2)
    else:
        cmd += '%s > %s 2>&1' % (folder, log)
    print 'Rebuilding to %s - this takes a while, logging to %s' % (pot, log)
    os.system(cmd)

    step2 = pot
    if WIN32:
        step2 = pot + '3'

    # Make paths relative to products skins dir
    os.system('sed "s,%s,\.,g" %s2 > %s' % (string.replace(folder, '\\', '\\\\'), pot, step2))
    os.remove('%s2' % pot)

    if WIN32:
        # Make directory separator unix like
        os.system('sed "/^#:.*/s,\\\\,/,g" %s3 > %s' % (pot, pot))
        os.remove('%s3' % pot)