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 details)

Uploaded Source

Built Distributions

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

Uploaded Source

polib-0.3.1-1.noarch.rpm (24.6 kB view details)

Uploaded Source

File details

Details for the file polib-0.3.1.tar.gz.

File metadata

  • Download URL: polib-0.3.1.tar.gz
  • Upload date:
  • Size: 206.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for polib-0.3.1.tar.gz
Algorithm Hash digest
SHA256 53c3348c5b03d1059480033a35646fcf37ebf4066034a0ef81dfbc822f67160e
MD5 d8bcd87efe252ff7daef940c94a40279
BLAKE2b-256 092a16414c4023b07eb8b9b8e4c1cf0c8819e6db33a7ab0eeabdcf8ab6170402

See more details on using hashes here.

File details

Details for the file polib-0.3.1.win32.exe.

File metadata

  • Download URL: polib-0.3.1.win32.exe
  • Upload date:
  • Size: 72.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for polib-0.3.1.win32.exe
Algorithm Hash digest
SHA256 1309f117b7851aa133d638d449bccde566f84803322f1bbdde569cb21be33cba
MD5 ab0d6423621d14296362c0103c55e8ab
BLAKE2b-256 939aab74f9d0c820f7dfc2c3c01cf1c31265a6e602a436938274239ae8708ea3

See more details on using hashes here.

File details

Details for the file polib-0.3.1-1.noarch.rpm.

File metadata

  • Download URL: polib-0.3.1-1.noarch.rpm
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for polib-0.3.1-1.noarch.rpm
Algorithm Hash digest
SHA256 608dfd24fbf90e90d3bd42ddf0c8591cb51b68992ef18aa26e57040cf7718111
MD5 33810dcdc364a0fba3a147e9e4b17285
BLAKE2b-256 43ca8ba1d15f0ee97469afcdf415e134886ad1ddfc28fe732bebde0ce5b0bedf

See more details on using hashes here.

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