diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2015-08-25 13:20:14 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2015-08-25 15:43:55 +0100 |
commit | 7d679eb4800df015c89ec9e4e7f82b815a051162 (patch) | |
tree | 4421b47d74c3c91bf338c2e997f40d0bfaae7df3 /gen_web_gettext.py | |
parent | 23cbd581dbb79d0b319052f62995b8152cc79a0a (diff) | |
download | deluge-7d679eb4800df015c89ec9e4e7f82b815a051162.tar.gz deluge-7d679eb4800df015c89ec9e4e7f82b815a051162.tar.bz2 deluge-7d679eb4800df015c89ec9e4e7f82b815a051162.zip |
Updates to helper scripts
* Python 3 compatible
* Consistent quote symbol
Diffstat (limited to 'gen_web_gettext.py')
-rwxr-xr-x | gen_web_gettext.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/gen_web_gettext.py b/gen_web_gettext.py index cb8d5589b..48535648c 100755 --- a/gen_web_gettext.py +++ b/gen_web_gettext.py @@ -32,23 +32,20 @@ def create_gettext_js(js_dir): locations.append((os.path.basename(filename), lineno + 1)) strings[string] = locations - keys = strings.keys() - keys.sort() - - gettext_tpl = """GetText={maps:{},\ + gettext_tpl = '''GetText={maps:{},\ add:function(string,translation) {this.maps[string]=translation},\ get:function(string) {if (this.maps[string]) {string=this.maps[string]} return string}} function _(string) {return GetText.get(string)}\ - """ + ''' gettext_file = os.path.join(os.path.dirname(js_dir), 'gettext.js') with open(gettext_file, 'w') as fp: fp.write(gettext_tpl) - for key in keys: + for key in sorted(strings.keys()): if DEBUG: - fp.write('\n// %s\n' % ', '.join(map(lambda x: '%s:%s' % x, strings[key]))) - fp.write("GetText.add('%(key)s','${escape(_(\"%(key)s\"))}')\n" % locals()) + fp.write('\n// %s\n' % ', '.join(['%s:%s' % x for x in strings[key]])) + fp.write('''GetText.add('%(key)s','${escape(_("%(key)s"))}')\n''' % locals()) if __name__ == '__main__': create_gettext_js(WEBUI_JS_DIR) - print "Created %s" % WEBUI_JS_DIR + print('Created %s' % WEBUI_JS_DIR) |