mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Welcome wizard now allows you to set interface language. Fixes #3736 (First question of wizard...)
This commit is contained in:
parent
5040b8178e
commit
dcca0f9a3e
@ -168,7 +168,9 @@ def main(args=sys.argv):
|
||||
sys.argv = args[:1]
|
||||
base = os.path.dirname(os.path.abspath(opts.exec_file))
|
||||
sys.path.insert(0, base)
|
||||
execfile(opts.exec_file)
|
||||
g = globals()
|
||||
g['__name__'] = '__main__'
|
||||
execfile(opts.exec_file, g)
|
||||
elif opts.debug_device_driver:
|
||||
debug_device_driver()
|
||||
elif opts.migrate:
|
||||
|
@ -33,8 +33,8 @@ class Device(object):
|
||||
|
||||
output_profile = 'default'
|
||||
output_format = 'EPUB'
|
||||
name = _('Default')
|
||||
manufacturer = _('Default')
|
||||
name = 'Default'
|
||||
manufacturer = 'Default'
|
||||
id = 'default'
|
||||
|
||||
@classmethod
|
||||
@ -146,8 +146,9 @@ def get_manufacturers():
|
||||
mans = set([])
|
||||
for x in get_devices():
|
||||
mans.add(x.manufacturer)
|
||||
mans.remove(_('Default'))
|
||||
return [_('Default')] + sorted(mans)
|
||||
if 'Default' in mans:
|
||||
mans.remove('Default')
|
||||
return ['Default'] + sorted(mans)
|
||||
|
||||
def get_devices_of(manufacturer):
|
||||
ans = [d for d in get_devices() if d.manufacturer == manufacturer]
|
||||
@ -464,6 +465,36 @@ class LibraryPage(QWizardPage, LibraryUI):
|
||||
self.setupUi(self)
|
||||
self.registerField('library_location', self.location)
|
||||
self.connect(self.button_change, SIGNAL('clicked()'), self.change)
|
||||
self.init_languages()
|
||||
self.connect(self.language, SIGNAL('currentIndexChanged(int)'),
|
||||
self.change_language)
|
||||
|
||||
def init_languages(self):
|
||||
self.language.blockSignals(True)
|
||||
self.language.clear()
|
||||
from calibre.utils.localization import available_translations, \
|
||||
get_language, get_lang
|
||||
lang = get_lang()
|
||||
if lang is None or lang not in available_translations():
|
||||
lang = 'en'
|
||||
self.language.addItem(get_language(lang), QVariant(lang))
|
||||
items = [(l, get_language(l)) for l in available_translations() \
|
||||
if l != lang]
|
||||
if lang != 'en':
|
||||
items.append(('en', get_language('en')))
|
||||
items.sort(cmp=lambda x, y: cmp(x[1], y[1]))
|
||||
for item in items:
|
||||
self.language.addItem(item[1], QVariant(item[0]))
|
||||
self.language.blockSignals(False)
|
||||
|
||||
def change_language(self, idx):
|
||||
prefs['language'] = str(self.language.itemData(self.language.currentIndex()).toString())
|
||||
import __builtin__
|
||||
__builtin__.__dict__['_'] = lambda(x): x
|
||||
from calibre.utils.localization import set_translators
|
||||
set_translators()
|
||||
self.emit(SIGNAL('retranslate()'))
|
||||
self.init_languages()
|
||||
|
||||
def change(self):
|
||||
dir = choose_dir(self, 'database location dialog',
|
||||
@ -548,6 +579,8 @@ class Wizard(QWizard):
|
||||
self.setPixmap(self.BackgroundPixmap, QPixmap(I('wizard.svg')))
|
||||
self.device_page = DevicePage()
|
||||
self.library_page = LibraryPage()
|
||||
self.connect(self.library_page, SIGNAL('retranslate()'),
|
||||
self.retranslate)
|
||||
self.finish_page = FinishPage()
|
||||
bt = unicode(self.buttonText(self.FinishButton)).replace('&', '')
|
||||
t = unicode(self.finish_page.finish_text.text())
|
||||
@ -572,6 +605,10 @@ class Wizard(QWizard):
|
||||
nw = min(580, nw)
|
||||
self.resize(nw, nh)
|
||||
|
||||
def retranslate(self):
|
||||
for pid in self.pageIds():
|
||||
page = self.page(pid)
|
||||
page.retranslateUi(page)
|
||||
|
||||
def accept(self):
|
||||
pages = map(self.page, self.visitedPages())
|
||||
|
@ -20,7 +20,20 @@
|
||||
<string>The one stop solution to all your e-book needs.</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Choose your &language:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>language</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="language"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Choose a location for your books. When you add books to calibre, they will be copied here:</string>
|
||||
@ -30,21 +43,31 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="location">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="button_change">
|
||||
<property name="text">
|
||||
<string>&Change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>If you have an existing calibre library, it will be copied to the new location. If a calibre library already exists at the new location, calibre will switch to using it.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -57,15 +80,18 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>If you have an existing calibre library, it will be copied to the new location. If a calibre library already exists at the new location, calibre will switch to using it.</string>
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
Loading…
x
Reference in New Issue
Block a user