Skip to content

Instantly share code, notes, and snippets.

@ecarreras
Created January 4, 2017 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecarreras/1d10031fa3e0b73ef891358e57a813dc to your computer and use it in GitHub Desktop.
Save ecarreras/1d10031fa3e0b73ef891358e57a813dc to your computer and use it in GitHub Desktop.
from babel.messages import catalog, pofile
SPLITS = 10
catalogs = [catalog.Catalog(locale='es_ES') for _ in range(0, SPLITS)]
with open('locales/es_ES/LC_MESSAGES/messages.po', 'r') as f:
po = pofile.read_po(f)
untranslated = [s.id for s in po if not s.string]
for idx, string in enumerate(untranslated):
c_idx = idx % SPLITS
c = catalogs[c_idx]
c.add(string)
for idx, c in enumerate(catalogs):
with open('locales/es_ES/LC_MESSAGES/messages.{}.po'.format(idx), 'w') as f:
pofile.write_po(f, c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment