Пример #1
0
def main():
    if len(sys.argv) < 3:
        print 'You have to specify the target and source product.'
        sys.exit(1)

    target = sys.argv[1]
    source = sys.argv[2]

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

    targetPoFiles = getPoFiles(target)
    sourcePoFiles = getPoFiles(source)

    if targetPoFiles == [] or sourcePoFiles == []:
        print 'No po-files were found for one of the given products.'
        sys.exit(3)

    for t in targetPoFiles:
        targetLanguage = getLanguage(target,t)
        for s in sourcePoFiles:
            sourceLanguage = getLanguage(source,s)
            if targetLanguage and sourceLanguage and targetLanguage == sourceLanguage:
                print '%s %s <- %s' % (getLanguage(target, t), t, s)
                os.system(__I18NDUDE + (' admix %s %s > %s-new') % (t, s, t))
                targetpath = os.path.join(os.curdir, t)
                os.remove(targetpath)
                if not os.path.exists(targetpath):
                    shutil.copy(t+'-new', t)
                    os.remove(targetpath+'-new')
Пример #2
0
def main():
    os.chdir('..')
    os.chdir('i18n')

    poFilesPlone = getPoFiles('plone')
    if not poFilesPlone:
        print 'No po-files were found for Plone.'
        sys.exit(2)

    poFilesATCT = getPoFiles('atcontenttypes')
    if not poFilesATCT:
        print 'No po-files were found for ATContentTypes.'
        sys.exit(3)

    # format: 'old-domain' : ['msgid1', 'msgid2', ...]
    relocated = {'plone' :
                  ['Changes saved.', 'Please correct the indicated errors.',
                   'Rotate 180', 'help_boolean_criteria_bool',
                   'help_criteria_field_name', 'help_custom_view',
                   'help_custom_view_fields', 'help_date_range_criteria_end',
                   'help_date_range_criteria_start', 'help_exclude_from_nav',
                   'help_limit_number', 'help_news_image', 'help_shortname',
                   'help_path_criteria_value', 'help_string_criteria_value',
                   'help_portal_type_criteria_value', 'help_url',
                   'label_body_text', 'label_boolean_criteria_bool',
                   'label_contact_email', 'label_contact_name',
                   'label_contact_phone', 'label_criteria_field_name',
                   'label_custom_view', 'label_custom_view_fields',
                   'label_date_range_criteria_end', 'label_event_announcement',
                   'label_date_range_criteria_start', 'label_event_attendees',
                   'label_event_end', 'label_event_location',
                   'label_event_start', 'label_event_type',
                   'label_exclude_from_nav', 'label_file', 'label_image',
                   'label_image_caption', 'label_inherit_criteria',
                   'label_item_count', 'label_limit_number', 'label_news_image',
                   'label_path_criteria_recurse', 'label_path_criteria_value',
                   'label_related_items', 'label_short_name',
                   'label_string_criteria_value', 'label_url',
                  ]
                }

    # make sure we only try on languages for which both po files exist
    ploneLanguages = [getLanguage('plone', p) for p in poFilesPlone]
    atctLanguages = [getLanguage('atcontenttypes', p) for p in poFilesATCT]

    languages = [l for l in ploneLanguages if l in atctLanguages and l != 'en']
    changes = {'plone' : False, 'atcontenttypes' : False}

    for lang in languages:
        po_ctl = {}
        try:
            po_ctl['plone'] = catalog.MessageCatalog(filename='plone-%s.po' % lang)
        except IOError, e:
            print >> sys.stderr, 'I/O Error: %s' % e
        try:
            po_ctl['atcontenttypes'] = catalog.MessageCatalog(filename='atcontenttypes-%s.po' % lang)
        except IOError, e:
            print >> sys.stderr, 'I/O Error: %s' % e
Пример #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)
Пример #4
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)
Пример #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)
Пример #6
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)
Пример #7
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)
Пример #8
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)
Пример #9
0
def main():
    if len(sys.argv) < 3:
        print('You have to specify the target and source product.')
        sys.exit(1)

    target = sys.argv[1]
    source = sys.argv[2]

    os.chdir('..')

    sourcePoFiles = getPoFiles(source)

    if sourcePoFiles == []:
        print('No po-files were found for the source product.')
        sys.exit(3)

    for sourcefile in sourcePoFiles:
        sourceLanguage = getLanguage(source,sourcefile)
        if sourceLanguage:
            targetfile = target + '-' + sourceLanguage + '.po'
            targetpath = os.path.join(os.curdir, targetfile)
            if not os.path.exists(targetpath):
                shutil.copy(sourcefile, targetfile)
Пример #10
0
def main():
    if len(sys.argv) < 3:
        print 'You have to specify the target and source product.'
        sys.exit(1)

    target = sys.argv[1]
    source = sys.argv[2]

    os.chdir('..')

    sourcePoFiles = getPoFiles(source)

    if sourcePoFiles == []:
        print 'No po-files were found for the source product.'
        sys.exit(3)

    for sourcefile in sourcePoFiles:
        sourceLanguage = getLanguage(source, sourcefile)
        if sourceLanguage:
            targetfile = target + '-' + sourceLanguage + '.po'
            targetpath = os.path.join(os.curdir, targetfile)
            if not os.path.exists(targetpath):
                shutil.copy(sourcefile, targetfile)
Пример #11
0
def main():
    os.chdir('..')
    os.chdir('i18n')

    poFilesPlone = getPoFiles('plone')
    if not poFilesPlone:
        print 'No po-files were found for Plone.'
        sys.exit(2)

    poFilesATCT = getPoFiles('atcontenttypes')
    if not poFilesATCT:
        print 'No po-files were found for ATContentTypes.'
        sys.exit(3)

    # format: 'old-domain' : ['msgid1', 'msgid2', ...]
    relocated = {
        'plone': [
            'Changes saved.',
            'Please correct the indicated errors.',
            'Rotate 180',
            'help_boolean_criteria_bool',
            'help_criteria_field_name',
            'help_custom_view',
            'help_custom_view_fields',
            'help_date_range_criteria_end',
            'help_date_range_criteria_start',
            'help_exclude_from_nav',
            'help_limit_number',
            'help_news_image',
            'help_shortname',
            'help_path_criteria_value',
            'help_string_criteria_value',
            'help_portal_type_criteria_value',
            'help_url',
            'label_body_text',
            'label_boolean_criteria_bool',
            'label_contact_email',
            'label_contact_name',
            'label_contact_phone',
            'label_criteria_field_name',
            'label_custom_view',
            'label_custom_view_fields',
            'label_date_range_criteria_end',
            'label_event_announcement',
            'label_date_range_criteria_start',
            'label_event_attendees',
            'label_event_end',
            'label_event_location',
            'label_event_start',
            'label_event_type',
            'label_exclude_from_nav',
            'label_file',
            'label_image',
            'label_image_caption',
            'label_inherit_criteria',
            'label_item_count',
            'label_limit_number',
            'label_news_image',
            'label_path_criteria_recurse',
            'label_path_criteria_value',
            'label_related_items',
            'label_short_name',
            'label_string_criteria_value',
            'label_url',
        ]
    }

    # make sure we only try on languages for which both po files exist
    ploneLanguages = [getLanguage('plone', p) for p in poFilesPlone]
    atctLanguages = [getLanguage('atcontenttypes', p) for p in poFilesATCT]

    languages = [l for l in ploneLanguages if l in atctLanguages and l != 'en']
    changes = {'plone': False, 'atcontenttypes': False}

    for lang in languages:
        po_ctl = {}
        try:
            po_ctl['plone'] = catalog.MessageCatalog(filename='plone-%s.po' %
                                                     lang)
        except IOError, e:
            print >> sys.stderr, 'I/O Error: %s' % e
        try:
            po_ctl['atcontenttypes'] = catalog.MessageCatalog(
                filename='atcontenttypes-%s.po' % lang)
        except IOError, e:
            print >> sys.stderr, 'I/O Error: %s' % e
Пример #12
0
def main():
    os.chdir('..')
    os.chdir('i18n')

    poFilesPlone = getPoFiles('plone')
    if not poFilesPlone:
        print('No po-files were found for Plone.')
        sys.exit(2)

    poFilesATCT = getPoFiles('atcontenttypes')
    if not poFilesATCT:
        print('No po-files were found for ATContentTypes.')
        sys.exit(3)

    # format: 'old-domain' : ['msgid1', 'msgid2', ...]
    relocated = {'plone' :
                  ['Changes saved.', 'Please correct the indicated errors.',
                   'Rotate 180', 'help_boolean_criteria_bool',
                   'help_criteria_field_name', 'help_custom_view',
                   'help_custom_view_fields', 'help_date_range_criteria_end',
                   'help_date_range_criteria_start', 'help_exclude_from_nav',
                   'help_limit_number', 'help_news_image', 'help_shortname',
                   'help_path_criteria_value', 'help_string_criteria_value',
                   'help_portal_type_criteria_value', 'help_url',
                   'label_body_text', 'label_boolean_criteria_bool',
                   'label_contact_email', 'label_contact_name',
                   'label_contact_phone', 'label_criteria_field_name',
                   'label_custom_view', 'label_custom_view_fields',
                   'label_date_range_criteria_end', 'label_event_announcement',
                   'label_date_range_criteria_start', 'label_event_attendees',
                   'label_event_end', 'label_event_location',
                   'label_event_start', 'label_event_type',
                   'label_exclude_from_nav', 'label_file', 'label_image',
                   'label_image_caption', 'label_inherit_criteria',
                   'label_item_count', 'label_limit_number', 'label_news_image',
                   'label_path_criteria_recurse', 'label_path_criteria_value',
                   'label_related_items', 'label_short_name',
                   'label_string_criteria_value', 'label_url',
                  ]
                }

    # make sure we only try on languages for which both po files exist
    ploneLanguages = [getLanguage('plone', p) for p in poFilesPlone]
    atctLanguages = [getLanguage('atcontenttypes', p) for p in poFilesATCT]

    languages = [l for l in ploneLanguages if l in atctLanguages and l != 'en']
    changes = {'plone' : False, 'atcontenttypes' : False}

    for lang in languages:
        po_ctl = {}
        try:
            po_ctl['plone'] = catalog.MessageCatalog(filename='plone-%s.po' % lang)
        except IOError as e:
            print('I/O Error: %s' % e, file=sys.stderr)
        try:
            po_ctl['atcontenttypes'] = catalog.MessageCatalog(filename='atcontenttypes-%s.po' % lang)
        except IOError as e:
            print('I/O Error: %s' % e, file=sys.stderr)

        changes = {'plone' : False, 'atcontenttypes' : False}

        relocate_domain = {'plone' : 'atcontenttypes', 'atcontenttypes' : 'plone'}

        msgids = {}
        msgids['plone'] = list(po_ctl['plone'].keys())
        msgids['atcontenttypes'] = list(po_ctl['atcontenttypes'].keys())

        for old_domain in relocated:
            relocate_msgids = relocated.get(old_domain)
            for relocate_msgid in relocate_msgids:
                if relocate_msgid in msgids[old_domain]:
                    msgstr = po_ctl[old_domain].get(relocate_msgid)
                    # We copy over messages for now
                    # del po_ctl[old_domain][relocate_msgid]
                    changes[old_domain] = True

                    new_domain = relocate_domain.get(old_domain)
                    if relocate_msgid in msgids[new_domain]:
                        old_msgstr = po_ctl[new_domain].get(relocate_msgid)
                        if old_msgstr.msgstr == '' and msgstr:
                            po_ctl[new_domain][relocate_msgid] = msgstr
                            changes[new_domain] = True
                            print('copied msgstr for %s' % relocate_msgid)
                        #else:
                        #    print '%s was already there' % relocate_msgid
                    else:
                        po_ctl[new_domain][relocate_msgid] = msgstr
                        changes[new_domain] = True
                        print('copied %s to %s-%s.po' % (relocate_msgid, new_domain, lang))
                #else:
                #    print '%s was not found anymore' % relocate_msgid

        for domain in changes:
            if changes[domain]:
                file = open('%s-%s.po' % (domain, lang), 'w')
                writer = catalog.POWriter(file, po_ctl[domain])
                writer.write(sort=True)