[WebUI] Fix to gen_web_gettext

This commit is contained in:
bendikro 2015-12-26 17:25:16 +01:00 committed by Calum Lind
parent b76d208212
commit 74f2f45fc0

View File

@ -37,8 +37,8 @@ def create_gettext_js(js_dir):
gettext_tpl = '''GetText={maps:{},\ gettext_tpl = '''GetText={maps:{},\
add:function(string,translation) {this.maps[string]=translation},\ add:function(string,translation) {this.maps[string]=translation},\
get:function(string) {if (this.maps[string]) {string=this.maps[string]} return string}} get:function(string) {if (this.maps[string]) {string=this.maps[string]} return string}}
function _(string) {return GetText.get(string)}\ function _(string) {return GetText.get(string)}
''' '''
gettext_file = os.path.join(os.path.dirname(js_dir), 'gettext.js') gettext_file = os.path.join(os.path.dirname(js_dir), 'gettext.js')
with open(gettext_file, 'w') as fp: with open(gettext_file, 'w') as fp:
@ -47,7 +47,8 @@ def create_gettext_js(js_dir):
if DEBUG: if DEBUG:
fp.write('\n// %s\n' % ', '.join(['%s:%s' % x for x in strings[key]])) 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()) fp.write('''GetText.add('%(key)s','${escape(_("%(key)s"))}')\n''' % locals())
return gettext_file
if __name__ == '__main__': if __name__ == '__main__':
create_gettext_js(WEBUI_JS_DIR) filename = create_gettext_js(WEBUI_JS_DIR)
print('Created gettext.js for %s' % WEBUI_JS_DIR) print("Created '%s'" % filename)