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.

Files for polib, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size polib-0.1.0-1.noarch.rpm (21.1 kB) File type RPM Python version 2.4 Upload date Hashes View hashes
Filename, size polib-0.1.0.tar.gz (39.3 kB) File type Source Python version None Upload date Hashes View hashes
Filename, size polib-0.1.0.win32.exe (70.6 kB) File type Windows Installer Python version 2.4 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page