Skip to content

Commit

Permalink
One more time, sort paths correctly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wader committed Aug 6, 2011
1 parent 03b46f5 commit 835970c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 69 deletions.
11 changes: 1 addition & 10 deletions lang/de_DE.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -131,17 +125,14 @@ 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

id: OK
msg: OK

#
# ./glwthemes/mono/popups/auth.view
#
id: Password
msg: Passwort

Expand Down
11 changes: 1 addition & 10 deletions lang/it_IT.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -131,17 +125,14 @@ 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

id: OK
msg: OK

#
# ./glwthemes/mono/popups/auth.view
#
id: Password
msg: Password

Expand Down
11 changes: 1 addition & 10 deletions lang/pt_PT.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -132,17 +126,14 @@ 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

id: OK
msg: OK

#
# ./glwthemes/mono/popups/auth.view
#
id: Password
msg: Palavra-passe

Expand Down
11 changes: 1 addition & 10 deletions lang/sv_SV.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -131,17 +125,14 @@ 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

id: OK
msg: OK

#
# ./glwthemes/mono/popups/auth.view
#
id: Password
msg: Lösenord

Expand Down
58 changes: 29 additions & 29 deletions support/update_lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <langfile> [<langfile...>]" % 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:]:

Expand All @@ -39,7 +43,7 @@ def buildphrases(rootpath):
language = 'Unknown'
native = 'Unknown'

in_strings = {}
in_phrases = {}
if os.path.isfile(path):
f = open(path)

Expand All @@ -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()

Expand All @@ -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()

0 comments on commit 835970c

Please sign in to comment.