Skip to content

Instantly share code, notes, and snippets.

@nijel
Last active August 29, 2015 14:15
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 nijel/6afc9f4ad5cb19a78403 to your computer and use it in GitHub Desktop.
Save nijel/6afc9f4ad5cb19a78403 to your computer and use it in GitHub Desktop.
Count units in a translation file
from translate.storage import factory
import sys
f = factory.getobject(sys.argv[1])
print(
'File {0} has {1} units'.format(
sys.argv[1],
len(f.units)
)
)
print(
'File {0} has {1} translatable units'.format(
sys.argv[1],
len([unit for unit in f.units if unit.istranslatable()])
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment