How to use the i18ndude.catalog.MessageCatalog 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 / test_i18n.py View on Github external
PACKAGE_HOME = os.path.join(PACKAGE_HOME, '..')

i18ndir = os.path.normpath(PACKAGE_HOME)

tests=[]
products=[]
pots={}
pot_catalogs={}
pot_lens={}

for potFile in getPotFiles(path=i18ndir):
    product = getProductFromPath(potFile)
    if product not in products:
        products.append(product)
    if product not in pot_catalogs:
        cat = catalog.MessageCatalog(filename=potFile)
        cat_len = len(cat)
        pots.update({product: potFile})
        pot_catalogs.update({product: cat})
        pot_lens.update({product: cat_len})

for product in products:
    class TestOnePOT(PotTestCase.PotTestCase):
        product = product
        pot = pots[product]
    tests.append(TestOnePOT)

    for poFile in getPoFiles(path=i18ndir, product=product):
        class TestOnePoFile(PoTestCase.PoTestCase):
            po = poFile
            product = product
            pot_cat = pot_catalogs[product]
github collective / plone.app.locales / utils / relocate.py View on Github external
# 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)

i18ndude

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

GPL-3.0
Latest version published 11 days ago

Package Health Score

66 / 100
Full package analysis