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.

Filename, size & hash SHA256 hash help File type Python version Upload date
polib-0.1.0-1.noarch.rpm (21.1 kB) Copy SHA256 hash SHA256 RPM 2.4 Aug 9, 2006
polib-0.1.0.tar.gz (39.3 kB) Copy SHA256 hash SHA256 Source None Aug 9, 2006
polib-0.1.0.win32.exe (70.6 kB) Copy SHA256 hash SHA256 Windows Installer 2.4 Aug 9, 2006

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 DigiCert DigiCert EV certificate StatusPage StatusPage Status page