#!/usr/bin/env python # -*- coding: utf-8 -*- # A simple script that adds all authors from transifex, which are # listed in comments at the beginning of the file, to the # 'translator-credits' translations - where launchpad added them # and which are shown in stk. # # First rename the transifex files: # for i in supertuxkartpot_*; do mv $i ${i##supertuxkartpot_}; done # # Usage: update_po_authors.py PATH_TO/LANGUAGE.po # # IMPORTANT note: this script must be run on a file downloaded # from transifex, not on a file on which this script had # been run before (otherwise the transifex authors would # be added again and again)!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # # Less important note: The specified file is overwritten without # a backup! Make sure the git status is unmodified. # import re import sys if __name__ == "__main__": if len(sys.argv) < 2: print "Usage: getpo_authors.py PATH_TO_PO_FILE" sys.exit(-1) for filename in sys.argv[1:]: print("Processing file %s" % filename) f = open(filename, "r") if not f: print "Can not find", filename exit lines = f.readlines() f.close() # There are two sources of contributors: # 1) Entries in the header from transifex (after "Translators:" # till the first msgid string. # 2) Entries as "translator-credits". These shouldn't be there, # but sometimes occur (e.g. because an old version of this # script was used that did not support these entries). # Assemble all those entries in one line found = 0 contributions = "" line_count = 0 new_authors = [] author_list = [] # Find new and old authors with a simple finite state machine: # ============================================================ i = 0 while i < len(lines): line = lines[i][:-1] # remove \n i = i + 1 if line=="# Translators:": while i