From 5e126ad91ca15053a8830252c5028e623ce53690 Mon Sep 17 00:00:00 2001 From: Vincent Texier <vit@free.fr> Date: Tue, 9 Jun 2015 19:51:27 +0200 Subject: [PATCH] fix referential selectors not translated --- res/i18n/ts/fr_FR.ts | 71 +++++++++++++++++++--------- src/cutecoin/core/account.py | 28 +++++------ src/cutecoin/gui/mainwindow.py | 18 +++---- src/cutecoin/gui/preferences.py | 8 ++-- src/cutecoin/gui/transactions_tab.py | 3 +- 5 files changed, 75 insertions(+), 53 deletions(-) diff --git a/res/i18n/ts/fr_FR.ts b/res/i18n/ts/fr_FR.ts index edcecfe2..b3d5bdc7 100644 --- a/res/i18n/ts/fr_FR.ts +++ b/res/i18n/ts/fr_FR.ts @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> -<TS version="2.1" language="fr_FR" sourcelanguage="en"> +<TS version="2.0" language="fr_FR" sourcelanguage="en"> <context> <name>@default</name> <message> @@ -52,17 +52,42 @@ <message> <location filename="../../../src/cutecoin/core/account.py" line="61"/> <source>ud {0}</source> - <translation>du {0}</translation> + <translation type="obsolete">du {0}</translation> + </message> + <message> + <location filename="../../../src/cutecoin/core/account.py" line="54"/> + <source>Units</source> + <translation>Unités</translation> + </message> + <message> + <location filename="../../../src/cutecoin/core/account.py" line="56"/> + <source>UD</source> + <translation>DU</translation> </message> <message> <location filename="../../../src/cutecoin/core/account.py" line="58"/> - <source>q0 {0}</source> - <translation></translation> + <source>Quant Z-sum</source> + <translation>Quant. som. 0</translation> </message> <message> <location filename="../../../src/cutecoin/core/account.py" line="61"/> - <source>r0 {0}</source> - <translation></translation> + <source>Relat Z-sum</source> + <translation>Rel. som. 0</translation> + </message> + <message> + <location filename="../../../src/cutecoin/core/account.py" line="61"/> + <source>UD {0}</source> + <translation>DU {0}</translation> + </message> + <message> + <location filename="../../../src/cutecoin/core/account.py" line="58"/> + <source>Q0 {0}</source> + <translation>Q0 {0}</translation> + </message> + <message> + <location filename="../../../src/cutecoin/core/account.py" line="61"/> + <source>R0 {0}</source> + <translation>R0 {0}</translation> </message> </context> <context> @@ -1075,7 +1100,7 @@ Revoking your UID can only success if it is not already validated by the network <translation>Sauvegarder</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/mainwindow.py" line="390"/> + <location filename="../../../src/cutecoin/gui/mainwindow.py" line="388"/> <source>Export</source> <translation>Exporter</translation> </message> @@ -1151,17 +1176,17 @@ Revoking your UID can only success if it is not already validated by the network <translation>CuteCoin {0}</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/mainwindow.py" line="368"/> + <location filename="../../../src/cutecoin/gui/mainwindow.py" line="366"/> <source>CuteCoin {0} - Account : {1}</source> <translation>CuteCoin {0} - Compte : {1}</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/mainwindow.py" line="388"/> + <location filename="../../../src/cutecoin/gui/mainwindow.py" line="386"/> <source>Export an account</source> <translation>Exporter un compte</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/mainwindow.py" line="389"/> + <location filename="../../../src/cutecoin/gui/mainwindow.py" line="387"/> <source>All account files (*.acc)</source> <translation>Tout fichier de compte (*.acc)</translation> </message> @@ -1592,27 +1617,27 @@ Souhaitez-vous publier votre clé publique ?</translation> <context> <name>TransactionsTabWidget</name> <message> - <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="120"/> + <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="129"/> <source>Actions</source> <translation>Actions</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="133"/> + <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="142"/> <source>Send again</source> <translation>Renvoyer</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="138"/> + <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="147"/> <source>Cancel</source> <translation>Annuler</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="144"/> + <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="153"/> <source>Informations</source> <translation>Informations</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="149"/> + <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="158"/> <source>Add as contact</source> <translation>Ajouter comme contact</translation> </message> @@ -1627,44 +1652,44 @@ Souhaitez-vous publier votre clé publique ?</translation> <translation type="obsolete">Voir dans la WoT</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="165"/> + <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="174"/> <source>Copy pubkey to clipboard</source> <translation>Copier la clé publique</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="202"/> + <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="211"/> <source>Warning</source> <translation>Attention</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="202"/> + <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="211"/> <source>Are you sure ? This money transfer will be removed and not sent.</source> <translation>Êtes vous certain ? Le transfer de monnaie sera annulé et non envoyé.</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="103"/> + <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="112"/> <source><b>Deposits</b> {:} {:}</source> <translation><b>Crédit</b> {:} {:}</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="107"/> + <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="116"/> <source><b>Payments</b> {:} {:}</source> <translation><b>Débit</b> {:} {:}</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="111"/> + <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="120"/> <source><b>Balance</b> {:} {:}</source> <translation><b>Balance</b> {:} {:}</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="154"/> + <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="163"/> <source>Send money</source> <translation>Envoyer de l'argent</translation> </message> <message> - <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="160"/> + <location filename="../../../src/cutecoin/gui/transactions_tab.py" line="169"/> <source>View in Web of Trust</source> <translation>Voir dans la Toile de Confiance</translation> </message> diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py index 6c364f79..7076c753 100644 --- a/src/cutecoin/core/account.py +++ b/src/cutecoin/core/account.py @@ -45,24 +45,20 @@ def relative_zerosum(units, community): class Account(QObject): - - ''' + """ An account is specific to a key. Each account has only one key, and a key can be locally referenced by only one account. - ''' - referentials = {'Units': (quantitative, '{0}', - quantitative, '{0}'), - 'UD': (relative, QT_TRANSLATE_NOOP('Account', 'ud {0}'), - relative, QT_TRANSLATE_NOOP('Account', 'ud {0}')), - 'Quant Z-sum': (quantitative_zerosum, - QT_TRANSLATE_NOOP('Account', 'q0 {0}'), - quantitative, '{0}'), - 'Relat Z-sum': (relative_zerosum, - QT_TRANSLATE_NOOP('Account', 'r0 {0}'), - relative, - QT_TRANSLATE_NOOP('Account', 'ud {0}')) - } + """ + referentials = ( + (quantitative, '{0}', quantitative, '{0}', QT_TRANSLATE_NOOP('Account', 'Units')), + (relative, QT_TRANSLATE_NOOP('Account', 'UD {0}'), relative, QT_TRANSLATE_NOOP('Account', 'UD {0}'), + QT_TRANSLATE_NOOP('Account', 'UD')), + (quantitative_zerosum, QT_TRANSLATE_NOOP('Account', 'Q0 {0}'), quantitative, '{0}', + QT_TRANSLATE_NOOP('Account', 'Quant Z-sum')), + (relative_zerosum, QT_TRANSLATE_NOOP('Account', 'R0 {0}'), relative, QT_TRANSLATE_NOOP('Account', 'UD {0}'), + QT_TRANSLATE_NOOP('Account', 'Relat Z-sum')) + ) loading_progressed = pyqtSignal(int, int) @@ -88,7 +84,7 @@ class Account(QObject): self.communities = communities self.wallets = wallets self.contacts = contacts - self.referential = 'Units' + self.referential = 0 @classmethod def create(cls, name): diff --git a/src/cutecoin/gui/mainwindow.py b/src/cutecoin/gui/mainwindow.py index bb653895..8ff27b16 100644 --- a/src/cutecoin/gui/mainwindow.py +++ b/src/cutecoin/gui/mainwindow.py @@ -9,8 +9,8 @@ from ..gen_resources.about_uic import Ui_AboutPopup from PyQt5.QtWidgets import QMainWindow, QAction, QFileDialog, QProgressBar, \ QMessageBox, QLabel, QComboBox, QDialog, QApplication from PyQt5.QtCore import QSignalMapper, QObject, \ - pyqtSlot, pyqtSignal, QDate, QDateTime, QTimer, QUrl, Qt -from PyQt5.QtGui import QIcon, QDesktopServices, QPixmap + pyqtSlot, pyqtSignal, QDate, QDateTime, QTimer, QUrl, Qt, QCoreApplication +from PyQt5.QtGui import QIcon, QDesktopServices from .process_cfg_account import ProcessConfigureAccount from .transfer import TransferMoneyDialog @@ -19,7 +19,6 @@ from .contact import ConfigureContactDialog from .import_account import ImportAccountDialog from .certification import CertificationDialog from .password_asker import PasswordAskerDialog -from ..tools.exceptions import NoPeerAvailable from .preferences import PreferencesDialog from .homescreen import HomeScreenWidget from ..core.account import Account @@ -27,7 +26,6 @@ from ..__init__ import __version__ from . import toast import logging -import requests class Loader(QObject): @@ -83,7 +81,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.combo_referential = QComboBox(self) self.combo_referential.setEnabled(False) - self.combo_referential.currentTextChanged.connect(self.referential_changed) + self.combo_referential.currentIndexChanged.connect(self.referential_changed) self.status_label = QLabel("", self) self.status_label.setTextFormat(Qt.RichText) @@ -125,9 +123,9 @@ class MainWindow(QMainWindow, Ui_MainWindow): QMessageBox.Ok) @pyqtSlot(str) - def referential_changed(self, text): + def referential_changed(self, index): if self.app.current_account: - self.app.current_account.set_display_referential(text) + self.app.current_account.set_display_referential(index) if self.currencies_tabwidget.currentWidget(): self.currencies_tabwidget.currentWidget().referential_changed() @@ -352,10 +350,12 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.combo_referential.blockSignals(True) self.combo_referential.clear() - self.combo_referential.addItems(sorted(Account.referentials.keys())) + for ref in self.app.current_account.referentials: + self.combo_referential.addItem(QCoreApplication.translate('Account', ref[4])) + self.combo_referential.setEnabled(True) self.combo_referential.blockSignals(False) - self.combo_referential.setCurrentText(self.app.preferences['ref']) + self.combo_referential.setCurrentIndex(self.app.preferences['ref']) self.menu_account.setEnabled(True) self.action_configure_parameters.setEnabled(True) self.setWindowTitle(self.tr("CuteCoin {0} - Account : {1}").format(__version__, diff --git a/src/cutecoin/gui/preferences.py b/src/cutecoin/gui/preferences.py index 51c92d02..ce81989d 100644 --- a/src/cutecoin/gui/preferences.py +++ b/src/cutecoin/gui/preferences.py @@ -4,7 +4,7 @@ Created on 11 mai 2015 @author: inso ''' -import logging +from PyQt5.QtCore import QCoreApplication from ..core.account import Account from PyQt5.QtWidgets import QDialog @@ -30,8 +30,8 @@ class PreferencesDialog(QDialog, Ui_PreferencesDialog): self.combo_account.addItem(account_name) self.combo_account.setCurrentText(self.app.preferences['account']) for ref in Account.referentials: - self.combo_referential.addItem(ref) - self.combo_referential.setCurrentText(self.app.preferences['ref']) + self.combo_referential.addItem(QCoreApplication.translate('Account', ref[4])) + self.combo_referential.setCurrentIndex(self.app.preferences['ref']) for lang in ('en_GB', 'fr_FR'): self.combo_language.addItem(lang) self.combo_language.setCurrentText(self.app.preferences['lang']) @@ -39,7 +39,7 @@ class PreferencesDialog(QDialog, Ui_PreferencesDialog): def accept(self): pref = {'account': self.combo_account.currentText(), 'lang': self.combo_language.currentText(), - 'ref': self.combo_referential.currentText()} + 'ref': self.combo_referential.currentIndex()} self.app.save_preferences(pref) super().accept() diff --git a/src/cutecoin/gui/transactions_tab.py b/src/cutecoin/gui/transactions_tab.py index 2c18c645..5b825e37 100644 --- a/src/cutecoin/gui/transactions_tab.py +++ b/src/cutecoin/gui/transactions_tab.py @@ -82,7 +82,8 @@ class TransactionsTabWidget(QWidget, Ui_transactionsTabWidget): self.table_history.resizeColumnsToContents() def refresh_balance(self): - if self.app.current_account.referential == 'Units': + # if referential is "units" + if self.app.current_account.referential == 0: self.label_balance.show() self.label_deposit.show() self.label_payment.show() -- GitLab