Skip to content

Commit

Permalink
Sort paths for each key as os.walk might return files in different order
Browse files Browse the repository at this point in the history
This makes sure the same source file will own a key if it appears
in multiple files.
Also some cleanup and make code more pythonic
  • Loading branch information
wader committed Aug 5, 2011
1 parent 356be2f commit 48c3dc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
15 changes: 6 additions & 9 deletions lang/sv_SV.lang
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ msg: CPUn är för långsam för att spela upp videon
#
# ./glwthemes/mono/popups/auth.view
#
id: Cancel
msg: Avbryt

id: OK
msg: OK

id: Password
msg: Lösenord

Expand All @@ -133,15 +139,6 @@ msg: Kom ihåg mig
id: Username
msg: Användarnamn

#
# ./glwthemes/mono/popups/message.view
#
id: Cancel
msg: Avbryt

id: OK
msg: OK

#
# ./glwthemes/mono/screensaver.view
#
Expand Down
23 changes: 5 additions & 18 deletions support/update_lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,11 @@
import re
import json

M = re.compile('_p{0,1}\("([^"]*)"\)')

M = re.compile('_p?\("([^"]*)"\)')

def scanfile(path, p):
f = open(path)
s = f.read()
l = re.findall(M, s)
if len(l) > 0:
for w in l:
if w in p:
if path not in p:
p[w].append(path)
else:
p[w] = [path]
f.close()


for w in re.findall(M, open(path).read()):
p.setdefault(w, []).append(path)

def buildphrases(rootpath):
p = {}
Expand Down Expand Up @@ -92,9 +80,8 @@ def buildphrases(rootpath):
print "Processing %s (%s / %s) maintained by %s" % \
(path, language, native, maintainer)

for x in sorted(phraselist, key=lambda x: '%s %s' % (x[1][0], x[0])):
key = x[0]
source = x[1][0]
for key, sources in sorted(phraselist, key=lambda (w, sources): '%s %s' % (sources[0], w)):
source = sources[0]

if source != last:
last = source
Expand Down

0 comments on commit 48c3dc1

Please sign in to comment.