From 835970c8825635fe86ac41fedb8f01c016ac1815 Mon Sep 17 00:00:00 2001 From: Mattias Wadman Date: Sat, 6 Aug 2011 14:17:28 +0200 Subject: [PATCH] One more time, sort paths correctly Paths where outputted sorted but correct source file was not always written to output file. More cleanup and use a dict with first sorted path as key and value is sorted list of phrases. --- lang/de_DE.lang | 11 +------- lang/it_IT.lang | 11 +------- lang/pt_PT.lang | 11 +------- lang/sv_SV.lang | 11 +------- support/update_lang.py | 58 +++++++++++++++++++++--------------------- 5 files changed, 33 insertions(+), 69 deletions(-) diff --git a/lang/de_DE.lang b/lang/de_DE.lang index cb599e842b..3fbe6f3e1a 100644 --- a/lang/de_DE.lang +++ b/lang/de_DE.lang @@ -46,15 +46,9 @@ msg: Gefundene CPUs: %d id: Display info msg: Anzeige Info -# -# ./glwthemes/mono/sysinfo.view -# id: Framerate: %.2f Hz msg: Bildrate %.2f Hz -# -# ./glwthemes/mono/pages/about.view -# id: GPU: %s msg: GPU: %s @@ -131,7 +125,7 @@ id: CPU is too slow to decode this video msg: CPU ist zu langsam um das Video zu dekodieren # -# ./glwthemes/mono/popups/message.view +# ./glwthemes/mono/popups/auth.view # id: Cancel msg: Abbrechen @@ -139,9 +133,6 @@ msg: Abbrechen id: OK msg: OK -# -# ./glwthemes/mono/popups/auth.view -# id: Password msg: Passwort diff --git a/lang/it_IT.lang b/lang/it_IT.lang index fb702b1f36..4f54ebc1ad 100644 --- a/lang/it_IT.lang +++ b/lang/it_IT.lang @@ -46,15 +46,9 @@ msg: CPU rilevate: %d id: Display info msg: Informazioni di visualizzazione -# -# ./glwthemes/mono/sysinfo.view -# id: Framerate: %.2f Hz msg: Framerate: %.2f Hz -# -# ./glwthemes/mono/pages/about.view -# id: GPU: %s msg: GPU: %s @@ -131,7 +125,7 @@ id: CPU is too slow to decode this video msg: CPU troppo lenta per poter decodificare questo video # -# ./glwthemes/mono/popups/message.view +# ./glwthemes/mono/popups/auth.view # id: Cancel msg: Annulla @@ -139,9 +133,6 @@ msg: Annulla id: OK msg: OK -# -# ./glwthemes/mono/popups/auth.view -# id: Password msg: Password diff --git a/lang/pt_PT.lang b/lang/pt_PT.lang index f1f1e2d0a2..9099308ace 100644 --- a/lang/pt_PT.lang +++ b/lang/pt_PT.lang @@ -47,15 +47,9 @@ msg: CPUs detetados: %d id: Display info msg: Informações de visualização -# -# ./glwthemes/mono/sysinfo.view -# id: Framerate: %.2f Hz msg: Framerate: %.2f Hz -# -# ./glwthemes/mono/pages/about.view -# id: GPU: %s msg: GPU: %s @@ -132,7 +126,7 @@ id: CPU is too slow to decode this video msg: O CPU é muito lento para descodificar este vídeo # -# ./glwthemes/mono/popups/message.view +# ./glwthemes/mono/popups/auth.view # id: Cancel msg: Cancelar @@ -140,9 +134,6 @@ msg: Cancelar id: OK msg: OK -# -# ./glwthemes/mono/popups/auth.view -# id: Password msg: Palavra-passe diff --git a/lang/sv_SV.lang b/lang/sv_SV.lang index adc066d34b..928bab0afb 100644 --- a/lang/sv_SV.lang +++ b/lang/sv_SV.lang @@ -46,15 +46,9 @@ msg: Funna CPUer: %d id: Display info msg: Bildskärmsinformation -# -# ./glwthemes/mono/sysinfo.view -# id: Framerate: %.2f Hz msg: Uppdateringsfrekvens %.2f Hz -# -# ./glwthemes/mono/pages/about.view -# id: GPU: %s msg: GPU: %s @@ -131,7 +125,7 @@ id: CPU is too slow to decode this video msg: CPUn är för långsam för att spela upp videon # -# ./glwthemes/mono/popups/message.view +# ./glwthemes/mono/popups/auth.view # id: Cancel msg: Avbryt @@ -139,9 +133,6 @@ msg: Avbryt id: OK msg: OK -# -# ./glwthemes/mono/popups/auth.view -# id: Password msg: Lösenord diff --git a/support/update_lang.py b/support/update_lang.py index c9ea1d02c5..29ed29579b 100755 --- a/support/update_lang.py +++ b/support/update_lang.py @@ -18,17 +18,21 @@ def buildphrases(rootpath): if f.endswith(('.c', '.view', '.skin')): scanfile(os.path.join(a[0], f), p) - return p - - - + # invert dict to use first source as key and value is list of phrases + phrases = {} + for phrase, sources in p.iteritems(): + phrases.setdefault(sorted(sources)[0], []).append(phrase) + # sort phrases for each source + for source in phrases: + phrases[source].sort() + + return phrases if len(sys.argv) < 3: print "Usage: %s rootpath []" % sys.argv[0] sys.exit(1) -phraselist = [(k, v) for k,v in buildphrases(sys.argv[1]).iteritems()] - +phrases = buildphrases(sys.argv[1]) for path in sys.argv[2:]: @@ -39,7 +43,7 @@ def buildphrases(rootpath): language = 'Unknown' native = 'Unknown' - in_strings = {} + in_phrases = {} if os.path.isfile(path): f = open(path) @@ -64,7 +68,7 @@ def buildphrases(rootpath): mid = o.group(2) if o.group(1) == 'msg' and len(o.group(2)) > 0: - in_strings[mid] = o.group(2) + in_phrases[mid] = o.group(2) f.close() @@ -78,26 +82,22 @@ def buildphrases(rootpath): print >>outfile, 'maintainer: %s' % maintainer print "Processing %s (%s / %s) maintained by %s" % \ - (path, language, native, maintainer) - - for key, sources in sorted(phraselist, key=lambda (w, sources): '%s %s' % (sorted(sources)[0], w)): - source = sources[0] - - if source != last: - last = source - print >>outfile, '#' - print >>outfile, '# %s' % last - print >>outfile, '#' - - print >>outfile, 'id: %s' % key - - if key in in_strings: - print >>outfile, 'msg: %s' % in_strings[key] - else: - print " ! Missing translation for %s" % key - print >>outfile, "# Missing translation" - print >>outfile, 'msg: ' - - print >>outfile + (path, language, native, maintainer) + + for source in sorted(phrases): + print >>outfile, '#' + print >>outfile, '# %s' % source + print >>outfile, '#' + + for phrase in phrases[source]: + print >>outfile, 'id: %s' % phrase + if phrase in in_phrases: + print >>outfile, 'msg: %s' % in_phrases[phrase] + else: + print >>outfile, "# Missing translation" + print >>outfile, 'msg: ' + print " ! Missing translation for %s" % phrase + + print >>outfile outfile.close()