#NEWLINE# def lang_stats( resources = None , languages = None ) : #NEWLINE# #INDENT# "\n    Output language statistics of committed translation files for each\n    Django catalog.\n    If resources is provided, it should be a list of translation resource to\n    limit the output (e.g. ['core', 'gis']).\n    " #NEWLINE# locale_dirs = _get_locale_dirs ( ) #NEWLINE# for ( name , dir_ ) in locale_dirs : #NEWLINE# #INDENT# if ( resources and ( not ( name in resources ) ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# print ( ( "\nShowing translations stats for '%s':" % name ) ) #NEWLINE# langs = sorted ( [ d for d in os . listdir ( dir_ ) if ( not d . startswith ( '_' ) ) ] ) #NEWLINE# for lang in langs : #NEWLINE# #INDENT# if ( languages and ( not ( d in languages ) ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# p = Popen ( ( 'msgfmt -vc -o /dev/null %(path)s/%(lang)s/LC_MESSAGES/django%(ext)s.po' % { #NEWLINE# #INDENT# 'path' : dir_ , #NEWLINE# 'lang' : lang , #NEWLINE# 'ext' : ( 'js' if name . endswith ( '-js' ) else '' ) , #NEWLINE# #UNINDENT# } ) , stdout = PIPE , stderr = PIPE , shell = True ) #NEWLINE# ( output , errors ) = p . communicate ( ) #NEWLINE# if ( p . returncode == 0 ) : #NEWLINE# #INDENT# print ( ( '%s: %s' % ( lang , errors . strip ( ) ) ) )