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.

Source Distribution

polib-0.3.1.tar.gz (206.9 kB view hashes)

Uploaded Source

Built Distributions

polib-0.3.1.win32.exe (72.1 kB view hashes)

Uploaded Source

polib-0.3.1-1.noarch.rpm (24.6 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