Language #455

Merged
Atheros1 merged 11 commits from master into master 2013-08-28 04:32:35 +02:00
3 changed files with 63 additions and 7 deletions
Showing only changes of commit a6b946f5be - Show all commits

View File

@ -2031,6 +2031,10 @@ class MyForm(QtGui.QMainWindow):
self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked())) self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked()))
shared.config.set('bitmessagesettings', 'willinglysendtomobile', str( shared.config.set('bitmessagesettings', 'willinglysendtomobile', str(
self.settingsDialogInstance.ui.checkBoxWillinglySendToMobile.isChecked())) self.settingsDialogInstance.ui.checkBoxWillinglySendToMobile.isChecked()))
shared.config.set('bitmessagesettings', 'overridelocale', str(
self.settingsDialogInstance.ui.checkBoxOverrideLocale.isChecked()))
shared.config.set('bitmessagesettings', 'userlocale', str(
self.settingsDialogInstance.ui.lineEditUserLocale.text()))
if int(shared.config.get('bitmessagesettings', 'port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()): if int(shared.config.get('bitmessagesettings', 'port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()):
if not shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'): if not shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'):
QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate( QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
@ -3041,6 +3045,10 @@ class settingsDialog(QtGui.QDialog):
shared.config.getboolean('bitmessagesettings', 'startintray')) shared.config.getboolean('bitmessagesettings', 'startintray'))
self.ui.checkBoxWillinglySendToMobile.setChecked( self.ui.checkBoxWillinglySendToMobile.setChecked(
shared.safeConfigGetBoolean('bitmessagesettings', 'willinglysendtomobile')) shared.safeConfigGetBoolean('bitmessagesettings', 'willinglysendtomobile'))
self.ui.checkBoxOverrideLocale.setChecked(
shared.safeConfigGetBoolean('bitmessagesettings', 'overridelocale'))
self.ui.lineEditUserLocale.setText(str(
shared.config.get('bitmessagesettings', 'userlocale')))
if shared.appdata == '': if shared.appdata == '':
self.ui.checkBoxPortableMode.setChecked(True) self.ui.checkBoxPortableMode.setChecked(True)
if 'darwin' in sys.platform: if 'darwin' in sys.platform:
@ -3405,11 +3413,39 @@ def run():
app = QtGui.QApplication(sys.argv) app = QtGui.QApplication(sys.argv)
translator = QtCore.QTranslator() translator = QtCore.QTranslator()
local_countrycode = str(locale.getdefaultlocale()[0])
locale_lang = local_countrycode[0:2]
user_countrycode = str(shared.config.get('bitmessagesettings', 'userlocale'))
user_lang = user_countrycode[0:2]
translation_path = "translations/bitmessage_"
if shared.config.getboolean('bitmessagesettings', 'overridelocale') == True:
# try the userinput if "overwridelanguage" is checked
try: try:
translator.load("translations/bitmessage_" + str(locale.getdefaultlocale()[0])) # check if the user input is a valid translation file
#translator.load("translations/bitmessage_fr_BE") # test French # this would also capture weird "countrycodes" like "en_pirate" or just "pirate"
translator.load(translation_path + user_countrycode)
except:
try:
# check if the user lang is a valid translation file
# in some cases this won't make sense, e.g. trying "pi" from "pirate"
translator.load(translation_path + user_lang)
except: except:
# The above is not compatible with all versions of OSX. # The above is not compatible with all versions of OSX.
# Don't have language either, default to 'Merica USA! USA!
translator.load("translations/bitmessage_en_US") # Default to english.
else:
# try the userinput if "overridelanguage" is checked
try:
# check if the user input is a valid translation file
translator.load(translation_path + local_countrycode)
except:
try:
# check if the user lang is a valid translation file
translator.load(translation_path + locale_lang)
except:
# The above is not compatible with all versions of OSX.
# Don't have language either, default to 'Merica USA! USA!
translator.load("translations/bitmessage_en_US") # Default to english. translator.load("translations/bitmessage_en_US") # Default to english.
QtGui.QApplication.installTranslator(translator) QtGui.QApplication.installTranslator(translator)

View File

@ -71,6 +71,14 @@ class Ui_settingsDialog(object):
self.checkBoxWillinglySendToMobile = QtGui.QCheckBox(self.tabUserInterface) self.checkBoxWillinglySendToMobile = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxWillinglySendToMobile.setObjectName(_fromUtf8("checkBoxWillinglySendToMobile")) self.checkBoxWillinglySendToMobile.setObjectName(_fromUtf8("checkBoxWillinglySendToMobile"))
self.gridLayout_5.addWidget(self.checkBoxWillinglySendToMobile, 6, 0, 1, 1) self.gridLayout_5.addWidget(self.checkBoxWillinglySendToMobile, 6, 0, 1, 1)
self.checkBoxOverrideLocale = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxOverrideLocale.setObjectName(_fromUtf8("checkBoxOverrideLocale"))
self.gridLayout_5.addWidget(self.checkBoxOverrideLocale, 7, 0, 1, 1)
self.lineEditUserLocale = QtGui.QLineEdit(self.tabUserInterface)
self.lineEditUserLocale.setObjectName(_fromUtf8("lineEditUserLocale"))
self.lineEditUserLocale.setMaximumSize(QtCore.QSize(70, 16777215))
self.lineEditUserLocale.setEnabled(False)
self.gridLayout_5.addWidget(self.lineEditUserLocale, 7, 1, 1, 1)
self.tabWidgetSettings.addTab(self.tabUserInterface, _fromUtf8("")) self.tabWidgetSettings.addTab(self.tabUserInterface, _fromUtf8(""))
self.tabNetworkSettings = QtGui.QWidget() self.tabNetworkSettings = QtGui.QWidget()
self.tabNetworkSettings.setObjectName(_fromUtf8("tabNetworkSettings")) self.tabNetworkSettings.setObjectName(_fromUtf8("tabNetworkSettings"))
@ -305,6 +313,7 @@ class Ui_settingsDialog(object):
self.tabWidgetSettings.setCurrentIndex(0) self.tabWidgetSettings.setCurrentIndex(0)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), settingsDialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), settingsDialog.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), settingsDialog.reject) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), settingsDialog.reject)
QtCore.QObject.connect(self.checkBoxOverrideLocale, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEditUserLocale.setEnabled)
QtCore.QObject.connect(self.checkBoxAuthentication, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEditSocksUsername.setEnabled) QtCore.QObject.connect(self.checkBoxAuthentication, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEditSocksUsername.setEnabled)
QtCore.QObject.connect(self.checkBoxAuthentication, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEditSocksPassword.setEnabled) QtCore.QObject.connect(self.checkBoxAuthentication, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEditSocksPassword.setEnabled)
QtCore.QMetaObject.connectSlotsByName(settingsDialog) QtCore.QMetaObject.connectSlotsByName(settingsDialog)
@ -331,6 +340,7 @@ class Ui_settingsDialog(object):
self.checkBoxStartOnLogon.setText(_translate("settingsDialog", "Start Bitmessage on user login", None)) self.checkBoxStartOnLogon.setText(_translate("settingsDialog", "Start Bitmessage on user login", None))
self.checkBoxPortableMode.setText(_translate("settingsDialog", "Run in Portable Mode", None)) self.checkBoxPortableMode.setText(_translate("settingsDialog", "Run in Portable Mode", None))
self.checkBoxWillinglySendToMobile.setText(_translate("settingsDialog", "Willingly include unencrypted destination address when sending to a mobile device", None)) self.checkBoxWillinglySendToMobile.setText(_translate("settingsDialog", "Willingly include unencrypted destination address when sending to a mobile device", None))
self.checkBoxOverrideLocale.setText(_translate("settingsDialog", "Override automatic language localization (use countycode or language code, e.g. 'en_US' or 'en'):", None))
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabUserInterface), _translate("settingsDialog", "User Interface", None)) self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabUserInterface), _translate("settingsDialog", "User Interface", None))
self.groupBox.setTitle(_translate("settingsDialog", "Listening port", None)) self.groupBox.setTitle(_translate("settingsDialog", "Listening port", None))
self.label.setText(_translate("settingsDialog", "Listen for connections on port:", None)) self.label.setText(_translate("settingsDialog", "Listen for connections on port:", None))

View File

@ -2,6 +2,7 @@ import shared
import ConfigParser import ConfigParser
import sys import sys
import os import os
import locale
from namecoin import ensureNamecoinOptions from namecoin import ensureNamecoinOptions
@ -69,6 +70,15 @@ def loadConfig():
shared.config.set( shared.config.set(
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', '0') 'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', '0')
shared.config.set('bitmessagesettings', 'dontconnect', 'true') shared.config.set('bitmessagesettings', 'dontconnect', 'true')
shared.config.set('bitmessagesettings', 'overridelocale', 'false')
try:
# this should set the userdefined locale to the default locale
# like this, the user will know his default locale
shared.config.set('bitmessagesettings', 'userlocale', str(locale.getdefaultlocale()[0]))
except:
# if we cannot determine the default locale let's default to english
# they user might use this as an country code
shared.config.set('bitmessagesettings', 'userlocale', 'en_US')
ensureNamecoinOptions() ensureNamecoinOptions()
if storeConfigFilesInSameDirectoryAsProgramByDefault: if storeConfigFilesInSameDirectoryAsProgramByDefault: