forked from openlp/openlp
Select Language at startup
This commit is contained in:
parent
289ce0de5f
commit
f295ac5407
@ -276,8 +276,10 @@ def main():
|
||||
if QtCore.QSettings().value(
|
||||
u'general/first time', QtCore.QVariant(True)).toBool():
|
||||
FirstTimeForm().exec_()
|
||||
pass
|
||||
# i18n Set Language
|
||||
language = LanguageManager.get_language()
|
||||
print language
|
||||
appTranslator = LanguageManager.get_translator(language)
|
||||
app.installTranslator(appTranslator)
|
||||
if not options.no_error_form:
|
||||
|
@ -69,6 +69,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
else:
|
||||
self.internetGroupBox.setVisible(False)
|
||||
self.noInternetLabel.setVisible(True)
|
||||
if LanguageManager.auto_language:
|
||||
self.LanguageComboBox.setEnabled(False)
|
||||
self.qmList = LanguageManager.get_qm_list()
|
||||
for key in sorted(self.qmList.keys()):
|
||||
self.LanguageComboBox.addItem(key)
|
||||
@ -83,8 +85,14 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
self.__pluginStatus(self.customCheckBox, u'custom/status')
|
||||
self.__pluginStatus(self.songUsageCheckBox, u'songusage/status')
|
||||
self.__pluginStatus(self.alertCheckBox, u'alerts/status')
|
||||
|
||||
print self.qmList[unicode(self.LanguageComboBox.currentText())]
|
||||
if self.autoLanguageCheckBox.checkState() == QtCore.Qt.Checked:
|
||||
LanguageManager.auto_language = True
|
||||
LanguageManager.set_language(False, False)
|
||||
else:
|
||||
LanguageManager.auto_language = False
|
||||
action = QtGui.QAction(None)
|
||||
action.setObjectName(unicode(self.LanguageComboBox.currentText()))
|
||||
LanguageManager.set_language(action, False)
|
||||
return QtGui.QWizard.accept(self)
|
||||
|
||||
def __pluginStatus(self, field, tag):
|
||||
|
@ -99,16 +99,20 @@ class LanguageManager(object):
|
||||
return language
|
||||
|
||||
@staticmethod
|
||||
def set_language(action):
|
||||
def set_language(action, message=True):
|
||||
"""
|
||||
Set the language to translate OpenLP into
|
||||
|
||||
``action``
|
||||
The language menu option
|
||||
|
||||
``message``
|
||||
Display the message option
|
||||
"""
|
||||
language = u'en'
|
||||
if action:
|
||||
action_name = u'%s' % action.objectName()
|
||||
print action_name
|
||||
qm_list = LanguageManager.get_qm_list()
|
||||
language = u'%s' % qm_list[action_name]
|
||||
if LanguageManager.auto_language:
|
||||
@ -116,6 +120,7 @@ class LanguageManager(object):
|
||||
QtCore.QSettings().setValue(
|
||||
u'general/language', QtCore.QVariant(language))
|
||||
log.info(u'Language file: \'%s\' written to conf file' % language)
|
||||
if message:
|
||||
QtGui.QMessageBox.information(None,
|
||||
translate('OpenLP.LanguageManager', 'Language'),
|
||||
translate('OpenLP.LanguageManager',
|
||||
|
@ -300,8 +300,8 @@ p, li { white-space: pre-wrap; }
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>252</width>
|
||||
<height>88</height>
|
||||
<width>491</width>
|
||||
<height>113</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
@ -339,15 +339,29 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="languageLabel">
|
||||
<property name="text">
|
||||
<string>Select default language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="LanguageComboBox"/>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="LanguageComboBox">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="autoLanguageCheckBox">
|
||||
<property name="text">
|
||||
<string>Auto Language</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user