# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys, time, datetime, re
+from i18n import _
try:
import PyQt4
print "on Linux systems, you may try 'sudo apt-get install python-qt4'"
sys.exit(1)
-
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import PyQt4.QtCore as QtCore
self.funds_error = False
self.tabs = tabs = QTabWidget(self)
- tabs.addTab(self.create_history_tab(), 'History')
+ tabs.addTab(self.create_history_tab(), _('History') )
if self.wallet.seed:
- tabs.addTab(self.create_send_tab(), 'Send')
- tabs.addTab(self.create_receive_tab(), 'Receive')
- tabs.addTab(self.create_contacts_tab(),'Contacts')
- tabs.addTab(self.create_wall_tab(), 'Wall')
+ tabs.addTab(self.create_send_tab(), _('Send') )
+ tabs.addTab(self.create_receive_tab(), _('Receive') )
+ tabs.addTab(self.create_contacts_tab(), _('Contacts') )
+ tabs.addTab(self.create_wall_tab(), _('Wall') )
tabs.setMinimumSize(600, 400)
tabs.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.setCentralWidget(tabs)
def update_wallet(self):
if self.wallet.interface and self.wallet.interface.is_connected:
if self.wallet.blocks == -1:
- text = "Connecting..."
+ text = _( "Connecting..." )
icon = QIcon(":icons/status_disconnected.png")
elif self.wallet.blocks == 0:
- text = "Server not ready"
+ text = _( "Server not ready" )
icon = QIcon(":icons/status_disconnected.png")
elif not self.wallet.up_to_date:
- text = "Synchronizing..."
+ text = _( "Synchronizing..." )
icon = QIcon(":icons/status_waiting.png")
else:
c, u = self.wallet.get_balance()
- text = "Balance: %s "%( format_satoshis(c,False,self.wallet.num_zeros) )
+ text = _( "Balance" ) + ": %s "%( format_satoshis(c,False,self.wallet.num_zeros) )
if u: text += "[%s unconfirmed]"%( format_satoshis(u,True,self.wallet.num_zeros).strip() )
icon = QIcon(":icons/status_connected.png")
else:
- text = "Not connected"
+ text = _( "Not connected" )
icon = QIcon(":icons/status_disconnected.png")
if self.funds_error:
- text = "Not enough funds"
+ text = _( "Not enough funds" )
self.statusBar().showMessage(text)
self.status_button.setIcon( icon )
w.setColumnWidth(2, 350)
w.setColumnWidth(3, 140)
w.setColumnWidth(4, 140)
- w.setHeaderLabels( [ '', 'Date', 'Description', 'Amount', 'Balance'] )
+ w.setHeaderLabels( [ '', _( 'Date' ), _( 'Description' ) , _('Amount'), _('Balance')] )
self.connect(w, SIGNAL('itemActivated(QTreeWidgetItem*, int)'), self.tx_details)
self.connect(w, SIGNAL('itemDoubleClicked(QTreeWidgetItem*, int)'), self.tx_label_clicked)
self.connect(w, SIGNAL('itemChanged(QTreeWidgetItem*, int)'), self.tx_label_changed)
conf = 0
time_str = 'pending'
- tx_details = "Transaction Details:\n\n" \
+ tx_details = _("Transaction Details") +"\n\n" \
+ "Transaction ID:\n" + tx_hash + "\n\n" \
+ "Status: %d confirmations\n\n"%conf \
+ "Date: %s\n\n"%time_str \
grid.setColumnStretch(4,1)
self.payto_e = QLineEdit()
- grid.addWidget(QLabel('Pay to'), 1, 0)
+ grid.addWidget(QLabel(_('Pay to')), 1, 0)
grid.addWidget(self.payto_e, 1, 1, 1, 3)
self.message_e = QLineEdit()
- grid.addWidget(QLabel('Description'), 2, 0)
+ grid.addWidget(QLabel(_('Description')), 2, 0)
grid.addWidget(self.message_e, 2, 1, 1, 3)
self.amount_e = QLineEdit()
- grid.addWidget(QLabel('Amount'), 3, 0)
+ grid.addWidget(QLabel(_('Amount')), 3, 0)
grid.addWidget(self.amount_e, 3, 1, 1, 2)
self.fee_e = QLineEdit()
- grid.addWidget(QLabel('Fee'), 4, 0)
+ grid.addWidget(QLabel(_('Fee')), 4, 0)
grid.addWidget(self.fee_e, 4, 1, 1, 2)
- b = EnterButton("Send", self.do_send)
+ b = EnterButton(_("Send"), self.do_send)
grid.addWidget(b, 5, 1)
- b = EnterButton("Clear",self.do_clear)
+ b = EnterButton(_("Clear"),self.do_clear)
grid.addWidget(b, 5, 2)
self.payto_sig = QLabel('')
to_address = r
if not self.wallet.is_valid(to_address):
- QMessageBox.warning(self, 'Error', 'Invalid Bitcoin Address:\n'+to_address, 'OK')
+ QMessageBox.warning(self, _('Error'), _('Invalid Bitcoin Address') + ':\n' + to_address, _('OK'))
return
try:
amount = int( Decimal( unicode( self.amount_e.text())) * 100000000 )
except:
- QMessageBox.warning(self, 'Error', 'Invalid Amount', 'OK')
+ QMessageBox.warning(self, _('Error'), _('Invalid Amount'), _('OK'))
return
try:
fee = int( Decimal( unicode( self.fee_e.text())) * 100000000 )
except:
- QMessageBox.warning(self, 'Error', 'Invalid Fee', 'OK')
+ QMessageBox.warning(self, _('Error'), _('Invalid Fee'), _('OK'))
return
if self.wallet.use_encryption:
status, msg = self.wallet.sendtx( tx )
if status:
- QMessageBox.information(self, '', 'Payment sent.\n'+msg, 'OK')
+ QMessageBox.information(self, '', _('Payment sent.')+'\n'+msg, _('OK'))
self.do_clear()
self.update_contacts_tab()
else:
- QMessageBox.warning(self, 'Error', msg, 'OK')
+ QMessageBox.warning(self, _('Error'), msg, _('OK'))
def set_url(self, url):
l = self.contacts_list
hbox = self.contacts_buttons_hbox
- hbox.addWidget(EnterButton("QR",lambda: self.show_address_qrcode(self.get_current_addr(False))))
- hbox.addWidget(EnterButton("Copy to Clipboard", lambda: self.app.clipboard().setText(self.get_current_addr(False))))
+ hbox.addWidget(EnterButton(_("QR"),lambda: self.show_address_qrcode(self.get_current_addr(False))))
+ hbox.addWidget(EnterButton(_("Copy to Clipboard"), lambda: self.app.clipboard().setText(self.get_current_addr(False))))
def payto():
addr = self.get_current_addr(False)
if not addr:return
self.tabs.setCurrentIndex(1)
self.payto_e.setText(addr)
self.amount_e.setFocus()
- hbox.addWidget(EnterButton('Pay to', lambda: payto()))
- hbox.addWidget(EnterButton("New", self.newaddress_dialog))
+ hbox.addWidget(EnterButton(_('Pay to'), lambda: payto()))
+ hbox.addWidget(EnterButton(_("New"), self.newaddress_dialog))
hbox.addStretch(1)
def update_receive_buttons(self):
addr = self.get_current_addr(True)
- t = "Unfreeze" if addr in self.wallet.frozen_addresses else "Freeze"
+ t = _("Unfreeze") if addr in self.wallet.frozen_addresses else _("Freeze")
self.freezeButton.setText(t)
l.setColumnWidth(1, 330)
l.setColumnWidth(2, 100)
l.setColumnWidth(3, 10)
- l.setHeaderLabels( ['Address', 'Label','Balance','Tx'])
+ l.setHeaderLabels( [_('Address'), _('Label'), _('Balance'), _('Tx')] )
w = QWidget()
vbox = QVBoxLayout()
l.setColumnWidth(0, 350)
l.setColumnWidth(1, 330)
l.setColumnWidth(2, 20)
- l.setHeaderLabels( ['Address', 'Label','Tx'])
+ l.setHeaderLabels( [_('Address'), _('Label'), _('Tx')] )
w = QWidget()
vbox = QVBoxLayout()
self.setStatusBar(sb)
def newaddress_dialog(self):
- text, ok = QInputDialog.getText(self, 'New Contact', 'Address:')
+ text, ok = QInputDialog.getText(self, _('New Contact'), _('Address') + ':')
address = unicode(text)
if ok:
if self.wallet.is_valid(address):
self.wallet.save()
self.update_contacts_tab()
else:
- QMessageBox.warning(self, 'Error', 'Invalid Address', 'OK')
+ QMessageBox.warning(self, _('Error'), _('Invalid Address'), _('OK'))
@staticmethod
def show_seed_dialog(wallet, parent=None):
from electrum import mnemonic
if not wallet.seed:
- QMessageBox.information(parent, 'Message', 'No seed', 'OK')
+ QMessageBox.information(parent, _('Message'), _('No seed'), _('OK'))
return
if wallet.use_encryption:
try:
seed = wallet.pw_decode( wallet.seed, password)
except:
- QMessageBox.warning(parent, 'Error', 'Invalid Password', 'OK')
+ QMessageBox.warning(parent, _('Error'), _('Invalid Password'), _('OK'))
return
- msg = "Your wallet generation seed is:\n\n" + seed \
- + "\n\nPlease keep it in a safe place; if you lose it,\nyou will not be able to restore your wallet.\n\n" \
- + "Equivalently, your wallet seed can be stored and\nrecovered with the following mnemonic code:\n\n\"" \
+ msg = _("Your wallet generation seed is") + ":\n\n" + seed + "\n\n"\
+ + _("Please keep it in a safe place; if you lose it, you will not be able to restore your wallet.") + "\n\n" \
+ + _("Equivalently, your wallet seed can be stored and recovered with the following mnemonic code") + ":\n\n\"" \
+ ' '.join(mnemonic.mn_encode(seed)) + "\"\n\n\n"
d = QDialog(None)
d.setModal(1)
- d.setWindowTitle("Seed")
+ d.setWindowTitle(_("Seed"))
d.setMinimumSize(400, 270)
vbox = QVBoxLayout()
else:
app = QApplication
- b = QPushButton("Copy to Clipboard")
+ b = QPushButton(_("Copy to Clipboard"))
b.clicked.connect(lambda: app.clipboard().setText(seed + ' "' + ' '.join(mnemonic.mn_encode(seed))+'"'))
hbox.addWidget(b)
- b = QPushButton("View as QR Code")
+ b = QPushButton(_("View as QR Code"))
b.clicked.connect(lambda: ElectrumWindow.show_seed_qrcode(seed))
hbox.addWidget(b)
- b = QPushButton("OK")
+ b = QPushButton(_("OK"))
b.clicked.connect(d.accept)
hbox.addWidget(b)
vbox.addLayout(hbox)
if not seed: return
d = QDialog(None)
d.setModal(1)
- d.setWindowTitle("Seed")
+ d.setWindowTitle(_("Seed"))
d.setMinimumSize(270, 300)
vbox = QVBoxLayout()
vbox.addWidget(QRCodeWidget(seed))
hbox = QHBoxLayout()
hbox.addStretch(1)
- b = QPushButton("OK")
+ b = QPushButton(_("OK"))
hbox.addWidget(b)
b.clicked.connect(d.accept)
hbox = QHBoxLayout()
amount_e = QLineEdit()
- hbox.addWidget(QLabel('Amount'))
+ hbox.addWidget(QLabel(_('Amount')))
hbox.addWidget(amount_e)
vbox.addLayout(hbox)
def do_save():
from electrum import bmp
bmp.save_qrcode(qrw.qr, "qrcode.bmp")
- self.show_message("QR code saved to file 'qrcode.bmp'")
+ self.show_message(_("QR code saved to file") + " 'qrcode.bmp'")
amount_e.textChanged.connect( amount_changed )
hbox = QHBoxLayout()
hbox.addStretch(1)
- b = QPushButton("Save")
+ b = QPushButton(_("Save"))
b.clicked.connect(do_save)
hbox.addWidget(b)
- b = QPushButton("Close")
+ b = QPushButton(_("Close"))
hbox.addWidget(b)
b.clicked.connect(d.accept)
d.exec_()
def question(self, msg):
- return QMessageBox.question(self, 'Message', msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes
+ return QMessageBox.question(self, _('Message'), msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes
def show_message(self, msg):
- QMessageBox.information(self, 'Message', msg, 'OK')
+ QMessageBox.information(self, _('Message'), msg, _('OK'))
def password_dialog(self ):
d = QDialog(self)
pw.setEchoMode(2)
vbox = QVBoxLayout()
- msg = 'Please enter your password'
+ msg = _('Please enter your password')
vbox.addWidget(QLabel(msg))
grid = QGridLayout()
grid.setSpacing(8)
- grid.addWidget(QLabel('Password'), 1, 0)
+ grid.addWidget(QLabel(_('Password')), 1, 0)
grid.addWidget(pw, 1, 1)
vbox.addLayout(grid)
def change_password_dialog( wallet, parent=None ):
if not wallet.seed:
- QMessageBox.information(parent, 'Message', 'No seed', 'OK')
+ QMessageBox.information(parent, _('Error'), _('No seed'), _('OK'))
return
d = QDialog(parent)
vbox = QVBoxLayout()
if parent:
- msg = 'Your wallet is encrypted. Use this dialog to change your password.\nTo disable wallet encryption, enter an empty new password.' if wallet.use_encryption else 'Your wallet keys are not encrypted'
+ msg = (_('Your wallet is encrypted. Use this dialog to change your password.')+'\n'+_('To disable wallet encryption, enter an empty new password.')) if wallet.use_encryption else _('Your wallet keys are not encrypted')
else:
- msg = "Please choose a password to encrypt your wallet keys.\nLeave these fields empty if you want to disable encryption."
+ msg = _("Please choose a password to encrypt your wallet keys.")+'\n'+_("Leave these fields empty if you want to disable encryption.")
vbox.addWidget(QLabel(msg))
grid = QGridLayout()
grid.setSpacing(8)
if wallet.use_encryption:
- grid.addWidget(QLabel('Password'), 1, 0)
+ grid.addWidget(QLabel(_('Password')), 1, 0)
grid.addWidget(pw, 1, 1)
- grid.addWidget(QLabel('New Password'), 2, 0)
+ grid.addWidget(QLabel(_('New Password')), 2, 0)
grid.addWidget(new_pw, 2, 1)
- grid.addWidget(QLabel('Confirm Password'), 3, 0)
+ grid.addWidget(QLabel(_('Confirm Password')), 3, 0)
grid.addWidget(conf_pw, 3, 1)
vbox.addLayout(grid)
try:
seed = wallet.pw_decode( wallet.seed, password)
except:
- QMessageBox.warning(parent, 'Error', 'Incorrect Password', 'OK')
+ QMessageBox.warning(parent, _('Error'), _('Incorrect Password'), _('OK'))
return
if new_password != new_password2:
- QMessageBox.warning(parent, 'Error', 'Passwords do not match', 'OK')
+ QMessageBox.warning(parent, _('Error'), _('Passwords do not match'), _('OK'))
return
wallet.update_password(seed, password, new_password)
d.setModal(1)
vbox = QVBoxLayout()
- msg = "Please enter your wallet seed or the corresponding mnemonic list of words, and the gap limit of your wallet."
+ msg = _("Please enter your wallet seed or the corresponding mnemonic list of words, and the gap limit of your wallet.")
vbox.addWidget(QLabel(msg))
grid = QGridLayout()
grid.setSpacing(8)
seed_e = QLineEdit()
- grid.addWidget(QLabel('Seed or mnemonic'), 1, 0)
+ grid.addWidget(QLabel(_('Seed or mnemonic')), 1, 0)
grid.addWidget(seed_e, 1, 1)
gap_e = QLineEdit()
gap_e.setText("5")
- grid.addWidget(QLabel('Gap limit'), 2, 0)
+ grid.addWidget(QLabel(_('Gap limit')), 2, 0)
grid.addWidget(gap_e, 2, 1)
gap_e.textChanged.connect(lambda: numbify(gap_e,True))
vbox.addLayout(grid)
try:
gap = int(unicode(gap_e.text()))
except:
- QMessageBox.warning(None, 'Error', 'error', 'OK')
+ QMessageBox.warning(None, _('Error'), 'error', 'OK')
sys.exit(0)
try:
try:
seed = mnemonic.mn_decode( seed.split(' ') )
except:
- QMessageBox.warning(None, 'Error', 'I cannot decode this', 'OK')
+ QMessageBox.warning(None, _('Error'), _('I cannot decode this'), _('OK'))
sys.exit(0)
if not seed:
- QMessageBox.warning(None, 'Error', 'no seed', 'OK')
+ QMessageBox.warning(None, _('Error'), _('No seed'), 'OK')
sys.exit(0)
wallet.seed = str(seed)
vbox = QVBoxLayout()
- msg = 'Here are the settings of your wallet.'
+ msg = _('Here are the settings of your wallet.')
vbox.addWidget(QLabel(msg))
grid = QGridLayout()
fee_e = QLineEdit()
fee_e.setText("%s"% str( Decimal( self.wallet.fee)/100000000 ) )
- grid.addWidget(QLabel('Fee per tx. input'), 2, 0)
+ grid.addWidget(QLabel(_('Fee per tx. input')), 2, 0)
grid.addWidget(fee_e, 2, 1)
fee_e.textChanged.connect(lambda: numbify(fee_e,False))
nz_e = QLineEdit()
nz_e.setText("%d"% self.wallet.num_zeros)
- grid.addWidget(QLabel('Zeros displayed after decimal point'), 3, 0)
+ grid.addWidget(QLabel(_('Zeros displayed after decimal point')), 3, 0)
grid.addWidget(nz_e, 3, 1)
nz_e.textChanged.connect(lambda: numbify(nz_e,True))
try:
fee = int( 100000000 * Decimal(fee) )
except:
- QMessageBox.warning(self, 'Error', 'Invalid value:%s'%fee, 'OK')
+ QMessageBox.warning(self, _('Error'), _('Invalid value') +': %s'%fee, _('OK'))
return
if self.wallet.fee != fee:
nz = int( nz )
if nz>8: nz=8
except:
- QMessageBox.warning(self, 'Error', 'Invalid value:%s'%nz, 'OK')
+ QMessageBox.warning(self, _('Error'), _('Invalid value')+':%s'%nz, _('OK'))
return
if self.wallet.num_zeros != nz:
interface = wallet.interface
if parent:
if interface.is_connected:
- status = "Connected to %s:%d\n%d blocks"%(interface.host, interface.port, wallet.blocks)
+ status = _("Connected to")+" %s:%d\n%d blocks"%(interface.host, interface.port, wallet.blocks)
else:
- status = "Not connected"
+ status = _("Not connected")
server = wallet.server
else:
import random
- status = "Please choose a server."
+ status = _("Please choose a server.")
server = random.choice( DEFAULT_SERVERS )
if not wallet.interface.servers:
set_button(current_line()[2])
- hbox.addWidget(QLabel('Protocol:'))
+ hbox.addWidget(QLabel(_('Protocol:')))
hbox.addWidget(radio1)
hbox.addWidget(radio2)
vbox.addLayout(hbox)
if wallet.interface.servers:
- label = 'Active Servers'
+ label = _('Active Servers')
else:
- label = 'Default Servers'
+ label = _('Default Servers')
servers_list_widget = QTreeWidget(parent)
servers_list_widget.setHeaderLabels( [ label ] )
try:
wallet.set_server(server)
except:
- QMessageBox.information(None, 'Error', 'error', 'OK')
+ QMessageBox.information(None, _('Error'), 'error', _('OK'))
if parent == None:
sys.exit(1)
else:
def restore_or_create(self):
- msg = "Wallet file not found.\nDo you want to create a new wallet,\n or to restore an existing one?"
+ msg = _("Wallet file not found.")+"\n"+_("Do you want to create a new wallet, or to restore an existing one?")
r = QMessageBox.question(None, 'Message', msg, 'create', 'restore', 'cancel', 0, 2)
if r==2: return False
print "recovery successful"
wallet.save()
else:
- QMessageBox.information(None, 'Message', "No transactions found for this seed", 'OK')
+ QMessageBox.information(None, _('Error'), _("No transactions found for this seed"), _('OK'))
wallet.save()
return True