This will get translator lines from all .po files from current
directory and its subdirectories. It will merge duplicate translator
names to one and add all years found for that name from all files.
Outputs created list of TRANSLATORS to stdout, processed .po files to
stderr (that line may be removed). Not optimized for speed.
#!/usr/bin/python
import os, sys, re
credits = {}
year = re.compile("[0-9]{4}")
def add_creditline(s):
s = s[2:]
index = s.find(",")
years = s[index:]
# set of years
l = set([years[m.start()+2:m.start()+6] for m in
re.finditer(re.escape(", "), years)])
if credits.has_key(s[:index]):
# if name already exists, add years to set
credits[s[:index]] = credits[s[:index]].union(l)
else:
# else append new name
credits[s[:index]] = l
def main():
creditline = re.compile(r"^# .*\, [0-9]{4}.$")
# traverse looking for .po files from current directory
for root, dirs, files in os.walk(".", topdown=False):
for name in files:
if name[-3:] == ".po":
# debug: write .po file name to stderr
sys.stderr.write(os.path.join(root, name)+'\n')
# read credit lines from .po
f = open(os.path.join(root, name), "r")
s = f.readline()
while s != 'msgid ""\n' and s !=
'':
s = f.readline()
if creditline.match(s):
add_creditline(s)
f.close()
# sort by translator name and print
credit_names = credits.keys()
credit_names.sort()
for i in credit_names:
print i + ", " + ", ".join(credits[i])) +
"."
if __name__ == "__main__":
main()
Regards,
~~helix84
On Mon, Mar 10, 2008 at 3:58 PM, Lucas Vieites <lucas@...162...> wrote:
I think there's room for optimisation, but this line does the
job
extracting only the last translators:
grep Last-Translator *.po | awk 'BEGIN { FS = ":" } ; {print $3}' |
sed
's/\\n\"//g' | sed '/^ $/d' | sed 's/^ //g' | uniq | sort
> TRANSLATORS
Cheers,
Lucas
2008/3/10, Luca Bruno <gnug.torte@...20...>:
>
>
>
> Lucas Vieites scrisse:
>
> > Hi,
> > I was wondering if the TRANSLATORS file is automatically update from
> > data in the .po files.
>
> Not yet. It would be really cool if someone come up with a simple
> script to do so (I think a few lines of sed/awk/perl/whatever would do
> the job).
>
> > My e-mail address has changed (and is reflected
> > in es.po), but in TRANSLATORS it's still the old one.
> >
> > So, if it's doneby hand I would like to request that my entry:
> > Lucas Vieites Fariña<lucas@...2...>, 2003-2008.
> > be changed to:
> > Lucas Vieites Fariña <lucas@...162...>, 2003-2008.
>
> Done.
>
> > Thank you in advance,
>
> Cheers, Luca
>
>
> --
> .''`. ** Debian GNU/Linux ** | Luca Bruno
> : :' : The Universal O.S. | lucab (AT)
debian.org
> `. `'` | GPG Key ID: 3BFB9FB3
> `-
http://www.debian.org | Debian GNU/Linux Developer
>
>
> -------------------------------------------------------------------------
> This
SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
>
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Inkscape-translator mailing list
> Inkscape-translator(a)lists.sourceforge.net
>
https://lists.sourceforge.net/lists/listinfo/inkscape-translator
>
>
>
-------------------------------------------------------------------------
This
SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Inkscape-translator mailing list
Inkscape-translator(a)lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/inkscape-translator