How to use the i18ndude.catalog.POWriter function in i18ndude

To help you get started, we’ve selected a few i18ndude examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github collective / plone.app.locales / tests / i18ngenerator.py View on Github external
ctl[domain] = catalog.MessageCatalog(domain=domain)
                label = dict.get('label')
                label_msgid = dict.get('label_msgid')
                desc = norm(dict.get('description'))
                desc_msgid = dict.get('description_msgid')

                if label_msgid and label:
                    ctl[domain].add(label_msgid, label, references=['widget label of %s - description \"%s\"' % (w.getName(), desc)])
                if desc_msgid and desc:
                    ctl[domain].add(desc_msgid, desc, references=['widget description of %s for label %s' % (w.getName(), label)])

        domains = ctl.keys()

        for domain in domains:
            file = open('%s-generated.pot' % domain, 'w')
            writer = catalog.POWriter(file, ctl[domain])
            writer.write(sort=True, msgstrToComment=True)
github collective / plone.app.locales / utils / relocate.py View on Github external
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)
github collective / plone.app.locales / i18n / utils / renamemsgid.py View on Github external
try:
            msgids = po_ctl.keys()
            if old in msgids:
                if new in msgids:
                    print 'New message already in %s' % poFile
                else:
                    po_ctl[new] = po_ctl.get(old)
                    del po_ctl[old]
                    print 'Rename %s to %s in file %s' % (old, new, poFile)
            else:
                print 'Old message not found in %s' % poFile
        except IndexError:
            print poFile

        file = open(poFile+'-new', 'w')
        writer = catalog.POWriter(file, po_ctl)
        writer.write(sort=True)

i18ndude

i18ndude performs various tasks related to ZPT's, Python Scripts and i18n.

GPL-3.0
Latest version published 4 months ago

Package Health Score

64 / 100
Full package analysis

Similar packages