mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Qt translations now work again
This commit is contained in:
parent
ad72afa9f9
commit
f60b270cce
@ -6,7 +6,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import sys, os, textwrap
|
import sys, os, textwrap, subprocess
|
||||||
|
|
||||||
from setup import Command, islinux, basenames, modules, functions
|
from setup import Command, islinux, basenames, modules, functions
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ class Develop(Command):
|
|||||||
description = 'Setup a development environment'
|
description = 'Setup a development environment'
|
||||||
MODE = 0755
|
MODE = 0755
|
||||||
|
|
||||||
sub_commands = ['build']
|
sub_commands = ['build', 'translations']
|
||||||
|
|
||||||
def add_options(self, parser):
|
def add_options(self, parser):
|
||||||
parser.set_usage(textwrap.dedent('''\
|
parser.set_usage(textwrap.dedent('''\
|
||||||
@ -64,8 +64,12 @@ class Develop(Command):
|
|||||||
self.regain_privileges()
|
self.regain_privileges()
|
||||||
self.find_locations(opts)
|
self.find_locations(opts)
|
||||||
self.write_templates(opts)
|
self.write_templates(opts)
|
||||||
|
self.run_postinstall()
|
||||||
self.success()
|
self.success()
|
||||||
|
|
||||||
|
def run_postinstall(self):
|
||||||
|
subprocess.check_call(['calibre_postinstall'])
|
||||||
|
|
||||||
def success(self):
|
def success(self):
|
||||||
self.info('\nDevelopment environment successfully setup')
|
self.info('\nDevelopment environment successfully setup')
|
||||||
|
|
||||||
|
@ -76,7 +76,8 @@ class Translations(POT):
|
|||||||
self.info('\tCopying ISO 639 translations')
|
self.info('\tCopying ISO 639 translations')
|
||||||
shutil.copy2(iso639, dest)
|
shutil.copy2(iso639, dest)
|
||||||
else:
|
else:
|
||||||
self.warn('No ISO 639 translations for locale:', locale)
|
self.warn('No ISO 639 translations for locale:', locale,
|
||||||
|
'\nDo you have pycountry installed?')
|
||||||
|
|
||||||
base = os.path.join(pyqt.qt_data_dir, 'translations')
|
base = os.path.join(pyqt.qt_data_dir, 'translations')
|
||||||
qt_translations = glob.glob(os.path.join(base, 'qt_*.qm'))
|
qt_translations = glob.glob(os.path.join(base, 'qt_*.qm'))
|
||||||
|
@ -532,6 +532,7 @@ class ResizableDialog(QDialog):
|
|||||||
|
|
||||||
gui_thread = None
|
gui_thread = None
|
||||||
|
|
||||||
|
|
||||||
class Application(QApplication):
|
class Application(QApplication):
|
||||||
|
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
@ -539,10 +540,9 @@ class Application(QApplication):
|
|||||||
QApplication.__init__(self, qargs)
|
QApplication.__init__(self, qargs)
|
||||||
global gui_thread
|
global gui_thread
|
||||||
gui_thread = QThread.currentThread()
|
gui_thread = QThread.currentThread()
|
||||||
self.translator = QTranslator(self)
|
self._translator = QTranslator(self)
|
||||||
if set_qt_translator(self.translator):
|
if set_qt_translator(self._translator):
|
||||||
print 1111111
|
self.installTranslator(self._translator)
|
||||||
self.installTranslator(self.translator)
|
|
||||||
|
|
||||||
def is_ok_to_use_qt():
|
def is_ok_to_use_qt():
|
||||||
global gui_thread
|
global gui_thread
|
||||||
|
@ -1821,12 +1821,12 @@ def init_qt(args):
|
|||||||
opts, args = parser.parse_args(args)
|
opts, args = parser.parse_args(args)
|
||||||
if opts.with_library is not None and os.path.isdir(opts.with_library):
|
if opts.with_library is not None and os.path.isdir(opts.with_library):
|
||||||
prefs.set('library_path', os.path.abspath(opts.with_library))
|
prefs.set('library_path', os.path.abspath(opts.with_library))
|
||||||
print 'Using library at', prefs['library_path']
|
prints('Using library at', prefs['library_path'])
|
||||||
|
QCoreApplication.setOrganizationName(ORG_NAME)
|
||||||
|
QCoreApplication.setApplicationName(APP_UID)
|
||||||
app = Application(args)
|
app = Application(args)
|
||||||
actions = tuple(Main.create_application_menubar())
|
actions = tuple(Main.create_application_menubar())
|
||||||
app.setWindowIcon(QIcon(':/library'))
|
app.setWindowIcon(QIcon(':/library'))
|
||||||
QCoreApplication.setOrganizationName(ORG_NAME)
|
|
||||||
QCoreApplication.setApplicationName(APP_UID)
|
|
||||||
return app, opts, args, actions
|
return app, opts, args, actions
|
||||||
|
|
||||||
def run_gui(opts, args, actions, listener, app):
|
def run_gui(opts, args, actions, listener, app):
|
||||||
|
@ -115,6 +115,6 @@ def set_qt_translator(translator):
|
|||||||
for x in (lang, lang.split('_')[0]):
|
for x in (lang, lang.split('_')[0]):
|
||||||
p = os.path.join(messages_path(x), 'qt.qm')
|
p = os.path.join(messages_path(x), 'qt.qm')
|
||||||
if os.path.exists(p):
|
if os.path.exists(p):
|
||||||
return translator.loadFromData(open(p, 'rb').read())
|
return translator.load(p)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user