Drop Windows EXE support for gettext

This commit is contained in:
Yen Chi Hsuan 2015-12-13 00:22:37 +08:00
parent 89442a0e26
commit 995f5036ca
2 changed files with 0 additions and 37 deletions

View File

@ -7,8 +7,6 @@ import os.path
import warnings
import sys
import glob
import io
import zipfile
try:
from setuptools import setup
@ -27,15 +25,6 @@ except ImportError:
exit(1)
def zipped_folder(topdir):
f = io.BytesIO()
zipf = zipfile.ZipFile(f, mode='w')
for dirpath, dirnames, filenames in os.walk(topdir):
for filename in filenames:
zipf.write(os.path.join(dirpath, filename))
zipf.close()
return f.getvalue()
py2exe_options = {
"bundle_files": 1,
"compressed": 1,
@ -47,7 +36,6 @@ py2exe_options = {
py2exe_console = [{
"script": "./youtube_dl/__main__.py",
"dest_base": "youtube-dl",
"other_resources": [(u'LOCALE_DATA', u'locale_data.zip', zipped_folder('share'))],
}]
py2exe_params = {

View File

@ -32,7 +32,6 @@ import sys
import tempfile
import traceback
import xml.etree.ElementTree
import zipfile
import zlib
from .compat import (
@ -2514,36 +2513,12 @@ class ISO3166Utils(object):
return cls._country_map.get(code.upper())
def _load_exe_resource(res_type, res_name):
kernel32 = ctypes.windll.kernel32
exe_handle = 0 # NULL: Current process
res_info = kernel32.FindResourceW(exe_handle, res_name, res_type)
res_handle = kernel32.LoadResource(exe_handle, res_info)
res_data = kernel32.LockResource(res_handle)
res_len = kernel32.SizeofResource(exe_handle, res_info)
res_arr = ctypes.cast(res_data, ctypes.POINTER(ctypes.c_char))[:res_len]
return res_arr
def g(s):
DOMAIN = 'youtube_dl'
lang, _ = locale.getdefaultlocale()
try:
t = gettext.translation(DOMAIN, find_file_in_root('share/locale/'), [lang])
except (OSError, IOError): # OSError for 3.3+ and IOError otherwise
t = None
if t is None and sys.platform == 'win32' and hasattr(sys, 'frozen'):
locale_data_zip = _load_exe_resource('LOCALE_DATA', 'LOCALE_DATA.ZIP')
f = io.BytesIO(locale_data_zip)
zipf = zipfile.ZipFile(f)
with zipf.open('share/locale/%s/LC_MESSAGES/%s.mo' % (lang, DOMAIN)) as mo_file:
t = gettext.GNUTranslations(mo_file)
zipf.close()
if t is None:
return s
ret = t.gettext(s)