def write_language_file(lang): if os.name == 'nt': regko = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, "Software\\BitTorrent") if lang == '': _winreg.DeleteValue(regko, "Language") else: lcid = None # I want two-way dicts for id, code in locale_sucks.iteritems(): if code.lower() == lang.lower(): lcid = id break if not lcid: raise KeyError(lang) _winreg.SetValueEx(regko, "Language", 0, _winreg.REG_SZ, str(lcid)) else: lang_file_name = language_path() lang_file = open(lang_file_name, 'w') lang_file.write(lang) lang_file.close()
f.close() b = b.replace("%VERSION%", version_str) b = b.replace("%APP_NAME%", app_name) found_langs = {} lang_macros = "" for l in languages: lang = nsis_language_names[l] nlf = os.path.join(NSIS_DIR, "Contrib\\Language files\\%s.nlf" % lang) nsh = os.path.join(NSIS_DIR, "Contrib\\Modern UI\\Language files\\%s.nsh" % lang) if os.path.exists(nlf) and os.path.exists(nsh): lang_macros += (' !insertmacro MUI_LANGUAGE "%s"\r\n' % lang) found_langs[l] = lang else: lcid = None for id, code in locale_sucks.iteritems(): if code.lower() == l.lower(): lcid = id print "Creating a template for", lang, lcid f = open(nlf, 'w') template = open("windows_installer\\template.nlf", 'r') template_str = template.read() template.close() t = (template_str % {'id':lcid}) f.write(t) f.close() f = open(nsh, 'w') template = open("windows_installer\\template.nsh", 'r') template_str = template.read()
b = b.replace("%VERSION%", version_str) b = b.replace("%APP_NAME%", app_name) found_langs = {} lang_macros = "" for l in languages: lang = nsis_language_names[l] nlf = os.path.join(NSIS_DIR, "Contrib\\Language files\\%s.nlf" % lang) nsh = os.path.join(NSIS_DIR, "Contrib\\Modern UI\\Language files\\%s.nsh" % lang) if os.path.exists(nlf) and os.path.exists(nsh): lang_macros += (' !insertmacro MUI_LANGUAGE "%s"\r\n' % lang) found_langs[l] = lang else: lcid = None for id, code in locale_sucks.iteritems(): if code.lower() == l.lower(): lcid = id print "Creating a template for", lang, lcid f = open(nlf, 'w') template = open("windows_installer\\template.nlf", 'r') template_str = template.read() template.close() t = (template_str % {'id': lcid}) f.write(t) f.close() f = open(nsh, 'w') template = open("windows_installer\\template.nsh", 'r') template_str = template.read()