Skip to main content

A library to manipulate gettext catalogs files (aka .po and .mo files).

Project description

polib allows you to manipulate, create, modify gettext catalogs (.pot, .po and binary .mo files). You can load existing files, iterate through it’s entries, add, modify entries, comments or metadata, etc… or create new po/pot files from scratch.

polib provides a simple and pythonic API, exporting only two convenience functions ‘pofile’ and ‘mofile’, and the 4 core classes: POFile, MOFile, POEntry and MOEntry for creating new files/entries.

A basic example

>>> import polib
>>> # load an existing po file
>>> po = polib.pofile('tests/test.po')
>>> for entry in po:
...     # do something with entry...
...     print entry.msgid, entry.msgstr
>>> # add an entry
>>> entry = polib.POEntry()
>>> entry.msgid = 'Welcome'
>>> entry.msgstr = 'Bienvenue'
>>> entry.occurences = [('welcome.py', '12'), ('anotherfile.py', '34')]
>>> po.append(entry)
>>> # save our modified po file
>>> po.save()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polib-0.1.0.tar.gz (39.3 kB view hashes)

Uploaded Source

Built Distributions

polib-0.1.0.win32.exe (70.6 kB view hashes)

Uploaded Source

polib-0.1.0-1.noarch.rpm (21.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page