fixed sync languages, thanks Yair

This commit is contained in:
Massimo committed 2012-10-30 11:09:50 -05:00
1 parent 5713ec1365
commit c404db4a08
2 files changed
+14 -7

No files matched your search

+1 -1
View File
@@ -1 +1 @@
Version 2.2.1 (2012-10-30 09:41:34) stable Version 2.2.1 (2012-10-30 11:09:19) stable
+13 -6
View File
@@ -7,14 +7,10 @@ import sys
import shutil import shutil
import os import os
from gluon.languages import findT, utf8_repr from gluon.languages import findT
sys.path.insert(0, '.') sys.path.insert(0, '.')
file = sys.argv[1]
apps = sys.argv[2:]
def sync_language(d, data): def sync_language(d, data):
''' this function makes sure a translated string will be prefered over an untranslated ''' this function makes sure a translated string will be prefered over an untranslated
string when syncing languages between apps. when both are translated, it prefers the string when syncing languages between apps. when both are translated, it prefers the
@@ -37,6 +33,7 @@ def sync_language(d, data):
return d return d
def sync_main(file, apps):
d = {} d = {}
for app in apps: for app in apps:
path = 'applications/%s/' % app path = 'applications/%s/' % app
@@ -49,6 +46,7 @@ for app in apps:
d = sync_language(d, data) d = sync_language(d, data)
path = 'applications/%s/' % apps[-1] path = 'applications/%s/' % apps[-1]
file1 = os.path.join(path, 'languages', '%s.py' % file) file1 = os.path.join(path, 'languages', '%s.py' % file)
@@ -59,7 +57,7 @@ try:
keys = d.keys() keys = d.keys()
keys.sort() keys.sort()
for key in keys: for key in keys:
f.write('%s:%s,\n' % (utf8_repr(key), utf8_repr(str(d[key])))) f.write("'''%s''':'''%s''',\n" % (key.replace("'", "\\'"), str(d[key].replace("'", "\\'"))))
f.write('}\n') f.write('}\n')
finally: finally:
f.close() f.close()
@@ -68,4 +66,13 @@ oapps = reversed(apps[:-1])
for app in oapps: for app in oapps:
path2 = 'applications/%s/' % app path2 = 'applications/%s/' % app
file2 = os.path.join(path2, 'languages', '%s.py' % file) file2 = os.path.join(path2, 'languages', '%s.py' % file)
if file1 != file2:
shutil.copyfile(file1, file2) shutil.copyfile(file1, file2)
if __name__ == "__main__":
file = sys.argv[1]
apps = sys.argv[2:]
sync_main(file, apps)