sync languages patch, helps merging language files, thanks Yair
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 1.99.4 (2012-02-11 23:04:52) stable
|
Version 1.99.4 (2012-02-12 09:49:15) stable
|
||||||
|
|||||||
@@ -14,6 +14,28 @@ sys.path.insert(0, '.')
|
|||||||
file = sys.argv[1]
|
file = sys.argv[1]
|
||||||
apps = sys.argv[2:]
|
apps = sys.argv[2:]
|
||||||
|
|
||||||
|
def sync_language(d, data):
|
||||||
|
''' 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
|
||||||
|
latter app, as did the original script
|
||||||
|
'''
|
||||||
|
|
||||||
|
for key in data:
|
||||||
|
# if this string is not in the allready translated data, add it
|
||||||
|
if key not in d:
|
||||||
|
d[key] = data[key]
|
||||||
|
# see if there is a translated string in the original list, but not in the new list
|
||||||
|
elif (
|
||||||
|
((d[key] != '') or (d[key] != key)) and
|
||||||
|
((data[key] == '') or (data[key] == key))
|
||||||
|
):
|
||||||
|
d[key] = d[key]
|
||||||
|
# any other case (wether there is or there isn't a translated string)
|
||||||
|
else:
|
||||||
|
d[key] = data[key]
|
||||||
|
|
||||||
|
return d
|
||||||
|
|
||||||
d = {}
|
d = {}
|
||||||
for app in apps:
|
for app in apps:
|
||||||
path = 'applications/%s/' % app
|
path = 'applications/%s/' % app
|
||||||
@@ -23,7 +45,8 @@ for app in apps:
|
|||||||
data = eval(langfile.read())
|
data = eval(langfile.read())
|
||||||
finally:
|
finally:
|
||||||
langfile.close()
|
langfile.close()
|
||||||
d.update(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)
|
||||||
|
|||||||
Reference in New Issue
Block a user