verify_translations.py: handle JavaScript files

This commit is contained in:
Francis Lachapelle
2016-01-13 10:48:17 -05:00
parent 8e8e19666a
commit ea37a9cd29

View File

@@ -23,11 +23,35 @@ dir_mappings = {
"../UI/MailerUI/Toolbars":"../UI/MailerUI",
"../UI/PreferencesUI/Toolbars":"../UI/PreferencesUI",
"../UI/Scheduler/Toolbars":"../UI/Scheduler",
# .js
"../UI/WebServerResources/generic.js":"../UI/Common",
"../UI/WebServerResources/UIxAclEditor.js":"../UI/Common",
"../UI/WebServerResources/SOGoRootPage.js":"../UI/MainUI",
"../UI/WebServerResources/SOGoRootPage.js":"../UI/MainUI",
"../UI/WebServerResources/PasswordPolicy.js":"../UI/AdministrationUI",
"../UI/WebServerResources/ContactsUI.js":"../UI/Contacts",
"../UI/WebServerResources/UIxContactEditor.js":"../UI/Contacts",
"../UI/WebServerResources/UIxContactsUserFolders.js":"../UI/Contacts",
"../UI/WebServerResources/UIxContactsUserRightsEditor.js":"../UI/Contacts",
"../UI/WebServerResources/MailerUI.js":"../UI/MailerUI",
"../UI/WebServerResources/MailerUIdTree.js":"../UI/MailerUI",
"../UI/WebServerResources/UIxMailEditor.js":"../UI/MailerUI",
"../UI/WebServerResources/UIxMailSearch.js":"../UI/MailerUI",
"../UI/WebServerResources/UIxMailUserRightsEditor.js":"../UI/MailerUI",
"../UI/WebServerResources/UIxPreferences.js":"../UI/PreferencesUI",
"../UI/WebServerResources/UIxFilterEditor.js":"../UI/PreferencesUI",
"../UI/WebServerResources/SchedulerUI.js":"../UI/Scheduler",
"../UI/WebServerResources/UIxCalUserRightsEditor.js":"../UI/Scheduler",
"../UI/WebServerResources/UIxCalViewPrint.js":"../UI/Scheduler",
}
def get_translations(path):
def get_translations(path, filename):
try:
transpath = dir_mappings.get(path, path)
transpath = dir_mappings.get(path)
if not transpath:
transpath = dir_mappings.get(path + '/' + filename)
if not transpath:
transpath = path
transname = transpath + '/English.lproj/Localizable.strings'
transall = open(transname).read()
except:
@@ -37,6 +61,8 @@ def get_translations(path):
def find_missing_translations(rootdir='.', extention='', recomp=None, greylist=()):
for path, dirs, files in os.walk(rootdir):
if (os.path.basename(path) in greylist):
continue
filelist = [f for f in files if f[(-1 * len(extention)):] == extention]
if filelist:
for filename in filelist:
@@ -48,7 +74,7 @@ def find_missing_translations(rootdir='.', extention='', recomp=None, greylist=(
values = [r.groups()[0] for r in [recomp.search(l) for l in lines] if r]
if values:
#- Get the current english translations for the path
transgood = get_translations(path)
transgood = get_translations(path, filename)
if not transgood:
print "No translation file found for %s, skipping %s" % (path, pathname)
continue
@@ -78,9 +104,6 @@ def main():
print 'Usage:', sys.argv[0], '[-g]\n\t\t-g: debug will show matching also'
sys.exit(1)
#greylist = ('UIxFilterEditor.wox')
greylist = ()
#- Get only the label:value from all lines
recomp = re.compile('.label:[^=]*="([^$].*?)"')
find_missing_translations('../UI', 'wox', recomp, greylist)
@@ -91,6 +114,10 @@ def main():
#- tooltip = "Switch to day view"
recomp = re.compile(' tooltip = "(.*?)";')
find_missing_translations('../UI', 'toolbar', recomp, ())
find_missing_translations('../UI', 'toolbar', recomp, ('Resources'))
#- _("Reminder")
recomp = re.compile(' _\("(.*?)"\)')
find_missing_translations('../UI/WebServerResources', 'js', recomp, ())
main()