Skip to main content

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

Project description

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

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

What’s new in version 0.3.1

  • fixed bug #0002: typo: “occurences” instead of “occurrences”,
  • fixed bug #0003: mismatch in exception instance names,
  • removed deprecation warnings,
  • removed unused charset() method in POFile/MOFile objects,
  • fixed bug in multibytes string length (added regression tests),
  • fixed a bug in detect_encoding(),
  • added a find() method to _BaseFile class,
  • proper handling of quoting and unquoting,
  • proper handling of multiline strings in metadata.

Basic usage example

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

Download it from here and visit: http://code.google.com/p/polib/

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.3.1
Filename, size File type Python version Upload date Hashes
Filename, size polib-0.3.1-1.noarch.rpm (24.6 kB) File type RPM Python version 2.5 Upload date Hashes View hashes
Filename, size polib-0.3.1.tar.gz (206.9 kB) File type Source Python version None Upload date Hashes View hashes
Filename, size polib-0.3.1.win32.exe (72.1 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