Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any Python package which allows parsing .po files (messages, including context comments)?

I need to merge/update/delete .po files messages and need some Python package which allow me to parse fully .po files including: messages, plurals, location, context and comments.

I want do simple tool which will check differences between to files. I could use also some GUI is already done but not sure if there such tool which will add new translation or remove not used translation.

I was search some articles but not found how to do it. Please recommend some Python package which parse .po fully (could other language) or tool to do such important task to keep good translations.

like image 594
Chameleon Avatar asked Oct 27 '25 15:10

Chameleon


2 Answers

The polib package is very good. It parses the file and presents several ways to access the data, including an iterator to loop through the msgid, msgstr pairs to do whatever you need. Here is the Quick Start documentation.

It can also parse a .mo if the .po isn't available, specially handle obsolete message strings, iterate over only translated strings, and other nice features.

like image 56
carl_kibler Avatar answered Oct 30 '25 07:10

carl_kibler


Try the babel module. it includes a .po parser in babel.messages.catalog and babel.messages.pofile among other things.

like image 26
wRAR Avatar answered Oct 30 '25 08:10

wRAR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!